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:
@@ -2157,8 +2157,18 @@ func (e configurationEvalutor) EvaluateConfiguration(condition proptools.Configu
|
|||||||
ctx.OtherModulePropertyErrorf(m, property, "release_flag requires 1 argument, found %d", condition.NumArgs())
|
ctx.OtherModulePropertyErrorf(m, property, "release_flag requires 1 argument, found %d", condition.NumArgs())
|
||||||
return proptools.ConfigurableValueUndefined()
|
return proptools.ConfigurableValueUndefined()
|
||||||
}
|
}
|
||||||
if v, ok := ctx.Config().productVariables.BuildFlags[condition.Arg(0)]; ok {
|
if ty, ok := ctx.Config().productVariables.BuildFlagTypes[condition.Arg(0)]; ok {
|
||||||
return proptools.ConfigurableValueString(v)
|
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()
|
return proptools.ConfigurableValueUndefined()
|
||||||
case "product_variable":
|
case "product_variable":
|
||||||
|
@@ -492,6 +492,8 @@ type ProductVariables struct {
|
|||||||
|
|
||||||
BuildFlags map[string]string `json:",omitempty"`
|
BuildFlags map[string]string `json:",omitempty"`
|
||||||
|
|
||||||
|
BuildFlagTypes map[string]string `json:",omitempty"`
|
||||||
|
|
||||||
BuildFromSourceStub *bool `json:",omitempty"`
|
BuildFromSourceStub *bool `json:",omitempty"`
|
||||||
|
|
||||||
BuildIgnoreApexContributionContents *bool `json:",omitempty"`
|
BuildIgnoreApexContributionContents *bool `json:",omitempty"`
|
||||||
|
@@ -74,3 +74,22 @@ func MarshalValue(value *rc_proto.Value) string {
|
|||||||
return ""
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -348,6 +348,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro
|
|||||||
}
|
}
|
||||||
value := MarshalValue(flag.Value)
|
value := MarshalValue(flag.Value)
|
||||||
makeVars[name] = value
|
makeVars[name] = value
|
||||||
|
addVar(name, "TYPE", ValueType(flag.Value))
|
||||||
addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
|
addVar(name, "PARTITIONS", strings.Join(decl.Containers, " "))
|
||||||
addVar(name, "DEFAULT", MarshalValue(decl.Value))
|
addVar(name, "DEFAULT", MarshalValue(decl.Value))
|
||||||
addVar(name, "VALUE", value)
|
addVar(name, "VALUE", value)
|
||||||
@@ -356,7 +357,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro
|
|||||||
addVar(name, "NAMESPACE", *decl.Namespace)
|
addVar(name, "NAMESPACE", *decl.Namespace)
|
||||||
}
|
}
|
||||||
pNames := []string{}
|
pNames := []string{}
|
||||||
for k, _ := range partitions {
|
for k := range partitions {
|
||||||
pNames = append(pNames, k)
|
pNames = append(pNames, k)
|
||||||
}
|
}
|
||||||
slices.SortFunc(pNames, func(a, b string) int {
|
slices.SortFunc(pNames, func(a, b string) int {
|
||||||
|
Reference in New Issue
Block a user