Bp2Build common properties auto-handling
Introduce `commonAttributes` & `fillCommonBp2BuildModuleAttrs used in
CreateBazelTargetModule
Adapt `bp2BuildInfo` to use `commonAttrs` instead of `Name`.
And thus also all downstream users of `CreateBazelTargetModule`.
As initial user, the Soong `required` property will be
translated to Bazel's `data`.
Bug: 198146582, 196091467
Test: build_converstion_test.go:TestCommonBp2BuildModuleAttrs
Test: go test
Test: mixed_{libc,droid}.sh
Change-Id: Ib500e40f7e2cb48c459f1ebe3188962fc41ec124
diff --git a/android/mutator.go b/android/mutator.go
index b361c51..4b37377 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -15,10 +15,11 @@
package android
import (
- "android/soong/bazel"
"reflect"
"sync"
+ "android/soong/bazel"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -268,7 +269,7 @@
// factory method, just like in CreateModule, but also requires
// BazelTargetModuleProperties containing additional metadata for the
// bp2build codegenerator.
- CreateBazelTargetModule(string, bazel.BazelTargetModuleProperties, interface{})
+ CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
}
type topDownMutatorContext struct {
@@ -514,17 +515,18 @@
}
func (t *topDownMutatorContext) CreateBazelTargetModule(
- name string,
bazelProps bazel.BazelTargetModuleProperties,
+ commonAttrs CommonAttributes,
attrs interface{}) {
-
+ commonAttrs.fillCommonBp2BuildModuleAttrs(t)
+ mod := t.Module()
info := bp2buildInfo{
- Name: name,
- Dir: t.OtherModuleDir(t.Module()),
- BazelProps: bazelProps,
- Attrs: attrs,
+ Dir: t.OtherModuleDir(mod),
+ BazelProps: bazelProps,
+ CommonAttrs: commonAttrs,
+ Attrs: attrs,
}
- t.Module().base().addBp2buildInfo(info)
+ mod.base().addBp2buildInfo(info)
}
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {