Cut the multiproduct_kati -> soong-ui-build dep.

This is done by moving SetupSignals() to its own little package.

There are a number of tiny little utility packages for soong_ui we might
be better of merging, but that's for another change (maybe)

Test: Presubmits.
Change-Id: I07b0ca98bfb8884ef4223d665e632183b9896a0d
This commit is contained in:
Lukacs T. Berki 2021-08-11 11:10:28 +02:00
parent 2c40569db0
commit f656b8434b
9 changed files with 55 additions and 25 deletions

View file

@ -19,8 +19,8 @@ package {
blueprint_go_binary {
name: "multiproduct_kati",
deps: [
"soong-ui-build",
"soong-ui-logger",
"soong-ui-signal",
"soong-ui-terminal",
"soong-ui-tracer",
"soong-zip",

View file

@ -31,8 +31,8 @@ import (
"syscall"
"time"
"android/soong/ui/build"
"android/soong/ui/logger"
"android/soong/ui/signal"
"android/soong/ui/status"
"android/soong/ui/terminal"
"android/soong/ui/tracer"
@ -127,12 +127,12 @@ func copyFile(from, to string) error {
}
type mpContext struct {
Context context.Context
Logger logger.Logger
Status status.ToolStatus
Tracer tracer.Tracer
LogsDir string
SoongUi string
MainOutDir string
MainLogsDir string
}
func detectTotalRAM() uint64 {
@ -179,7 +179,7 @@ func main() {
flag.Parse()
ctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
trace := tracer.New(log)
@ -192,7 +192,7 @@ func main() {
var failures failureCount
stat.AddOutput(&failures)
build.SetupSignals(log, cancel, func() {
signal.SetupSignals(log, cancel, func() {
trace.Close()
log.Cleanup()
stat.Finish()
@ -310,12 +310,11 @@ func main() {
s.SetTotalActions(len(finalProductsList))
mpCtx := &mpContext{
Context: ctx,
Logger: log,
Status: s,
Tracer: trace,
LogsDir: logsDir,
SoongUi: soongUi,
MainOutDir: outputDir,
MainLogsDir: logsDir,
}
products := make(chan string, len(productsList))
@ -337,7 +336,7 @@ func main() {
if product == "" {
return
}
runSoongUiForProduct(mpCtx, product, soongUi, outputDir)
runSoongUiForProduct(mpCtx, product)
}
}
}()
@ -391,10 +390,10 @@ func cleanupAfterProduct(outDir, productZip string) {
}
}
func runSoongUiForProduct(mpctx *mpContext, product, soongUi, mainOutDir string) {
outDir := filepath.Join(mainOutDir, product)
logsDir := filepath.Join(mpctx.LogsDir, product)
productZip := filepath.Join(mainOutDir, product+".zip")
func runSoongUiForProduct(mpctx *mpContext, product string) {
outDir := filepath.Join(mpctx.MainOutDir, product)
logsDir := filepath.Join(mpctx.MainLogsDir, product)
productZip := filepath.Join(mpctx.MainOutDir, product+".zip")
consoleLogPath := filepath.Join(logsDir, "std.log")
if err := os.MkdirAll(outDir, 0777); err != nil {
@ -429,7 +428,7 @@ func runSoongUiForProduct(mpctx *mpContext, product, soongUi, mainOutDir string)
args = append(args, "dist")
}
cmd := exec.Command(soongUi, args...)
cmd := exec.Command(mpctx.SoongUi, args...)
cmd.Stdout = consoleLogWriter
cmd.Stderr = consoleLogWriter
cmd.Env = append(os.Environ(),

View file

@ -20,6 +20,7 @@ blueprint_go_binary {
name: "soong_ui",
deps: [
"soong-ui-build",
"soong-ui-signal",
"soong-ui-logger",
"soong-ui-terminal",
"soong-ui-tracer",

View file

@ -30,6 +30,7 @@ import (
"android/soong/ui/build"
"android/soong/ui/logger"
"android/soong/ui/metrics"
"android/soong/ui/signal"
"android/soong/ui/status"
"android/soong/ui/terminal"
"android/soong/ui/tracer"
@ -190,7 +191,7 @@ func main() {
stat.AddOutput(trace.StatusTracer())
// Set up a cleanup procedure in case the normal termination process doesn't work.
build.SetupSignals(log, cancel, func() {
signal.SetupSignals(log, cancel, func() {
trace.Close()
log.Cleanup()
stat.Finish()

View file

@ -7,6 +7,7 @@ blueprint_go_binary {
deps: [
"soong-ui-build",
"soong-ui-logger",
"soong-ui-signal",
"soong-ui-terminal",
"soong-ui-tracer",
],

View file

@ -27,6 +27,7 @@ import (
"android/soong/ui/build"
"android/soong/ui/logger"
"android/soong/ui/metrics"
"android/soong/ui/signal"
"android/soong/ui/status"
"android/soong/ui/terminal"
"android/soong/ui/tracer"
@ -65,7 +66,7 @@ func (t *Test) Run(logsDir string) {
stat.AddOutput(output)
stat.AddOutput(trace.StatusTracer())
build.SetupSignals(log, cancel, func() {
signal.SetupSignals(log, cancel, func() {
trace.Close()
log.Cleanup()
stat.Finish()

View file

@ -61,7 +61,6 @@ bootstrap_go_package {
"proc_sync.go",
"rbe.go",
"sandbox_config.go",
"signal.go",
"soong.go",
"test_build.go",
"upload.go",

28
ui/signal/Android.bp Normal file
View file

@ -0,0 +1,28 @@
// Copyright 2021 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
bootstrap_go_package {
name: "soong-ui-signal",
pkgPath: "android/soong/ui/signal",
srcs: [
"signal.go",
],
deps: [
"soong-ui-logger",
],
}

View file

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package build
package signal
import (
"os"