Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module types, along with the related code. Bug: 315353489 Test: m blueprint_tests Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
This commit is contained in:
@@ -31,16 +31,12 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
"android/soong/bazel/cquery"
|
||||
"android/soong/snapshot"
|
||||
"android/soong/ui/metrics/bp2build_metrics_proto"
|
||||
)
|
||||
|
||||
var pctx = android.NewPackageContext("android/soong/etc")
|
||||
@@ -139,7 +135,6 @@ type PrebuiltEtcModule interface {
|
||||
type PrebuiltEtc struct {
|
||||
android.ModuleBase
|
||||
android.DefaultableModuleBase
|
||||
android.BazelModuleBase
|
||||
|
||||
snapshot.VendorSnapshotModuleInterface
|
||||
snapshot.RecoverySnapshotModuleInterface
|
||||
@@ -462,7 +457,6 @@ func PrebuiltEtcFactory() android.Module {
|
||||
// This module is device-only
|
||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||
android.InitDefaultableModule(module)
|
||||
android.InitBazelModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
@@ -492,7 +486,6 @@ func PrebuiltEtcHostFactory() android.Module {
|
||||
// This module is host-only
|
||||
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
|
||||
android.InitDefaultableModule(module)
|
||||
android.InitBazelModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
@@ -503,7 +496,6 @@ func PrebuiltEtcCaCertsFactory() android.Module {
|
||||
InitPrebuiltEtcModule(module, "cacerts")
|
||||
// This module is device-only
|
||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||
android.InitBazelModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
@@ -526,7 +518,6 @@ func PrebuiltRootHostFactory() android.Module {
|
||||
// This module is host-only
|
||||
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon)
|
||||
android.InitDefaultableModule(module)
|
||||
android.InitBazelModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
@@ -538,7 +529,6 @@ func PrebuiltUserShareFactory() android.Module {
|
||||
// This module is device-only
|
||||
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
|
||||
android.InitDefaultableModule(module)
|
||||
android.InitBazelModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
@@ -730,154 +720,3 @@ func generatePrebuiltSnapshot(s snapshot.SnapshotSingleton, ctx android.Singleto
|
||||
|
||||
return snapshot.SnapshotPaths{OutputFiles: snapshotOutputs, NoticeFiles: snapshotNotices}
|
||||
}
|
||||
|
||||
// For Bazel / bp2build
|
||||
|
||||
type bazelPrebuiltFileAttributes struct {
|
||||
Src bazel.LabelAttribute
|
||||
Filename bazel.LabelAttribute
|
||||
Dir string
|
||||
Installable bazel.BoolAttribute
|
||||
Filename_from_src bazel.BoolAttribute
|
||||
}
|
||||
|
||||
// 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.Bp2buildMutatorContext) (*bazelPrebuiltFileAttributes, bool) {
|
||||
var src bazel.LabelAttribute
|
||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
|
||||
for config, p := range configToProps {
|
||||
props, ok := p.(*prebuiltEtcProperties)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if props.Src != nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
productVarProperties, errs := android.ProductVariableProperties(ctx, ctx.Module())
|
||||
for _, err := range errs {
|
||||
ctx.ModuleErrorf("ProductVariableProperties error: %s", err)
|
||||
}
|
||||
for propName, productConfigProps := range productVarProperties {
|
||||
for configProp, propVal := range productConfigProps {
|
||||
if propName == "Src" {
|
||||
props, ok := propVal.(*string)
|
||||
if !ok {
|
||||
ctx.PropertyErrorf(" Expected Property to have type string, but was %s\n", reflect.TypeOf(propVal).String())
|
||||
continue
|
||||
}
|
||||
if props != nil {
|
||||
label := android.BazelLabelForModuleSrcSingle(ctx, *props)
|
||||
src.SetSelectValue(configProp.ConfigurationAxis(), configProp.SelectKey(), label)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var filename string
|
||||
var filenameFromSrc bool
|
||||
moduleProps := module.properties
|
||||
|
||||
if moduleProps.Filename != nil && *moduleProps.Filename != "" {
|
||||
filename = *moduleProps.Filename
|
||||
} else if moduleProps.Filename_from_src != nil && *moduleProps.Filename_from_src {
|
||||
if moduleProps.Src != nil {
|
||||
filename = android.BazelLabelForModuleSrcSingle(ctx, *moduleProps.Src).Label
|
||||
}
|
||||
filenameFromSrc = true
|
||||
} else {
|
||||
filename = ctx.ModuleName()
|
||||
}
|
||||
|
||||
var dir = module.installDirBase
|
||||
if module.SubDir() != "" {
|
||||
dir = dir + "/" + module.SubDir()
|
||||
}
|
||||
|
||||
var installable bazel.BoolAttribute
|
||||
if install := module.properties.Installable; install != nil {
|
||||
installable.Value = install
|
||||
}
|
||||
|
||||
attrs := &bazelPrebuiltFileAttributes{
|
||||
Src: src,
|
||||
Dir: dir,
|
||||
Installable: installable,
|
||||
}
|
||||
|
||||
if filename != "" {
|
||||
attrs.Filename = bazel.LabelAttribute{Value: &bazel.Label{Label: filename}}
|
||||
} else if filenameFromSrc {
|
||||
attrs.Filename_from_src = bazel.BoolAttribute{Value: moduleProps.Filename_from_src}
|
||||
}
|
||||
|
||||
return attrs, true
|
||||
}
|
||||
|
||||
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
|
||||
// prebuilt_* modules (except prebuilt_etc_xml) are PrebuiltEtc,
|
||||
// which we treat as *PrebuiltFile*
|
||||
func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||
var dir = module.installDirBase
|
||||
// prebuilt_file only supports "etc" or "usr/share" or "." as module installDirBase
|
||||
if !(dir == "etc" || dir == "usr/share" || dir == ".") {
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "dir")
|
||||
return
|
||||
}
|
||||
|
||||
attrs, convertible := module.Bp2buildHelper(ctx)
|
||||
if !convertible {
|
||||
return
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "prebuilt_file",
|
||||
Bzl_load_location: "//build/bazel/rules:prebuilt_file.bzl",
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
|
||||
}
|
||||
|
||||
var _ android.MixedBuildBuildable = (*PrebuiltEtc)(nil)
|
||||
|
||||
func (pe *PrebuiltEtc) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (pe *PrebuiltEtc) QueueBazelCall(ctx android.BaseModuleContext) {
|
||||
ctx.Config().BazelContext.QueueBazelRequest(
|
||||
pe.GetBazelLabel(ctx, pe),
|
||||
cquery.GetPrebuiltFileInfo,
|
||||
android.GetConfigKey(ctx),
|
||||
)
|
||||
}
|
||||
|
||||
func (pe *PrebuiltEtc) ProcessBazelQueryResponse(ctx android.ModuleContext) {
|
||||
bazelCtx := ctx.Config().BazelContext
|
||||
pfi, err := bazelCtx.GetPrebuiltFileInfo(pe.GetBazelLabel(ctx, pe), android.GetConfigKey(ctx))
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// Set properties for androidmk
|
||||
pe.installDirPath = android.PathForModuleInstall(ctx, pfi.Dir)
|
||||
|
||||
// Installation rules
|
||||
ip := installProperties{
|
||||
installable: pfi.Installable,
|
||||
filename: pfi.Filename,
|
||||
sourceFilePath: android.PathForSource(ctx, pfi.Src),
|
||||
// symlinks: pe.properties.Symlinks, // TODO: b/207489266 - Fully support all properties in prebuilt_file
|
||||
}
|
||||
pe.addInstallRules(ctx, ip)
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel/cquery"
|
||||
"android/soong/snapshot"
|
||||
)
|
||||
|
||||
@@ -495,41 +494,3 @@ func TestPrebuiltTakeSnapshot(t *testing.T) {
|
||||
checkIfSnapshotNotTaken(t, result, "recovery", "prebuilt_recovery_indirect")
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcAndroidMkEntriesWithBazel(t *testing.T) {
|
||||
t.Parallel()
|
||||
bp := `
|
||||
prebuilt_etc {
|
||||
name: "myetc",
|
||||
src: "prebuilt_etc.rc", // filename in src tree
|
||||
filename: "init.rc", // target filename on device
|
||||
sub_dir: "subdir", // relative subdir for installation
|
||||
bazel_module: { label: "//foo/bar:myetc" },
|
||||
}
|
||||
`
|
||||
res := android.GroupFixturePreparers(
|
||||
prepareForPrebuiltEtcTest,
|
||||
android.FixtureModifyConfig(func(cfg android.Config) {
|
||||
cfg.BazelContext = android.MockBazelContext{
|
||||
LabelToPrebuiltFileInfo: map[string]cquery.PrebuiltFileInfo{
|
||||
"//foo/bar:myetc": cquery.PrebuiltFileInfo{
|
||||
Src: "foo/bar/prebuilt_etc.rc",
|
||||
Dir: "etc/subdir",
|
||||
Filename: "init.rc",
|
||||
Installable: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}),
|
||||
).RunTestWithBp(t, bp)
|
||||
ctx := res.ModuleForTests("myetc", "android_arm64_armv8-a")
|
||||
mod := ctx.Module()
|
||||
entries := android.AndroidMkEntriesForTest(t, res.TestContext, mod)[0]
|
||||
// verify androidmk entries
|
||||
android.AssertStringDoesContain(t, "LOCAL_MODULE_PATH should contain", entries.EntryMap["LOCAL_MODULE_PATH"][0], "etc/subdir")
|
||||
android.AssertStringEquals(t, "LOCAL_INSTALLED_MODULE_STEM is incorrect", "init.rc", entries.EntryMap["LOCAL_INSTALLED_MODULE_STEM"][0])
|
||||
// verify installation rules
|
||||
install := ctx.Description("install")
|
||||
android.AssertStringEquals(t, "Source location of prebuilt_etc installation", "out/soong/.intermediates/myetc/android_arm64_armv8-a/init.rc", install.Input.String())
|
||||
android.AssertStringEquals(t, "Target location of prebuilt_etc installation", "out/soong/target/product/test_device/system/etc/subdir/init.rc", install.Output.String())
|
||||
}
|
||||
|
Reference in New Issue
Block a user