bp2build: framework for generating BazelTargetModules.
This CL creates the framework necessary for generating BazelTargetModules from regular Soong Android modules. BazelTargetModules are code-generated into Bazel targets in BUILD files. See the follow-up CL for examples of creating filegroup/genrule BazelTargetModules. Test: GENERATE_BAZEL_FILES=true m nothing # creates out/soong/bp2build with no BUILD files, because there are no BazelTargetModules in the module graph. Change-Id: I33a96365bd439043b13af6db9e439592e9983188
This commit is contained in:
@@ -44,9 +44,16 @@ func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) {
|
||||
}
|
||||
}
|
||||
|
||||
func registerMutatorsForBazelConversion(ctx *blueprint.Context) {
|
||||
// FIXME(b/171263886): Start bringing in mutators to make the Bionic
|
||||
// module subgraph suitable for automated conversion.
|
||||
// RegisterMutatorsForBazelConversion is a alternate registration pipeline for bp2build. Exported for testing.
|
||||
func RegisterMutatorsForBazelConversion(ctx *blueprint.Context, bp2buildMutators []RegisterMutatorFunc) {
|
||||
mctx := ®isterMutatorsContext{}
|
||||
|
||||
// Register bp2build mutators
|
||||
for _, f := range bp2buildMutators {
|
||||
f(mctx)
|
||||
}
|
||||
|
||||
registerMutatorsToContext(ctx, mctx.mutators)
|
||||
}
|
||||
|
||||
func registerMutators(ctx *blueprint.Context, preArch, preDeps, postDeps, finalDeps []RegisterMutatorFunc) {
|
||||
@@ -196,6 +203,21 @@ func FinalDepsMutators(f RegisterMutatorFunc) {
|
||||
finalDeps = append(finalDeps, f)
|
||||
}
|
||||
|
||||
var bp2buildMutators = []RegisterMutatorFunc{}
|
||||
|
||||
// RegisterBp2BuildMutator registers specially crafted mutators for
|
||||
// converting Blueprint/Android modules into special modules that can
|
||||
// be code-generated into Bazel BUILD targets.
|
||||
//
|
||||
// TODO(b/178068862): bring this into TestContext.
|
||||
func RegisterBp2BuildMutator(moduleType string, m func(TopDownMutatorContext)) {
|
||||
mutatorName := moduleType + "_bp2build"
|
||||
f := func(ctx RegisterMutatorsContext) {
|
||||
ctx.TopDown(mutatorName, m)
|
||||
}
|
||||
bp2buildMutators = append(bp2buildMutators, f)
|
||||
}
|
||||
|
||||
type BaseMutatorContext interface {
|
||||
BaseModuleContext
|
||||
|
||||
|
Reference in New Issue
Block a user