Support release configs with only aconfig flags
Release configs with `aconfig_flags_only: true` can inherit build flag
values, but cannot set them.
Bug: 328495189
Test: manual
Change-Id: I2bdc88761d61fb20f10dc734f2ba87114f51b859
diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go
index b67374a..e107b9f 100644
--- a/cmd/release_config/crunch_flags/main.go
+++ b/cmd/release_config/crunch_flags/main.go
@@ -15,18 +15,29 @@
"google.golang.org/protobuf/proto"
)
-// When a flag declaration has an initial value that is a string, the default workflow is PREBUILT.
-// If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL.
-var manualFlagNamePrefixes []string = []string{
- "RELEASE_ACONFIG_",
- "RELEASE_PLATFORM_",
-}
+var (
+ // When a flag declaration has an initial value that is a string, the default workflow is PREBUILT.
+ // If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL.
+ manualFlagNamePrefixes []string = []string{
+ "RELEASE_ACONFIG_",
+ "RELEASE_PLATFORM_",
+ }
-var defaultFlagNamespace string = "android_UNKNOWN"
+ // Set `aconfig_flags_only: true` in these release configs.
+ aconfigFlagsOnlyConfigs map[string]bool = map[string]bool{
+ "trunk_food": true,
+ }
+
+ // Default namespace value. This is intentionally invalid.
+ defaultFlagNamespace string = "android_UNKNOWN"
+
+ // What is the current name for "next".
+ nextName string = "ap3a"
+)
func RenameNext(name string) string {
if name == "next" {
- return "ap3a"
+ return nextName
}
return name
}
@@ -205,6 +216,9 @@
fmt.Printf("%s: Unexpected value %s=%s\n", path, valName, valValue)
}
if flagValue != nil {
+ if releaseProto.AconfigFlagsOnly {
+ return fmt.Errorf("%s does not allow build flag overrides", RenameNext(name))
+ }
valPath := filepath.Join(dir, "flag_values", RenameNext(name), fmt.Sprintf("%s.textproto", valName))
err := WriteFile(valPath, flagValue)
if err != nil {
@@ -285,6 +299,9 @@
releaseConfig := &rc_proto.ReleaseConfig{
Name: proto.String(RenameNext(name)),
}
+ if aconfigFlagsOnlyConfigs[name] {
+ releaseConfig.AconfigFlagsOnly = true
+ }
configFiles := config[configRegexp.SubexpIndex("files")]
files := strings.Split(strings.ReplaceAll(configFiles, "$(local_dir)", dir+"/"), " ")
configInherits := config[configRegexp.SubexpIndex("inherits")]