Enable bazel metrics from ninja build.
Generate the bazel profile file that contains the metrics of
executing the ninja build phase of Soong.
Bug: b/173028918
Test: * m nothing and check out dir that there is no bazel_metrics dir.
* USE_BAZEL=1 m nothing and checked
out/bazel_metrics/build_bazel_profile.gz existed.
* m nothing and checked out/bazel_metrics does not exist.
Change-Id: I797d1eecf5c2c260ade8b55dc69c237bfd0fcbd4
diff --git a/ui/build/bazel.go b/ui/build/bazel.go
index 8a9fd14..0bc3a16 100644
--- a/ui/build/bazel.go
+++ b/ui/build/bazel.go
@@ -19,6 +19,8 @@
"os"
"path/filepath"
"strings"
+
+ "android/soong/shared"
)
func runBazel(ctx Context, config Config) {
@@ -45,9 +47,12 @@
cmd.Args = append(cmd.Args, strings.Fields(extra_startup_args)...)
}
+ actionName := "build"
cmd.Args = append(cmd.Args,
- "build",
+ actionName,
"--output_groups="+outputGroups,
+ "--profile="+filepath.Join(shared.BazelMetricsFilename(config.OutDir(), actionName)),
+ "--slim_profile=true",
)
if extra_build_args, ok := cmd.Environment.Get("BAZEL_BUILD_ARGS"); ok {