Generate a BUILD file for every Android.bp file in api_bp2build
workspace. This is necessary to solve bazel package boundary issues where the api file might exist in a different directory Test: m api_bp2build && build/bazel/bin/bazel build --config=android --config=api_bp2build //build/orchestrator/apis:system Test: multitree_build system/nothing (in multitree) Change-Id: Id64085d65a1943bdb394ea80c875db96ca373839
This commit is contained in:
parent
bd52ea9ecf
commit
98cb85624c
2 changed files with 25 additions and 4 deletions
|
@ -136,7 +136,7 @@ func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) {
|
|||
ctx.EventHandler.Begin("queryview")
|
||||
defer ctx.EventHandler.End("queryview")
|
||||
codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.QueryView, topDir)
|
||||
err := createBazelWorkspace(codegenContext, shared.JoinPath(topDir, queryviewDir))
|
||||
err := createBazelWorkspace(codegenContext, shared.JoinPath(topDir, queryviewDir), false)
|
||||
maybeQuit(err, "")
|
||||
touch(shared.JoinPath(topDir, queryviewMarker))
|
||||
}
|
||||
|
@ -174,7 +174,28 @@ func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string {
|
|||
// Run codegen to generate BUILD files
|
||||
codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.ApiBp2build, topDir)
|
||||
absoluteApiBp2buildDir := shared.JoinPath(topDir, cmdlineArgs.BazelApiBp2buildDir)
|
||||
err := createBazelWorkspace(codegenContext, absoluteApiBp2buildDir)
|
||||
// Always generate bp2build_all_srcs filegroups in api_bp2build.
|
||||
// This is necessary to force each Android.bp file to create an equivalent BUILD file
|
||||
// and prevent package boundray issues.
|
||||
// e.g.
|
||||
// Source
|
||||
// f/b/Android.bp
|
||||
// java_library{
|
||||
// name: "foo",
|
||||
// api: "api/current.txt",
|
||||
// }
|
||||
//
|
||||
// f/b/api/Android.bp <- will cause package boundary issues
|
||||
//
|
||||
// Gen
|
||||
// f/b/BUILD
|
||||
// java_contribution{
|
||||
// name: "foo.contribution",
|
||||
// api: "//f/b/api:current.txt",
|
||||
// }
|
||||
//
|
||||
// If we don't generate f/b/api/BUILD, foo.contribution will be unbuildable.
|
||||
err := createBazelWorkspace(codegenContext, absoluteApiBp2buildDir, true)
|
||||
maybeQuit(err, "")
|
||||
ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ import (
|
|||
)
|
||||
|
||||
// A helper function to generate a Read-only Bazel workspace in outDir
|
||||
func createBazelWorkspace(ctx *bp2build.CodegenContext, outDir string) error {
|
||||
func createBazelWorkspace(ctx *bp2build.CodegenContext, outDir string, generateFilegroups bool) error {
|
||||
os.RemoveAll(outDir)
|
||||
ruleShims := bp2build.CreateRuleShims(android.ModuleTypeFactories())
|
||||
|
||||
res, err := bp2build.GenerateBazelTargets(ctx, false)
|
||||
res, err := bp2build.GenerateBazelTargets(ctx, generateFilegroups)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue