bp2build: block src == name for prebuilt_* modules
src == name causes circular dependency errors, instead mark these as unconverted and don't create modules for them. Test: m bp2build and verify boringssl_self_test.zygote64.rc unconverted Change-Id: I5d5fdd7e14830cd685816064cd0377998d07293c
This commit is contained in:
@@ -1636,10 +1636,6 @@ var (
|
|||||||
// depends on libart-unstripped and new module type llvm_prebuilt_build_tool
|
// depends on libart-unstripped and new module type llvm_prebuilt_build_tool
|
||||||
"check_cfi",
|
"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
|
// depends on unconverted module tradefed
|
||||||
"HelloWorldPerformanceTest",
|
"HelloWorldPerformanceTest",
|
||||||
|
|
||||||
|
@@ -346,3 +346,17 @@ prebuilt_etc {
|
|||||||
ExpectedErr: fmt.Errorf("label attribute could not be collapsed"),
|
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"
|
||||||
"android/soong/bazel/cquery"
|
"android/soong/bazel/cquery"
|
||||||
"android/soong/snapshot"
|
"android/soong/snapshot"
|
||||||
|
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pctx = android.NewPackageContext("android/soong/etc")
|
var pctx = android.NewPackageContext("android/soong/etc")
|
||||||
@@ -711,7 +712,7 @@ type bazelPrebuiltFileAttributes struct {
|
|||||||
// Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion
|
// Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion
|
||||||
// of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes
|
// of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes
|
||||||
// used by both prebuilt_etc_xml and other prebuilt_* moodules
|
// 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
|
var src bazel.LabelAttribute
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
|
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
|
||||||
for config, p := range configToProps {
|
for config, p := range configToProps {
|
||||||
@@ -720,7 +721,12 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) *ba
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if props.Src != nil {
|
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)
|
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}
|
attrs.Filename_from_src = bazel.BoolAttribute{Value: moduleProps.Filename_from_src}
|
||||||
}
|
}
|
||||||
|
|
||||||
return attrs
|
return attrs, true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
|
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
|
||||||
@@ -793,7 +798,10 @@ func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs := module.Bp2buildHelper(ctx)
|
attrs, convertible := module.Bp2buildHelper(ctx)
|
||||||
|
if !convertible {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "prebuilt_file",
|
Rule_class: "prebuilt_file",
|
||||||
|
@@ -146,7 +146,11 @@ type bazelPrebuiltEtcXmlAttributes struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
baseAttrs := p.PrebuiltEtc.Bp2buildHelper(ctx)
|
baseAttrs, convertible := p.PrebuiltEtc.Bp2buildHelper(ctx)
|
||||||
|
|
||||||
|
if !convertible {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var schema *string
|
var schema *string
|
||||||
if p.properties.Schema != nil {
|
if p.properties.Schema != nil {
|
||||||
|
Reference in New Issue
Block a user