Store build targets in the soong metrics.
Bug: 194519312
Test: Added unit test and verified the soong metrics file generated.
Change-Id: I832da2501e0e8d3435d4f92642cf45ddccb7f2ea
diff --git a/ui/build/config.go b/ui/build/config.go
index 35dacf2..5cd5c65 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -355,13 +355,16 @@
}
func buildConfig(config Config) *smpb.BuildConfig {
- return &smpb.BuildConfig{
+ c := &smpb.BuildConfig{
ForceUseGoma: proto.Bool(config.ForceUseGoma()),
UseGoma: proto.Bool(config.UseGoma()),
UseRbe: proto.Bool(config.UseRBE()),
BazelAsNinja: proto.Bool(config.UseBazel()),
BazelMixedBuild: proto.Bool(config.bazelBuildMode() == mixedBuild),
}
+ c.Targets = append(c.Targets, config.arguments...)
+
+ return c
}
// getConfigArgs processes the command arguments based on the build action and creates a set of new
diff --git a/ui/build/config_test.go b/ui/build/config_test.go
index 1f2158b..03d304e 100644
--- a/ui/build/config_test.go
+++ b/ui/build/config_test.go
@@ -1003,6 +1003,7 @@
tests := []struct {
name string
environ Environment
+ arguments []string
useBazel bool
expectedBuildConfig *smpb.BuildConfig
}{
@@ -1074,6 +1075,20 @@
},
},
{
+ name: "specified targets",
+ environ: Environment{},
+ useBazel: true,
+ arguments: []string{"droid", "dist"},
+ expectedBuildConfig: &smpb.BuildConfig{
+ ForceUseGoma: proto.Bool(false),
+ UseGoma: proto.Bool(false),
+ UseRbe: proto.Bool(false),
+ BazelAsNinja: proto.Bool(true),
+ BazelMixedBuild: proto.Bool(false),
+ Targets: []string{"droid", "dist"},
+ },
+ },
+ {
name: "all set",
environ: Environment{
"FORCE_USE_GOMA=1",
@@ -1095,8 +1110,9 @@
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
c := &configImpl{
- environ: &tc.environ,
- useBazel: tc.useBazel,
+ environ: &tc.environ,
+ useBazel: tc.useBazel,
+ arguments: tc.arguments,
}
config := Config{c}
actualBuildConfig := buildConfig(config)