Export release flag types to make/soong

And use the types to appropriately type selects on the release
variables.

Bug: 323382414
Test: Presubmits
Change-Id: Ide7eca95662caaa7b4be42e20399d9fcd7fed35f
This commit is contained in:
Cole Faust
2024-05-21 16:51:59 -07:00
parent 1ab18fc547
commit 751a4a5fa2
4 changed files with 35 additions and 3 deletions

View File

@@ -74,3 +74,22 @@ func MarshalValue(value *rc_proto.Value) string {
return ""
}
}
// Returns a string representation of the type of the value for make
func ValueType(value *rc_proto.Value) string {
if value == nil || value.Val == nil {
return "unspecified"
}
switch value.Val.(type) {
case *rc_proto.Value_UnspecifiedValue:
return "unspecified"
case *rc_proto.Value_StringValue:
return "string"
case *rc_proto.Value_BoolValue:
return "bool"
case *rc_proto.Value_Obsolete:
return "obsolete"
default:
panic("Unhandled type")
}
}

View File

@@ -348,6 +348,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro
}
value := MarshalValue(flag.Value)
makeVars[name] = value
addVar(name, "TYPE", ValueType(flag.Value))
addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
addVar(name, "DEFAULT", MarshalValue(decl.Value))
addVar(name, "VALUE", value)
@@ -356,7 +357,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro
addVar(name, "NAMESPACE", *decl.Namespace)
}
pNames := []string{}
for k, _ := range partitions {
for k := range partitions {
pNames = append(pNames, k)
}
slices.SortFunc(pNames, func(a, b string) int {