Loading bp2build/bp2build.go +16 −6 Original line number Diff line number Diff line Loading @@ -45,17 +45,27 @@ func Codegen(ctx *CodegenContext) *CodegenMetrics { bp2buildFiles := CreateBazelFiles(ctx.Config(), nil, res.buildFileToTargets, ctx.mode) writeFiles(ctx, bp2buildDir, bp2buildFiles) soongInjectionDir := android.PathForOutput(ctx, bazel.SoongInjectionDirName) writeFiles(ctx, soongInjectionDir, CreateSoongInjectionDirFiles(ctx, res.metrics)) return &res.metrics } // Wrapper function that will be responsible for all files in soong_injection directory // This includes // 1. config value(s) that are hardcoded in Soong // 2. product_config variables func CreateSoongInjectionDirFiles(ctx *CodegenContext, metrics CodegenMetrics) []BazelFile { var ret []BazelFile productConfigFiles, err := CreateProductConfigFiles(ctx) if err != nil { fmt.Printf("ERROR: %s", err.Error()) os.Exit(1) } soongInjectionDir := android.PathForOutput(ctx, bazel.SoongInjectionDirName) writeFiles(ctx, soongInjectionDir, productConfigFiles) writeFiles(ctx, soongInjectionDir, CreateSoongInjectionFiles(ctx.Config(), res.metrics)) return &res.metrics ret = append(ret, productConfigFiles...) ret = append(ret, soongInjectionFiles(ctx.Config(), metrics)...) return ret } // Get the output directory and create it if it doesn't exist. Loading bp2build/conversion.go +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,8 @@ type BazelFile struct { Contents string } func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile { // PRIVATE: Use CreateSoongInjectionDirFiles instead func soongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile { var files []BazelFile files = append(files, newFile("android", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package. Loading bp2build/conversion_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ func TestCreateBazelFiles_QueryView_AddsTopLevelFiles(t *testing.T) { func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) { testConfig := android.TestConfig("", make(map[string]string), "", make(map[string][]byte)) files := CreateSoongInjectionFiles(testConfig, CreateCodegenMetrics()) files := soongInjectionFiles(testConfig, CreateCodegenMetrics()) expectedFilePaths := []bazelFilepath{ { Loading cmd/soong_build/main.go +5 −3 Original line number Diff line number Diff line Loading @@ -145,8 +145,10 @@ func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) { func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string { ctx.EventHandler.Begin("api_bp2build") defer ctx.EventHandler.End("api_bp2build") // Do not allow missing dependencies. ctx.SetAllowMissingDependencies(false) // api_bp2build does not run the typical pipeline of soong mutators. // Hoevever, it still runs the defaults mutator which can create dependencies. // These dependencies might not always exist (e.g. in tests) ctx.SetAllowMissingDependencies(ctx.Config().AllowMissingDependencies()) ctx.RegisterForApiBazelConversion() // Register the Android.bp files in the tree Loading Loading @@ -176,7 +178,7 @@ func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string { ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...) // Create soong_injection repository soongInjectionFiles := bp2build.CreateSoongInjectionFiles(ctx.Config(), bp2build.CreateCodegenMetrics()) soongInjectionFiles := bp2build.CreateSoongInjectionDirFiles(codegenContext, bp2build.CreateCodegenMetrics()) absoluteSoongInjectionDir := shared.JoinPath(topDir, ctx.Config().SoongOutDir(), bazel.SoongInjectionDirName) for _, file := range soongInjectionFiles { // The API targets in api_bp2build workspace do not have any dependency on api_bp2build. Loading tests/bp2build_bazel_test.sh +7 −0 Original line number Diff line number Diff line Loading @@ -231,4 +231,11 @@ EOF fi } # Smoke test to verify api_bp2build worksapce does not contain any errors function test_api_bp2build_empty_build() { setup run_soong api_bp2build run_bazel build --config=android --config=api_bp2build //:empty } scan_and_run_tests Loading
bp2build/bp2build.go +16 −6 Original line number Diff line number Diff line Loading @@ -45,17 +45,27 @@ func Codegen(ctx *CodegenContext) *CodegenMetrics { bp2buildFiles := CreateBazelFiles(ctx.Config(), nil, res.buildFileToTargets, ctx.mode) writeFiles(ctx, bp2buildDir, bp2buildFiles) soongInjectionDir := android.PathForOutput(ctx, bazel.SoongInjectionDirName) writeFiles(ctx, soongInjectionDir, CreateSoongInjectionDirFiles(ctx, res.metrics)) return &res.metrics } // Wrapper function that will be responsible for all files in soong_injection directory // This includes // 1. config value(s) that are hardcoded in Soong // 2. product_config variables func CreateSoongInjectionDirFiles(ctx *CodegenContext, metrics CodegenMetrics) []BazelFile { var ret []BazelFile productConfigFiles, err := CreateProductConfigFiles(ctx) if err != nil { fmt.Printf("ERROR: %s", err.Error()) os.Exit(1) } soongInjectionDir := android.PathForOutput(ctx, bazel.SoongInjectionDirName) writeFiles(ctx, soongInjectionDir, productConfigFiles) writeFiles(ctx, soongInjectionDir, CreateSoongInjectionFiles(ctx.Config(), res.metrics)) return &res.metrics ret = append(ret, productConfigFiles...) ret = append(ret, soongInjectionFiles(ctx.Config(), metrics)...) return ret } // Get the output directory and create it if it doesn't exist. Loading
bp2build/conversion.go +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,8 @@ type BazelFile struct { Contents string } func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile { // PRIVATE: Use CreateSoongInjectionDirFiles instead func soongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile { var files []BazelFile files = append(files, newFile("android", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package. Loading
bp2build/conversion_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ func TestCreateBazelFiles_QueryView_AddsTopLevelFiles(t *testing.T) { func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) { testConfig := android.TestConfig("", make(map[string]string), "", make(map[string][]byte)) files := CreateSoongInjectionFiles(testConfig, CreateCodegenMetrics()) files := soongInjectionFiles(testConfig, CreateCodegenMetrics()) expectedFilePaths := []bazelFilepath{ { Loading
cmd/soong_build/main.go +5 −3 Original line number Diff line number Diff line Loading @@ -145,8 +145,10 @@ func runQueryView(queryviewDir, queryviewMarker string, ctx *android.Context) { func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string { ctx.EventHandler.Begin("api_bp2build") defer ctx.EventHandler.End("api_bp2build") // Do not allow missing dependencies. ctx.SetAllowMissingDependencies(false) // api_bp2build does not run the typical pipeline of soong mutators. // Hoevever, it still runs the defaults mutator which can create dependencies. // These dependencies might not always exist (e.g. in tests) ctx.SetAllowMissingDependencies(ctx.Config().AllowMissingDependencies()) ctx.RegisterForApiBazelConversion() // Register the Android.bp files in the tree Loading Loading @@ -176,7 +178,7 @@ func runApiBp2build(ctx *android.Context, extraNinjaDeps []string) string { ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...) // Create soong_injection repository soongInjectionFiles := bp2build.CreateSoongInjectionFiles(ctx.Config(), bp2build.CreateCodegenMetrics()) soongInjectionFiles := bp2build.CreateSoongInjectionDirFiles(codegenContext, bp2build.CreateCodegenMetrics()) absoluteSoongInjectionDir := shared.JoinPath(topDir, ctx.Config().SoongOutDir(), bazel.SoongInjectionDirName) for _, file := range soongInjectionFiles { // The API targets in api_bp2build workspace do not have any dependency on api_bp2build. Loading
tests/bp2build_bazel_test.sh +7 −0 Original line number Diff line number Diff line Loading @@ -231,4 +231,11 @@ EOF fi } # Smoke test to verify api_bp2build worksapce does not contain any errors function test_api_bp2build_empty_build() { setup run_soong api_bp2build run_bazel build --config=android --config=api_bp2build //:empty } scan_and_run_tests