Merge "Export release flag types to make/soong" into main

This commit is contained in:
Treehugger Robot 2024-05-22 02:26:00 +00:00 committed by Gerrit Code Review
commit d7b71490ae
4 changed files with 35 additions and 3 deletions

View file

@ -2157,8 +2157,18 @@ func (e configurationEvalutor) EvaluateConfiguration(condition proptools.Configu
ctx.OtherModulePropertyErrorf(m, property, "release_flag requires 1 argument, found %d", condition.NumArgs())
return proptools.ConfigurableValueUndefined()
}
if v, ok := ctx.Config().productVariables.BuildFlags[condition.Arg(0)]; ok {
return proptools.ConfigurableValueString(v)
if ty, ok := ctx.Config().productVariables.BuildFlagTypes[condition.Arg(0)]; ok {
v := ctx.Config().productVariables.BuildFlags[condition.Arg(0)]
switch ty {
case "unspecified", "obsolete":
return proptools.ConfigurableValueUndefined()
case "string":
return proptools.ConfigurableValueString(v)
case "bool":
return proptools.ConfigurableValueBool(v == "true")
default:
panic("unhandled release flag type: " + ty)
}
}
return proptools.ConfigurableValueUndefined()
case "product_variable":

View file

@ -492,6 +492,8 @@ type ProductVariables struct {
BuildFlags map[string]string `json:",omitempty"`
BuildFlagTypes map[string]string `json:",omitempty"`
BuildFromSourceStub *bool `json:",omitempty"`
BuildIgnoreApexContributionContents *bool `json:",omitempty"`

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 {