Don't create a new module for bp2build conversion.

A performance improvement for bp2build as Blueprint/Soong no longer have
the overhead of additional modules. The creation of these modules
results in:
* traversal of additional modules for each subsequent mutator
* synchronization over a go channel to collect newly created modules:
https://cs.android.com/android/platform/superproject/+/master:build/blueprint/context.go;l=2594,2600;drc=1602226f23181b8c3fbfcaf3358f0297e839d7d3

We avoid both of these by storing the information directly in the
underlying module.

Also as a fringe benefit, removes some necessary boilerplate for
conversion.

For benchmarks, reduces runtime ~1% for 1% converted, ~24% for 100%
converted. See more: go/benchmarks-for-https:-r.android.com-1792714

Test: ran benchmarks/tests in bp2build
Test: build/bazel/ci/bp2build.sh
Change-Id: Ie9273b8cbab5bc6edac1728067ce184382feb211
This commit is contained in:
Liz Kammer 2021-08-11 00:17:36 -04:00
parent 0dd067d309
commit 2ada09a546
16 changed files with 148 additions and 276 deletions

View file

@ -34,24 +34,6 @@ type bazelFilegroupAttributes struct {
Srcs bazel.LabelListAttribute
}
type bazelFilegroup struct {
BazelTargetModuleBase
bazelFilegroupAttributes
}
func BazelFileGroupFactory() Module {
module := &bazelFilegroup{}
module.AddProperties(&module.bazelFilegroupAttributes)
InitBazelTargetModule(module)
return module
}
func (bfg *bazelFilegroup) Name() string {
return bfg.BaseModuleName()
}
func (bfg *bazelFilegroup) GenerateAndroidBuildActions(ctx ModuleContext) {}
func FilegroupBp2Build(ctx TopDownMutatorContext) {
fg, ok := ctx.Module().(*fileGroup)
if !ok || !fg.ConvertWithBp2build(ctx) {
@ -69,7 +51,7 @@ func FilegroupBp2Build(ctx TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:filegroup.bzl",
}
ctx.CreateBazelTargetModule(BazelFileGroupFactory, fg.Name(), props, attrs)
ctx.CreateBazelTargetModule(fg.Name(), props, attrs)
}
type fileGroupProperties struct {

View file

@ -491,6 +491,11 @@ type Module interface {
AddProperties(props ...interface{})
GetProperties() []interface{}
// IsConvertedByBp2build returns whether this module was converted via bp2build
IsConvertedByBp2build() bool
// Bp2buildTargets returns the target(s) generated for Bazel via bp2build for this module
Bp2buildTargets() []bp2buildInfo
BuildParamsForTests() []BuildParams
RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
VariablesForTests() map[string]string
@ -878,6 +883,11 @@ type commonProperties struct {
// for example "" for core or "recovery" for recovery. It will often be set to one of the
// constants in image.go, but can also be set to a custom value by individual module types.
ImageVariation string `blueprint:"mutated"`
// Information about _all_ bp2build targets generated by this module. Multiple targets are
// supported as Soong handles some things within a single target that we may choose to split into
// multiple targets, e.g. renderscript, protos, yacc within a cc module.
Bp2buildInfo []bp2buildInfo `blueprint:"mutated"`
}
type distProperties struct {
@ -1204,6 +1214,54 @@ type ModuleBase struct {
vintfFragmentsPaths Paths
}
// A struct containing all relevant information about a Bazel target converted via bp2build.
type bp2buildInfo struct {
Name string
Dir string
BazelProps bazel.BazelTargetModuleProperties
Attrs interface{}
}
// TargetName returns the Bazel target name of a bp2build converted target.
func (b bp2buildInfo) TargetName() string {
return b.Name
}
// TargetPackage returns the Bazel package of a bp2build converted target.
func (b bp2buildInfo) TargetPackage() string {
return b.Dir
}
// BazelRuleClass returns the Bazel rule class of a bp2build converted target.
func (b bp2buildInfo) BazelRuleClass() string {
return b.BazelProps.Rule_class
}
// BazelRuleLoadLocation returns the location of the Bazel rule of a bp2build converted target.
// This may be empty as native Bazel rules do not need to be loaded.
func (b bp2buildInfo) BazelRuleLoadLocation() string {
return b.BazelProps.Bzl_load_location
}
// BazelAttributes returns the Bazel attributes of a bp2build converted target.
func (b bp2buildInfo) BazelAttributes() interface{} {
return b.Attrs
}
func (m *ModuleBase) addBp2buildInfo(info bp2buildInfo) {
m.commonProperties.Bp2buildInfo = append(m.commonProperties.Bp2buildInfo, info)
}
// IsConvertedByBp2build returns whether this module was converted via bp2build.
func (m *ModuleBase) IsConvertedByBp2build() bool {
return len(m.commonProperties.Bp2buildInfo) > 0
}
// Bp2buildTargets returns the Bazel targets bp2build generated for this module.
func (m *ModuleBase) Bp2buildTargets() []bp2buildInfo {
return m.commonProperties.Bp2buildInfo
}
func (m *ModuleBase) AddJSONData(d *map[string]interface{}) {
(*d)["Android"] = map[string]interface{}{}
}

View file

@ -270,7 +270,7 @@ type TopDownMutatorContext interface {
// factory method, just like in CreateModule, but also requires
// BazelTargetModuleProperties containing additional metadata for the
// bp2build codegenerator.
CreateBazelTargetModule(ModuleFactory, string, bazel.BazelTargetModuleProperties, interface{}) BazelTargetModule
CreateBazelTargetModule(string, bazel.BazelTargetModuleProperties, interface{})
}
type topDownMutatorContext struct {
@ -516,26 +516,24 @@ func registerDepsMutatorBp2Build(ctx RegisterMutatorsContext) {
}
func (t *topDownMutatorContext) CreateBazelTargetModule(
factory ModuleFactory,
name string,
bazelProps bazel.BazelTargetModuleProperties,
attrs interface{}) BazelTargetModule {
attrs interface{}) {
if strings.HasPrefix(name, bazel.BazelTargetModuleNamePrefix) {
panic(fmt.Errorf(
"The %s name prefix is added automatically, do not set it manually: %s",
bazel.BazelTargetModuleNamePrefix,
name))
}
name = bazel.BazelTargetModuleNamePrefix + name
nameProp := struct {
Name *string
}{
Name: &name,
info := bp2buildInfo{
Name: name,
Dir: t.OtherModuleDir(t.Module()),
BazelProps: bazelProps,
Attrs: attrs,
}
b := t.createModuleWithoutInheritance(factory, &nameProp, attrs).(BazelTargetModule)
b.SetBazelTargetModuleProperties(bazelProps)
return b
t.Module().base().addBp2buildInfo(info)
}
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {

View file

@ -3238,18 +3238,6 @@ type bazelApexBundleAttributes struct {
Prebuilts bazel.LabelListAttribute
}
type bazelApexBundle struct {
android.BazelTargetModuleBase
bazelApexBundleAttributes
}
func BazelApexBundleFactory() android.Module {
module := &bazelApexBundle{}
module.AddProperties(&module.bazelApexBundleAttributes)
android.InitBazelTargetModule(module)
return module
}
func ApexBundleBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*apexBundle)
if !ok {
@ -3337,11 +3325,5 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB
Bzl_load_location: "//build/bazel/rules:apex.bzl",
}
ctx.CreateBazelTargetModule(BazelApexBundleFactory, module.Name(), props, attrs)
ctx.CreateBazelTargetModule(module.Name(), props, attrs)
}
func (m *bazelApexBundle) Name() string {
return m.BaseModuleName()
}
func (m *bazelApexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {}

View file

@ -203,18 +203,6 @@ type bazelApexKeyAttributes struct {
Private_key bazel.LabelAttribute
}
type bazelApexKey struct {
android.BazelTargetModuleBase
bazelApexKeyAttributes
}
func BazelApexKeyFactory() android.Module {
module := &bazelApexKey{}
module.AddProperties(&module.bazelApexKeyAttributes)
android.InitBazelTargetModule(module)
return module
}
func ApexKeyBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*apexKey)
if !ok {
@ -252,11 +240,5 @@ func apexKeyBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexKey)
Bzl_load_location: "//build/bazel/rules:apex_key.bzl",
}
ctx.CreateBazelTargetModule(BazelApexKeyFactory, module.Name(), props, attrs)
ctx.CreateBazelTargetModule(module.Name(), props, attrs)
}
func (m *bazelApexKey) Name() string {
return m.BaseModuleName()
}
func (m *bazelApexKey) GenerateAndroidBuildActions(ctx android.ModuleContext) {}

View file

@ -244,7 +244,7 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (map[str
dir := bpCtx.ModuleDir(m)
dirs[dir] = true
var t BazelTarget
var targets []BazelTarget
switch ctx.Mode() {
case Bp2Build:
@ -258,18 +258,23 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (map[str
if _, exists := buildFileToAppend[pathToBuildFile]; exists {
return
}
var err error
t, err = getHandcraftedBuildContent(ctx, b, pathToBuildFile)
t, err := getHandcraftedBuildContent(ctx, b, pathToBuildFile)
if err != nil {
panic(fmt.Errorf("Error converting %s: %s", bpCtx.ModuleName(m), err))
}
targets = append(targets, t)
// TODO(b/181575318): currently we append the whole BUILD file, let's change that to do
// something more targeted based on the rule type and target
buildFileToAppend[pathToBuildFile] = true
} else if btm, ok := m.(android.BazelTargetModule); ok {
t = generateBazelTarget(bpCtx, m, btm)
metrics.RuleClassCount[t.ruleClass] += 1
compatLayer.AddNameToLabelEntry(m.Name(), t.Label())
} else if aModule, ok := m.(android.Module); ok && aModule.IsConvertedByBp2build() {
targets = generateBazelTargets(bpCtx, aModule)
for _, t := range targets {
if t.name == m.Name() {
// only add targets that exist in Soong to compatibility layer
compatLayer.AddNameToLabelEntry(m.Name(), t.Label())
}
metrics.RuleClassCount[t.ruleClass] += 1
}
} else {
metrics.TotalModuleCount += 1
return
@ -281,12 +286,13 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (map[str
// be mapped cleanly to a bazel label.
return
}
t = generateSoongModuleTarget(bpCtx, m)
t := generateSoongModuleTarget(bpCtx, m)
targets = append(targets, t)
default:
panic(fmt.Errorf("Unknown code-generation mode: %s", ctx.Mode()))
}
buildFileToTargets[dir] = append(buildFileToTargets[dir], t)
buildFileToTargets[dir] = append(buildFileToTargets[dir], targets...)
})
if generateFilegroups {
// Add a filegroup target that exposes all sources in the subtree of this package
@ -326,22 +332,38 @@ func getHandcraftedBuildContent(ctx *CodegenContext, b android.Bazelable, pathTo
}, nil
}
func generateBazelTarget(ctx bpToBuildContext, m blueprint.Module, btm android.BazelTargetModule) BazelTarget {
ruleClass := btm.RuleClass()
bzlLoadLocation := btm.BzlLoadLocation()
func generateBazelTargets(ctx bpToBuildContext, m android.Module) []BazelTarget {
var targets []BazelTarget
for _, m := range m.Bp2buildTargets() {
targets = append(targets, generateBazelTarget(ctx, m))
}
return targets
}
type bp2buildModule interface {
TargetName() string
TargetPackage() string
BazelRuleClass() string
BazelRuleLoadLocation() string
BazelAttributes() interface{}
}
func generateBazelTarget(ctx bpToBuildContext, m bp2buildModule) BazelTarget {
ruleClass := m.BazelRuleClass()
bzlLoadLocation := m.BazelRuleLoadLocation()
// extract the bazel attributes from the module.
props := getBuildProperties(ctx, m)
props := extractModuleProperties([]interface{}{m.BazelAttributes()})
delete(props.Attrs, "bp2build_available")
// Return the Bazel target with rule class and attributes, ready to be
// code-generated.
attributes := propsToAttributes(props.Attrs)
targetName := targetNameForBp2Build(ctx, m)
targetName := m.TargetName()
return BazelTarget{
name: targetName,
packageName: ctx.ModuleDir(m),
packageName: m.TargetPackage(),
ruleClass: ruleClass,
bzlLoadLocation: bzlLoadLocation,
content: fmt.Sprintf(
@ -391,24 +413,21 @@ func generateSoongModuleTarget(ctx bpToBuildContext, m blueprint.Module) BazelTa
}
func getBuildProperties(ctx bpToBuildContext, m blueprint.Module) BazelAttributes {
var allProps map[string]string
// TODO: this omits properties for blueprint modules (blueprint_go_binary,
// bootstrap_go_binary, bootstrap_go_package), which will have to be handled separately.
if aModule, ok := m.(android.Module); ok {
allProps = ExtractModuleProperties(aModule)
return extractModuleProperties(aModule.GetProperties())
}
return BazelAttributes{
Attrs: allProps,
}
return BazelAttributes{}
}
// Generically extract module properties and types into a map, keyed by the module property name.
func ExtractModuleProperties(aModule android.Module) map[string]string {
func extractModuleProperties(props []interface{}) BazelAttributes {
ret := map[string]string{}
// Iterate over this android.Module's property structs.
for _, properties := range aModule.GetProperties() {
for _, properties := range props {
propertiesValue := reflect.ValueOf(properties)
// Check that propertiesValue is a pointer to the Properties struct, like
// *cc.BaseLinkerProperties or *java.CompilerProperties.
@ -427,7 +446,9 @@ func ExtractModuleProperties(aModule android.Module) map[string]string {
}
}
return ret
return BazelAttributes{
Attrs: ret,
}
}
func isStructPtr(t reflect.Type) bool {

View file

@ -480,12 +480,12 @@ func TestGenerateBazelTargetModules_OneToMany_LoadedFromStarlark(t *testing.T) {
name = "bar",
)
my_proto_library(
name = "bar_my_proto_library_deps",
)
proto_library(
name = "bar_proto_library_deps",
)
my_proto_library(
name = "bar_my_proto_library_deps",
)`,
expectedBazelTargetCount: 3,
expectedLoadStatements: `load("//build/bazel/rules:proto.bzl", "my_proto_library", "proto_library")
@ -1213,22 +1213,24 @@ func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
dir := "."
for _, testCase := range testCases {
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
ctx := android.NewTestContext(config)
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
ctx.RegisterBp2BuildMutator(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestBp2BuildMutator)
ctx.RegisterForBazelConversion()
t.Run(testCase.description, func(t *testing.T) {
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
ctx := android.NewTestContext(config)
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
ctx.RegisterBp2BuildMutator(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestBp2BuildMutator)
ctx.RegisterForBazelConversion()
_, errs := ctx.ParseFileList(dir, []string{"Android.bp"})
android.FailIfErrored(t, errs)
_, errs = ctx.ResolveDependencies(config)
android.FailIfErrored(t, errs)
_, errs := ctx.ParseFileList(dir, []string{"Android.bp"})
android.FailIfErrored(t, errs)
_, errs = ctx.ResolveDependencies(config)
android.FailIfErrored(t, errs)
codegenCtx := NewCodegenContext(config, *ctx.Context, Bp2Build)
bazelTargets := generateBazelTargetsForDir(codegenCtx, dir)
if actualCount := len(bazelTargets); actualCount != testCase.expectedCount {
t.Fatalf("%s: Expected %d bazel target, got %d", testCase.description, testCase.expectedCount, actualCount)
}
codegenCtx := NewCodegenContext(config, *ctx.Context, Bp2Build)
bazelTargets := generateBazelTargetsForDir(codegenCtx, dir)
if actualCount := len(bazelTargets); actualCount != testCase.expectedCount {
t.Fatalf("%s: Expected %d bazel target, got %d", testCase.description, testCase.expectedCount, actualCount)
}
})
}
}

View file

@ -140,16 +140,6 @@ type customBazelModule struct {
customBazelModuleAttributes
}
func customBazelModuleFactory() android.Module {
module := &customBazelModule{}
module.AddProperties(&module.customBazelModuleAttributes)
android.InitBazelTargetModule(module)
return module
}
func (m *customBazelModule) Name() string { return m.BaseModuleName() }
func (m *customBazelModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
if m, ok := ctx.Module().(*customModule); ok {
if !m.ConvertWithBp2build(ctx) {
@ -178,7 +168,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
Rule_class: "custom",
}
ctx.CreateBazelTargetModule(customBazelModuleFactory, m.Name(), props, attrs)
ctx.CreateBazelTargetModule(m.Name(), props, attrs)
}
}
@ -197,19 +187,19 @@ func customBp2BuildMutatorFromStarlark(ctx android.TopDownMutatorContext) {
Rule_class: "my_library",
Bzl_load_location: "//build/bazel/rules:rules.bzl",
}
ctx.CreateBazelTargetModule(customBazelModuleFactory, baseName, myLibraryProps, attrs)
ctx.CreateBazelTargetModule(baseName, myLibraryProps, attrs)
protoLibraryProps := bazel.BazelTargetModuleProperties{
Rule_class: "proto_library",
Bzl_load_location: "//build/bazel/rules:proto.bzl",
}
ctx.CreateBazelTargetModule(customBazelModuleFactory, baseName+"_proto_library_deps", protoLibraryProps, attrs)
ctx.CreateBazelTargetModule(baseName+"_proto_library_deps", protoLibraryProps, attrs)
myProtoLibraryProps := bazel.BazelTargetModuleProperties{
Rule_class: "my_proto_library",
Bzl_load_location: "//build/bazel/rules:proto.bzl",
}
ctx.CreateBazelTargetModule(customBazelModuleFactory, baseName+"_my_proto_library_deps", myProtoLibraryProps, attrs)
ctx.CreateBazelTargetModule(baseName+"_my_proto_library_deps", myProtoLibraryProps, attrs)
}
}

View file

@ -27,6 +27,7 @@ import (
"android/soong/bazel"
"android/soong/bazel/cquery"
"android/soong/cc/config"
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
)
@ -256,24 +257,6 @@ type stripAttributes struct {
None bazel.BoolAttribute
}
type bazelCcLibrary struct {
android.BazelTargetModuleBase
bazelCcLibraryAttributes
}
func (m *bazelCcLibrary) Name() string {
return m.BaseModuleName()
}
func (m *bazelCcLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
func BazelCcLibraryFactory() android.Module {
module := &bazelCcLibrary{}
module.AddProperties(&module.bazelCcLibraryAttributes)
android.InitBazelTargetModule(module)
return module
}
func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) {
@ -346,7 +329,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:full_cc_library.bzl",
}
ctx.CreateBazelTargetModule(BazelCcLibraryFactory, m.Name(), props, attrs)
ctx.CreateBazelTargetModule(m.Name(), props, attrs)
}
// cc_library creates both static and/or shared libraries for a device and/or
@ -2414,7 +2397,7 @@ func ccLibraryStaticBp2BuildInternal(ctx android.TopDownMutatorContext, module *
Bzl_load_location: "//build/bazel/rules:cc_library_static.bzl",
}
ctx.CreateBazelTargetModule(BazelCcLibraryStaticFactory, module.Name(), props, attrs)
ctx.CreateBazelTargetModule(module.Name(), props, attrs)
}
func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {

View file

@ -111,18 +111,6 @@ type bazelCcLibraryHeadersAttributes struct {
System_dynamic_deps bazel.LabelListAttribute
}
type bazelCcLibraryHeaders struct {
android.BazelTargetModuleBase
bazelCcLibraryHeadersAttributes
}
func BazelCcLibraryHeadersFactory() android.Module {
module := &bazelCcLibraryHeaders{}
module.AddProperties(&module.bazelCcLibraryHeadersAttributes)
android.InitBazelTargetModule(module)
return module
}
func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*Module)
if !ok {
@ -155,11 +143,5 @@ func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:cc_library_headers.bzl",
}
ctx.CreateBazelTargetModule(BazelCcLibraryHeadersFactory, module.Name(), props, attrs)
ctx.CreateBazelTargetModule(module.Name(), props, attrs)
}
func (m *bazelCcLibraryHeaders) Name() string {
return m.BaseModuleName()
}
func (m *bazelCcLibraryHeaders) GenerateAndroidBuildActions(ctx android.ModuleContext) {}

View file

@ -130,24 +130,6 @@ type bazelObjectAttributes struct {
Asflags bazel.StringListAttribute
}
type bazelObject struct {
android.BazelTargetModuleBase
bazelObjectAttributes
}
func (m *bazelObject) Name() string {
return m.BaseModuleName()
}
func (m *bazelObject) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
func BazelObjectFactory() android.Module {
module := &bazelObject{}
module.AddProperties(&module.bazelObjectAttributes)
android.InitBazelTargetModule(module)
return module
}
// ObjectBp2Build is the bp2build converter from cc_object modules to the
// Bazel equivalent target, plus any necessary include deps for the cc_object.
func ObjectBp2Build(ctx android.TopDownMutatorContext) {
@ -200,7 +182,7 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:cc_object.bzl",
}
ctx.CreateBazelTargetModule(BazelObjectFactory, m.Name(), props, attrs)
ctx.CreateBazelTargetModule(m.Name(), props, attrs)
}
func (object *objectLinker) appendLdflags(flags []string) {

View file

@ -662,18 +662,6 @@ type bazelPrebuiltEtcAttributes struct {
Installable bazel.BoolAttribute
}
type bazelPrebuiltEtc struct {
android.BazelTargetModuleBase
bazelPrebuiltEtcAttributes
}
func BazelPrebuiltEtcFactory() android.Module {
module := &bazelPrebuiltEtc{}
module.AddProperties(&module.bazelPrebuiltEtcAttributes)
android.InitBazelTargetModule(module)
return module
}
func PrebuiltEtcBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*PrebuiltEtc)
if !ok {
@ -723,11 +711,5 @@ func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *Preb
Bzl_load_location: "//build/bazel/rules:prebuilt_etc.bzl",
}
ctx.CreateBazelTargetModule(BazelPrebuiltEtcFactory, module.Name(), props, attrs)
ctx.CreateBazelTargetModule(module.Name(), props, attrs)
}
func (m *bazelPrebuiltEtc) Name() string {
return m.BaseModuleName()
}
func (m *bazelPrebuiltEtc) GenerateAndroidBuildActions(ctx android.ModuleContext) {}

View file

@ -826,18 +826,6 @@ type bazelGenruleAttributes struct {
Cmd string
}
type bazelGenrule struct {
android.BazelTargetModuleBase
bazelGenruleAttributes
}
func BazelGenruleFactory() android.Module {
module := &bazelGenrule{}
module.AddProperties(&module.bazelGenruleAttributes)
android.InitBazelTargetModule(module)
return module
}
func GenruleBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) {
@ -904,15 +892,9 @@ func GenruleBp2Build(ctx android.TopDownMutatorContext) {
}
// Create the BazelTargetModule.
ctx.CreateBazelTargetModule(BazelGenruleFactory, m.Name(), props, attrs)
ctx.CreateBazelTargetModule(m.Name(), props, attrs)
}
func (m *bazelGenrule) Name() string {
return m.BaseModuleName()
}
func (m *bazelGenrule) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
var Bool = proptools.Bool
var String = proptools.String

View file

@ -1385,18 +1385,6 @@ type bazelAndroidAppCertificateAttributes struct {
Certificate string
}
type bazelAndroidAppCertificate struct {
android.BazelTargetModuleBase
bazelAndroidAppCertificateAttributes
}
func BazelAndroidAppCertificateFactory() android.Module {
module := &bazelAndroidAppCertificate{}
module.AddProperties(&module.bazelAndroidAppCertificateAttributes)
android.InitBazelTargetModule(module)
return module
}
func AndroidAppCertificateBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*AndroidAppCertificate)
if !ok {
@ -1428,11 +1416,5 @@ func androidAppCertificateBp2BuildInternal(ctx android.TopDownMutatorContext, mo
Bzl_load_location: "//build/bazel/rules:android_app_certificate.bzl",
}
ctx.CreateBazelTargetModule(BazelAndroidAppCertificateFactory, module.Name(), props, attrs)
ctx.CreateBazelTargetModule(module.Name(), props, attrs)
}
func (m *bazelAndroidAppCertificate) Name() string {
return m.BaseModuleName()
}
func (m *bazelAndroidAppCertificate) GenerateAndroidBuildActions(ctx android.ModuleContext) {}

View file

@ -41,24 +41,6 @@ type bazelPythonBinaryAttributes struct {
Python_version string
}
type bazelPythonBinary struct {
android.BazelTargetModuleBase
bazelPythonBinaryAttributes
}
func BazelPythonBinaryFactory() android.Module {
module := &bazelPythonBinary{}
module.AddProperties(&module.bazelPythonBinaryAttributes)
android.InitBazelTargetModule(module)
return module
}
func (m *bazelPythonBinary) Name() string {
return m.BaseModuleName()
}
func (m *bazelPythonBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) {
@ -112,7 +94,7 @@ func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
Rule_class: "py_binary",
}
ctx.CreateBazelTargetModule(BazelPythonBinaryFactory, m.Name(), props, attrs)
ctx.CreateBazelTargetModule(m.Name(), props, attrs)
}
type BinaryProperties struct {

View file

@ -527,18 +527,6 @@ type bazelShBinaryAttributes struct {
// visibility
}
type bazelShBinary struct {
android.BazelTargetModuleBase
bazelShBinaryAttributes
}
func BazelShBinaryFactory() android.Module {
module := &bazelShBinary{}
module.AddProperties(&module.bazelShBinaryAttributes)
android.InitBazelTargetModule(module)
return module
}
func ShBinaryBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*ShBinary)
if !ok || !m.ConvertWithBp2build(ctx) {
@ -556,13 +544,7 @@ func ShBinaryBp2Build(ctx android.TopDownMutatorContext) {
Rule_class: "sh_binary",
}
ctx.CreateBazelTargetModule(BazelShBinaryFactory, m.Name(), props, attrs)
ctx.CreateBazelTargetModule(m.Name(), props, attrs)
}
func (m *bazelShBinary) Name() string {
return m.BaseModuleName()
}
func (m *bazelShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
var Bool = proptools.Bool