From 83842d72352d92db10048edd8665aec71b939cfd Mon Sep 17 00:00:00 2001 From: Patrice Arruda Date: Tue, 8 Dec 2020 19:42:08 +0000 Subject: Provide an interface for shared paths between Soong and Soong UI. Code refactoring has been done for logs directory logic code since the bazel metrics directory depends on the log directory. For builds that did not specify a dist directory, the log directory is under out directory. With dist, the logs directory is under /logs. This matters for Android CI builds where the metrics files are placed under logs directory. With this change, the bazel metrics directory and corresponding files will be under /logs directory for Android CI builds. Bug: b/174479728 Test: * USE_BAZEL=1 m nothing (bazel_metrics dir in out dir) * m nothing (bazel_metrics dir deleted) * DIST_DIR=/tmp/build USE_BAZEL=1 m nothing dist (bazel_metrics is in /tmp/build/logs directory) Change-Id: Ic9e1ff49a1964fcaaf801bde2c19f33597ca1db4 --- ui/build/bazel.go | 2 +- ui/build/config.go | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/build/bazel.go b/ui/build/bazel.go index 23b14ee1b..8a5a2b7d6 100644 --- a/ui/build/bazel.go +++ b/ui/build/bazel.go @@ -101,7 +101,7 @@ func runBazel(ctx Context, config Config) { // ninja_build target. "--output_groups="+outputGroups, // Generate a performance profile - "--profile="+filepath.Join(shared.BazelMetricsFilename(config.OutDir(), actionName)), + "--profile="+filepath.Join(shared.BazelMetricsFilename(config, actionName)), "--slim_profile=true", ) diff --git a/ui/build/config.go b/ui/build/config.go index c9911f3d1..72ae3fe75 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -275,7 +275,7 @@ func NewConfig(ctx Context, args ...string) Config { } } - bpd := shared.BazelMetricsDir(ret.OutDir()) + bpd := ret.BazelMetricsDir() if err := os.RemoveAll(bpd); err != nil { ctx.Fatalf("Unable to remove bazel profile directory %q: %v", bpd, err) } @@ -1121,3 +1121,20 @@ func (c *configImpl) MetricsUploaderApp() string { } return "" } + +// LogsDir returns the logs directory where build log and metrics +// files are located. By default, the logs directory is the out +// directory. If the argument dist is specified, the logs directory +// is /logs. +func (c *configImpl) LogsDir() string { + if c.Dist() { + return filepath.Join(c.DistDir(), "logs") + } + return c.OutDir() +} + +// BazelMetricsDir returns the /bazel_metrics directory +// where the bazel profiles are located. +func (c *configImpl) BazelMetricsDir() string { + return filepath.Join(c.LogsDir(), "bazel_metrics") +} -- cgit v1.2.3-59-g8ed1b