Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a48f0d7 authored by LaMont Jones's avatar LaMont Jones
Browse files

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
parent 2f9af237
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -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.