summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
author Patrice Arruda <patricearruda@google.com> 2020-12-08 19:42:08 +0000
committer Patrice Arruda <patricearruda@google.com> 2020-12-08 20:24:14 +0000
commit83842d72352d92db10048edd8665aec71b939cfd (patch)
treee0a7a17b744fed35d80d3364698af9511ae64646 /shared
parentc27dd1a9bb8de33de8877239df9b4e475bb6fb04 (diff)
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 <dist dir>/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 <dist dir>/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
Diffstat (limited to 'shared')
-rw-r--r--shared/paths.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/shared/paths.go b/shared/paths.go
index 24ba057aa..f5dc5dd2e 100644
--- a/shared/paths.go
+++ b/shared/paths.go
@@ -20,21 +20,23 @@ import (
"path/filepath"
)
+// A SharedPaths represents a list of paths that are shared between
+// soong_ui and soong.
+type SharedPaths interface {
+ // BazelMetricsDir returns the path where a set of bazel profile
+ // files are stored for later processed by the metrics pipeline.
+ BazelMetricsDir() string
+}
+
// Given the out directory, returns the root of the temp directory (to be cleared at the start of each execution of Soong)
func TempDirForOutDir(outDir string) (tempPath string) {
return filepath.Join(outDir, ".temp")
}
-// BazelMetricsDir returns the path where a set of bazel profile
-// files are stored for later processed by the metrics pipeline.
-func BazelMetricsDir(outDir string) string {
- return filepath.Join(outDir, "bazel_metrics")
-}
-
// BazelMetricsFilename returns the bazel profile filename based
// on the action name. This is to help to store a set of bazel
// profiles since bazel may execute multiple times during a single
// build.
-func BazelMetricsFilename(outDir, actionName string) string {
- return filepath.Join(BazelMetricsDir(outDir), actionName+"_bazel_profile.gz")
+func BazelMetricsFilename(s SharedPaths, actionName string) string {
+ return filepath.Join(s.BazelMetricsDir(), actionName+"_bazel_profile.gz")
}