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
diff --git a/cc/object.go b/cc/object.go
index 5952f1e..606e368 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -130,24 +130,6 @@
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 @@
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) {