Merge "Handle arch-variant in prebuilt_etc"
This commit is contained in:
@@ -48,6 +48,12 @@ func getLabelValue(label bazel.LabelAttribute) (reflect.Value, []selects) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if there is a select, use the base value as the conditions default value
|
||||||
|
if len(ret) > 0 {
|
||||||
|
ret[bazel.ConditionsDefaultSelectKey] = value
|
||||||
|
value = reflect.Zero(value.Type())
|
||||||
|
}
|
||||||
|
|
||||||
return value, []selects{ret}
|
return value, []selects{ret}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,3 +53,40 @@ prebuilt_etc {
|
|||||||
sub_dir = "tz",
|
sub_dir = "tz",
|
||||||
)`}})
|
)`}})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrebuiltEtcArchVariant(t *testing.T) {
|
||||||
|
runPrebuiltEtcTestCase(t, bp2buildTestCase{
|
||||||
|
description: "prebuilt_etc - simple example",
|
||||||
|
moduleTypeUnderTest: "prebuilt_etc",
|
||||||
|
moduleTypeUnderTestFactory: etc.PrebuiltEtcFactory,
|
||||||
|
moduleTypeUnderTestBp2BuildMutator: etc.PrebuiltEtcBp2Build,
|
||||||
|
filesystem: map[string]string{},
|
||||||
|
blueprint: `
|
||||||
|
prebuilt_etc {
|
||||||
|
name: "apex_tz_version",
|
||||||
|
src: "version/tz_version",
|
||||||
|
filename: "tz_version",
|
||||||
|
sub_dir: "tz",
|
||||||
|
installable: false,
|
||||||
|
arch: {
|
||||||
|
arm: {
|
||||||
|
src: "arm",
|
||||||
|
},
|
||||||
|
arm64: {
|
||||||
|
src: "arm64",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedBazelTargets: []string{`prebuilt_etc(
|
||||||
|
name = "apex_tz_version",
|
||||||
|
filename = "tz_version",
|
||||||
|
installable = False,
|
||||||
|
src = select({
|
||||||
|
"//build/bazel/platforms/arch:arm": "arm",
|
||||||
|
"//build/bazel/platforms/arch:arm64": "arm64",
|
||||||
|
"//conditions:default": "version/tz_version",
|
||||||
|
}),
|
||||||
|
sub_dir = "tz",
|
||||||
|
)`}})
|
||||||
|
}
|
||||||
|
@@ -673,8 +673,16 @@ func PrebuiltEtcBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *PrebuiltEtc) {
|
func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *PrebuiltEtc) {
|
||||||
var srcLabelAttribute bazel.LabelAttribute
|
var srcLabelAttribute bazel.LabelAttribute
|
||||||
if module.properties.Src != nil {
|
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
|
||||||
srcLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.Src))
|
for config, p := range configToProps {
|
||||||
|
props, ok := p.(*prebuiltEtcProperties)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if props.Src != nil {
|
||||||
|
srcLabelAttribute.SetSelectValue(axis, config, android.BazelLabelForModuleSrcSingle(ctx, *props.Src))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var filename string
|
var filename string
|
||||||
|
Reference in New Issue
Block a user