Merge "bp2build: block src == name for prebuilt_* modules" into main
This commit is contained in:
commit
3f0aa4d618
4 changed files with 32 additions and 10 deletions
|
@ -1636,10 +1636,6 @@ var (
|
|||
// depends on libart-unstripped and new module type llvm_prebuilt_build_tool
|
||||
"check_cfi",
|
||||
|
||||
// TODO(b/297070571): cannot convert prebuilts_etc module which possess identical name and src properties
|
||||
"boringssl_self_test.zygote64.rc",
|
||||
"boringssl_self_test.zygote64_32.rc",
|
||||
|
||||
// depends on unconverted module tradefed
|
||||
"HelloWorldPerformanceTest",
|
||||
|
||||
|
|
|
@ -346,3 +346,17 @@ prebuilt_etc {
|
|||
ExpectedErr: fmt.Errorf("label attribute could not be collapsed"),
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcNoConversionIfSrcEqualsName(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "foo",
|
||||
filename: "fooFilename",
|
||||
src: "foo",
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import (
|
|||
"android/soong/bazel"
|
||||
"android/soong/bazel/cquery"
|
||||
"android/soong/snapshot"
|
||||
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||
)
|
||||
|
||||
var pctx = android.NewPackageContext("android/soong/etc")
|
||||
|
@ -711,7 +712,7 @@ type bazelPrebuiltFileAttributes struct {
|
|||
// Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion
|
||||
// of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes
|
||||
// used by both prebuilt_etc_xml and other prebuilt_* moodules
|
||||
func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) *bazelPrebuiltFileAttributes {
|
||||
func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) (*bazelPrebuiltFileAttributes, bool) {
|
||||
var src bazel.LabelAttribute
|
||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
|
||||
for config, p := range configToProps {
|
||||
|
@ -720,7 +721,12 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) *ba
|
|||
continue
|
||||
}
|
||||
if props.Src != nil {
|
||||
label := android.BazelLabelForModuleSrcSingle(ctx, *props.Src)
|
||||
srcStr := proptools.String(props.Src)
|
||||
if srcStr == ctx.ModuleName() {
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "src == name")
|
||||
return &bazelPrebuiltFileAttributes{}, false
|
||||
}
|
||||
label := android.BazelLabelForModuleSrcSingle(ctx, srcStr)
|
||||
src.SetSelectValue(axis, config, label)
|
||||
}
|
||||
}
|
||||
|
@ -779,8 +785,7 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) *ba
|
|||
attrs.Filename_from_src = bazel.BoolAttribute{Value: moduleProps.Filename_from_src}
|
||||
}
|
||||
|
||||
return attrs
|
||||
|
||||
return attrs, true
|
||||
}
|
||||
|
||||
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
|
||||
|
@ -793,7 +798,10 @@ func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext
|
|||
return
|
||||
}
|
||||
|
||||
attrs := module.Bp2buildHelper(ctx)
|
||||
attrs, convertible := module.Bp2buildHelper(ctx)
|
||||
if !convertible {
|
||||
return
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "prebuilt_file",
|
||||
|
|
|
@ -146,7 +146,11 @@ type bazelPrebuiltEtcXmlAttributes struct {
|
|||
}
|
||||
|
||||
func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
baseAttrs := p.PrebuiltEtc.Bp2buildHelper(ctx)
|
||||
baseAttrs, convertible := p.PrebuiltEtc.Bp2buildHelper(ctx)
|
||||
|
||||
if !convertible {
|
||||
return
|
||||
}
|
||||
|
||||
var schema *string
|
||||
if p.properties.Schema != nil {
|
||||
|
|
Loading…
Reference in a new issue