From 5a48f0d7f2a715f80f38dbd18c224d434c18e1fb Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 30 May 2024 09:57:27 -0700 Subject: [PATCH] Better default value for RELEASE_PLATFORM_VERSION If the release config name is a build prefix and different from the inherited value, set RELEASE_PLATFORM_VERSION based on the release config name. Bug: 348495189 Test: manual Change-Id: I95d715150cba9b57e343a8b8364d36f38dcc18a3 --- .../release_config_lib/release_config.go | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cmd/release_config/release_config_lib/release_config.go b/cmd/release_config/release_config_lib/release_config.go index 3e2348f1b..46430531f 100644 --- a/cmd/release_config/release_config_lib/release_config.go +++ b/cmd/release_config/release_config_lib/release_config.go @@ -18,6 +18,7 @@ import ( "cmp" "fmt" "path/filepath" + "regexp" "slices" "sort" "strings" @@ -137,9 +138,15 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro config.compileInProgress = true isRoot := config.Name == "root" + // Is this a build-prefix release config, such as 'ap3a'? + isBuildPrefix, err := regexp.MatchString("^[a-z][a-z][0-9][0-9a-z]$", config.Name) + if err != nil { + return err + } // Start with only the flag declarations. config.FlagArtifacts = configs.FlagArtifacts.Clone() releaseAconfigValueSets := config.FlagArtifacts["RELEASE_ACONFIG_VALUE_SETS"] + releasePlatformVersion := config.FlagArtifacts["RELEASE_PLATFORM_VERSION"] // Generate any configs we need to inherit. This will detect loops in // the config. @@ -147,7 +154,7 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro myInherits := []string{} myInheritsSet := make(map[string]bool) // If there is a "root" release config, it is the start of every inheritance chain. - _, err := configs.GetReleaseConfig("root") + _, err = configs.GetReleaseConfig("root") if err == nil && !isRoot { config.InheritNames = append([]string{"root"}, config.InheritNames...) } @@ -179,6 +186,20 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) myDirsMap := make(map[int]bool) + if isBuildPrefix && releasePlatformVersion != nil { + if MarshalValue(releasePlatformVersion.Value) != strings.ToUpper(config.Name) { + value := FlagValue{ + path: config.Contributions[0].path, + proto: rc_proto.FlagValue{ + Name: releasePlatformVersion.FlagDeclaration.Name, + Value: UnmarshalValue(strings.ToUpper(config.Name)), + }, + } + if err := releasePlatformVersion.UpdateValue(value); err != nil { + return err + } + } + } for _, contrib := range contributionsToApply { contribAconfigValueSets := []string{} // Gather the aconfig_value_sets from this contribution, allowing duplicates for simplicity.