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
This commit is contained in:
Patrice Arruda
2020-11-13 11:37:06 -08:00
parent af880da0c4
commit 18cb70d645

View File

@@ -19,6 +19,8 @@ import (
"os"
"path/filepath"
"strings"
"android/soong/shared"
)
func runBazel(ctx Context, config Config) {
@@ -45,9 +47,12 @@ func runBazel(ctx Context, config Config) {
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 {