Merge "Don't create a new module for bp2build conversion."

This commit is contained in:
Liz Kammer 2021-08-18 19:28:20 +00:00 committed by Gerrit Code Review
commit 380dbb9327
16 changed files with 148 additions and 276 deletions

View file

@ -34,24 +34,6 @@ type bazelFilegroupAttributes struct {
Srcs bazel.LabelListAttribute 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) { func FilegroupBp2Build(ctx TopDownMutatorContext) {
fg, ok := ctx.Module().(*fileGroup) fg, ok := ctx.Module().(*fileGroup)
if !ok || !fg.ConvertWithBp2build(ctx) { if !ok || !fg.ConvertWithBp2build(ctx) {
@ -69,7 +51,7 @@ func FilegroupBp2Build(ctx TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:filegroup.bzl", Bzl_load_location: "//build/bazel/rules:filegroup.bzl",
} }
ctx.CreateBazelTargetModule(BazelFileGroupFactory, fg.Name(), props, attrs) ctx.CreateBazelTargetModule(fg.Name(), props, attrs)
} }
type fileGroupProperties struct { type fileGroupProperties struct {

View file

@ -491,6 +491,11 @@ type Module interface {
AddProperties(props ...interface{}) AddProperties(props ...interface{})
GetProperties() []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 BuildParamsForTests() []BuildParams
RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
VariablesForTests() map[string]string 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 // 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. // constants in image.go, but can also be set to a custom value by individual module types.
ImageVariation string `blueprint:"mutated"` 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 { type distProperties struct {
@ -1204,6 +1214,54 @@ type ModuleBase struct {
vintfFragmentsPaths Paths 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{}) { func (m *ModuleBase) AddJSONData(d *map[string]interface{}) {
(*d)["Android"] = 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 // factory method, just like in CreateModule, but also requires
// BazelTargetModuleProperties containing additional metadata for the // BazelTargetModuleProperties containing additional metadata for the
// bp2build codegenerator. // bp2build codegenerator.
CreateBazelTargetModule(ModuleFactory, string, bazel.BazelTargetModuleProperties, interface{}) BazelTargetModule CreateBazelTargetModule(string, bazel.BazelTargetModuleProperties, interface{})
} }
type topDownMutatorContext struct { type topDownMutatorContext struct {
@ -516,26 +516,24 @@ func registerDepsMutatorBp2Build(ctx RegisterMutatorsContext) {
} }
func (t *topDownMutatorContext) CreateBazelTargetModule( func (t *topDownMutatorContext) CreateBazelTargetModule(
factory ModuleFactory,
name string, name string,
bazelProps bazel.BazelTargetModuleProperties, bazelProps bazel.BazelTargetModuleProperties,
attrs interface{}) BazelTargetModule { attrs interface{}) {
if strings.HasPrefix(name, bazel.BazelTargetModuleNamePrefix) { if strings.HasPrefix(name, bazel.BazelTargetModuleNamePrefix) {
panic(fmt.Errorf( panic(fmt.Errorf(
"The %s name prefix is added automatically, do not set it manually: %s", "The %s name prefix is added automatically, do not set it manually: %s",
bazel.BazelTargetModuleNamePrefix, bazel.BazelTargetModuleNamePrefix,
name)) name))
} }
name = bazel.BazelTargetModuleNamePrefix + name
nameProp := struct { info := bp2buildInfo{
Name *string Name: name,
}{ Dir: t.OtherModuleDir(t.Module()),
Name: &name, BazelProps: bazelProps,
Attrs: attrs,
} }
b := t.createModuleWithoutInheritance(factory, &nameProp, attrs).(BazelTargetModule) t.Module().base().addBp2buildInfo(info)
b.SetBazelTargetModuleProperties(bazelProps)
return b
} }
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) { func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {

View file

@ -3231,18 +3231,6 @@ type bazelApexBundleAttributes struct {
Prebuilts bazel.LabelListAttribute 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) { func ApexBundleBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*apexBundle) module, ok := ctx.Module().(*apexBundle)
if !ok { if !ok {
@ -3330,11 +3318,5 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB
Bzl_load_location: "//build/bazel/rules:apex.bzl", 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 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) { func ApexKeyBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*apexKey) module, ok := ctx.Module().(*apexKey)
if !ok { if !ok {
@ -252,11 +240,5 @@ func apexKeyBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexKey)
Bzl_load_location: "//build/bazel/rules:apex_key.bzl", 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) dir := bpCtx.ModuleDir(m)
dirs[dir] = true dirs[dir] = true
var t BazelTarget var targets []BazelTarget
switch ctx.Mode() { switch ctx.Mode() {
case Bp2Build: case Bp2Build:
@ -258,18 +258,23 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (map[str
if _, exists := buildFileToAppend[pathToBuildFile]; exists { if _, exists := buildFileToAppend[pathToBuildFile]; exists {
return return
} }
var err error t, err := getHandcraftedBuildContent(ctx, b, pathToBuildFile)
t, err = getHandcraftedBuildContent(ctx, b, pathToBuildFile)
if err != nil { if err != nil {
panic(fmt.Errorf("Error converting %s: %s", bpCtx.ModuleName(m), err)) 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 // 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 // something more targeted based on the rule type and target
buildFileToAppend[pathToBuildFile] = true buildFileToAppend[pathToBuildFile] = true
} else if btm, ok := m.(android.BazelTargetModule); ok { } else if aModule, ok := m.(android.Module); ok && aModule.IsConvertedByBp2build() {
t = generateBazelTarget(bpCtx, m, btm) targets = generateBazelTargets(bpCtx, aModule)
metrics.RuleClassCount[t.ruleClass] += 1 for _, t := range targets {
compatLayer.AddNameToLabelEntry(m.Name(), t.Label()) 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 { } else {
metrics.TotalModuleCount += 1 metrics.TotalModuleCount += 1
return return
@ -281,12 +286,13 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (map[str
// be mapped cleanly to a bazel label. // be mapped cleanly to a bazel label.
return return
} }
t = generateSoongModuleTarget(bpCtx, m) t := generateSoongModuleTarget(bpCtx, m)
targets = append(targets, t)
default: default:
panic(fmt.Errorf("Unknown code-generation mode: %s", ctx.Mode())) panic(fmt.Errorf("Unknown code-generation mode: %s", ctx.Mode()))
} }
buildFileToTargets[dir] = append(buildFileToTargets[dir], t) buildFileToTargets[dir] = append(buildFileToTargets[dir], targets...)
}) })
if generateFilegroups { if generateFilegroups {
// Add a filegroup target that exposes all sources in the subtree of this package // 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 }, nil
} }
func generateBazelTarget(ctx bpToBuildContext, m blueprint.Module, btm android.BazelTargetModule) BazelTarget { func generateBazelTargets(ctx bpToBuildContext, m android.Module) []BazelTarget {
ruleClass := btm.RuleClass() var targets []BazelTarget
bzlLoadLocation := btm.BzlLoadLocation() 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. // extract the bazel attributes from the module.
props := getBuildProperties(ctx, m) props := extractModuleProperties([]interface{}{m.BazelAttributes()})
delete(props.Attrs, "bp2build_available") delete(props.Attrs, "bp2build_available")
// Return the Bazel target with rule class and attributes, ready to be // Return the Bazel target with rule class and attributes, ready to be
// code-generated. // code-generated.
attributes := propsToAttributes(props.Attrs) attributes := propsToAttributes(props.Attrs)
targetName := targetNameForBp2Build(ctx, m) targetName := m.TargetName()
return BazelTarget{ return BazelTarget{
name: targetName, name: targetName,
packageName: ctx.ModuleDir(m), packageName: m.TargetPackage(),
ruleClass: ruleClass, ruleClass: ruleClass,
bzlLoadLocation: bzlLoadLocation, bzlLoadLocation: bzlLoadLocation,
content: fmt.Sprintf( content: fmt.Sprintf(
@ -391,24 +413,21 @@ func generateSoongModuleTarget(ctx bpToBuildContext, m blueprint.Module) BazelTa
} }
func getBuildProperties(ctx bpToBuildContext, m blueprint.Module) BazelAttributes { func getBuildProperties(ctx bpToBuildContext, m blueprint.Module) BazelAttributes {
var allProps map[string]string
// TODO: this omits properties for blueprint modules (blueprint_go_binary, // TODO: this omits properties for blueprint modules (blueprint_go_binary,
// bootstrap_go_binary, bootstrap_go_package), which will have to be handled separately. // bootstrap_go_binary, bootstrap_go_package), which will have to be handled separately.
if aModule, ok := m.(android.Module); ok { if aModule, ok := m.(android.Module); ok {
allProps = ExtractModuleProperties(aModule) return extractModuleProperties(aModule.GetProperties())
} }
return BazelAttributes{ return BazelAttributes{}
Attrs: allProps,
}
} }
// Generically extract module properties and types into a map, keyed by the module property name. // 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{} ret := map[string]string{}
// Iterate over this android.Module's property structs. // Iterate over this android.Module's property structs.
for _, properties := range aModule.GetProperties() { for _, properties := range props {
propertiesValue := reflect.ValueOf(properties) propertiesValue := reflect.ValueOf(properties)
// Check that propertiesValue is a pointer to the Properties struct, like // Check that propertiesValue is a pointer to the Properties struct, like
// *cc.BaseLinkerProperties or *java.CompilerProperties. // *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 { func isStructPtr(t reflect.Type) bool {

View file

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

View file

@ -140,16 +140,6 @@ type customBazelModule struct {
customBazelModuleAttributes 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) { func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
if m, ok := ctx.Module().(*customModule); ok { if m, ok := ctx.Module().(*customModule); ok {
if !m.ConvertWithBp2build(ctx) { if !m.ConvertWithBp2build(ctx) {
@ -178,7 +168,7 @@ func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
Rule_class: "custom", 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", Rule_class: "my_library",
Bzl_load_location: "//build/bazel/rules:rules.bzl", Bzl_load_location: "//build/bazel/rules:rules.bzl",
} }
ctx.CreateBazelTargetModule(customBazelModuleFactory, baseName, myLibraryProps, attrs) ctx.CreateBazelTargetModule(baseName, myLibraryProps, attrs)
protoLibraryProps := bazel.BazelTargetModuleProperties{ protoLibraryProps := bazel.BazelTargetModuleProperties{
Rule_class: "proto_library", Rule_class: "proto_library",
Bzl_load_location: "//build/bazel/rules:proto.bzl", 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{ myProtoLibraryProps := bazel.BazelTargetModuleProperties{
Rule_class: "my_proto_library", Rule_class: "my_proto_library",
Bzl_load_location: "//build/bazel/rules:proto.bzl", 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"
"android/soong/bazel/cquery" "android/soong/bazel/cquery"
"android/soong/cc/config" "android/soong/cc/config"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/pathtools" "github.com/google/blueprint/pathtools"
) )
@ -256,24 +257,6 @@ type stripAttributes struct {
None bazel.BoolAttribute 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) { func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*Module) m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) { if !ok || !m.ConvertWithBp2build(ctx) {
@ -346,7 +329,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:full_cc_library.bzl", 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 // 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", 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) { func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {

View file

@ -111,18 +111,6 @@ type bazelCcLibraryHeadersAttributes struct {
System_dynamic_deps bazel.LabelListAttribute 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) { func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*Module) module, ok := ctx.Module().(*Module)
if !ok { if !ok {
@ -155,11 +143,5 @@ func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:cc_library_headers.bzl", 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 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 // ObjectBp2Build is the bp2build converter from cc_object modules to the
// Bazel equivalent target, plus any necessary include deps for the cc_object. // Bazel equivalent target, plus any necessary include deps for the cc_object.
func ObjectBp2Build(ctx android.TopDownMutatorContext) { func ObjectBp2Build(ctx android.TopDownMutatorContext) {
@ -200,7 +182,7 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
Bzl_load_location: "//build/bazel/rules:cc_object.bzl", 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) { func (object *objectLinker) appendLdflags(flags []string) {

View file

@ -662,18 +662,6 @@ type bazelPrebuiltEtcAttributes struct {
Installable bazel.BoolAttribute 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) { func PrebuiltEtcBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*PrebuiltEtc) module, ok := ctx.Module().(*PrebuiltEtc)
if !ok { if !ok {
@ -723,11 +711,5 @@ func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *Preb
Bzl_load_location: "//build/bazel/rules:prebuilt_etc.bzl", 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 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) { func GenruleBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*Module) m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) { if !ok || !m.ConvertWithBp2build(ctx) {
@ -904,15 +892,9 @@ func GenruleBp2Build(ctx android.TopDownMutatorContext) {
} }
// Create the BazelTargetModule. // 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 Bool = proptools.Bool
var String = proptools.String var String = proptools.String

View file

@ -1385,18 +1385,6 @@ type bazelAndroidAppCertificateAttributes struct {
Certificate string 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) { func AndroidAppCertificateBp2Build(ctx android.TopDownMutatorContext) {
module, ok := ctx.Module().(*AndroidAppCertificate) module, ok := ctx.Module().(*AndroidAppCertificate)
if !ok { if !ok {
@ -1428,11 +1416,5 @@ func androidAppCertificateBp2BuildInternal(ctx android.TopDownMutatorContext, mo
Bzl_load_location: "//build/bazel/rules:android_app_certificate.bzl", 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 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) { func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*Module) m, ok := ctx.Module().(*Module)
if !ok || !m.ConvertWithBp2build(ctx) { if !ok || !m.ConvertWithBp2build(ctx) {
@ -112,7 +94,7 @@ func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
Rule_class: "py_binary", Rule_class: "py_binary",
} }
ctx.CreateBazelTargetModule(BazelPythonBinaryFactory, m.Name(), props, attrs) ctx.CreateBazelTargetModule(m.Name(), props, attrs)
} }
type BinaryProperties struct { type BinaryProperties struct {

View file

@ -527,18 +527,6 @@ type bazelShBinaryAttributes struct {
// visibility // 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) { func ShBinaryBp2Build(ctx android.TopDownMutatorContext) {
m, ok := ctx.Module().(*ShBinary) m, ok := ctx.Module().(*ShBinary)
if !ok || !m.ConvertWithBp2build(ctx) { if !ok || !m.ConvertWithBp2build(ctx) {
@ -556,13 +544,7 @@ func ShBinaryBp2Build(ctx android.TopDownMutatorContext) {
Rule_class: "sh_binary", 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 var Bool = proptools.Bool