From f656b8434bcb0035902000408d0b59d45eded73a Mon Sep 17 00:00:00 2001 From: "Lukacs T. Berki" Date: Wed, 11 Aug 2021 11:10:28 +0200 Subject: [PATCH] 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 --- cmd/multiproduct_kati/Android.bp | 2 +- cmd/multiproduct_kati/main.go | 39 ++++++++++++++++---------------- cmd/soong_ui/Android.bp | 1 + cmd/soong_ui/main.go | 3 ++- cuj/Android.bp | 1 + cuj/cuj.go | 3 ++- ui/build/Android.bp | 1 - ui/signal/Android.bp | 28 +++++++++++++++++++++++ ui/{build => signal}/signal.go | 2 +- 9 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 ui/signal/Android.bp rename ui/{build => signal}/signal.go (99%) diff --git a/cmd/multiproduct_kati/Android.bp b/cmd/multiproduct_kati/Android.bp index 21d8e21f2..e5be6c0c8 100644 --- a/cmd/multiproduct_kati/Android.bp +++ b/cmd/multiproduct_kati/Android.bp @@ -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", diff --git a/cmd/multiproduct_kati/main.go b/cmd/multiproduct_kati/main.go index 8bfa7723d..284638772 100644 --- a/cmd/multiproduct_kati/main.go +++ b/cmd/multiproduct_kati/main.go @@ -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 + Logger logger.Logger + Status status.ToolStatus - 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, + Logger: log, + Status: s, + 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(), diff --git a/cmd/soong_ui/Android.bp b/cmd/soong_ui/Android.bp index 4f5eea900..9f10b823f 100644 --- a/cmd/soong_ui/Android.bp +++ b/cmd/soong_ui/Android.bp @@ -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", diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go index 02c522977..d70978727 100644 --- a/cmd/soong_ui/main.go +++ b/cmd/soong_ui/main.go @@ -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() diff --git a/cuj/Android.bp b/cuj/Android.bp index a2da6e68e..f9cfdc1d2 100644 --- a/cuj/Android.bp +++ b/cuj/Android.bp @@ -7,6 +7,7 @@ blueprint_go_binary { deps: [ "soong-ui-build", "soong-ui-logger", + "soong-ui-signal", "soong-ui-terminal", "soong-ui-tracer", ], diff --git a/cuj/cuj.go b/cuj/cuj.go index b4ae9a263..413f4237f 100644 --- a/cuj/cuj.go +++ b/cuj/cuj.go @@ -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() diff --git a/ui/build/Android.bp b/ui/build/Android.bp index 37940bafa..3dc87f584 100644 --- a/ui/build/Android.bp +++ b/ui/build/Android.bp @@ -61,7 +61,6 @@ bootstrap_go_package { "proc_sync.go", "rbe.go", "sandbox_config.go", - "signal.go", "soong.go", "test_build.go", "upload.go", diff --git a/ui/signal/Android.bp b/ui/signal/Android.bp new file mode 100644 index 000000000..08933a130 --- /dev/null +++ b/ui/signal/Android.bp @@ -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", + ], +} diff --git a/ui/build/signal.go b/ui/signal/signal.go similarity index 99% rename from ui/build/signal.go rename to ui/signal/signal.go index 6643e2ffb..4929a7bfe 100644 --- a/ui/build/signal.go +++ b/ui/signal/signal.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package build +package signal import ( "os"