From f59a8e117ea4b1030cddf9b0ed0e0a23b38ade02 Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Fri, 16 Jul 2021 09:28:53 +0000 Subject: [PATCH] Fix apex bp2build. apexBundle was missing InitBazelModule for it to have bazel_module properties. Test: soong unit test Fixes: 193866723 Change-Id: I5fb38c8b2e8edaecef44162491d399c0223d3fb1 --- android/bazel.go | 9 +++++---- apex/apex.go | 1 + bp2build/apex_conversion_test.go | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/android/bazel.go b/android/bazel.go index 8d137621d..46212dc33 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -129,7 +129,7 @@ var ( // Keep any existing BUILD files (and do not generate new BUILD files) for these directories bp2buildKeepExistingBuildFile = map[string]bool{ // This is actually build/bazel/build.BAZEL symlinked to ./BUILD - ".":/*recrusive = */ false, + ".":/*recursive = */ false, "build/bazel":/* recursive = */ true, "build/pesto":/* recursive = */ true, @@ -144,9 +144,10 @@ var ( // Configure modules in these directories to enable bp2build_available: true or false by default. bp2buildDefaultConfig = Bp2BuildConfig{ - "bionic": Bp2BuildDefaultTrueRecursively, - "external/gwp_asan": Bp2BuildDefaultTrueRecursively, - "system/core/libcutils": Bp2BuildDefaultTrueRecursively, + "bionic": Bp2BuildDefaultTrueRecursively, + "build/bazel/examples/apex/minimal": Bp2BuildDefaultTrueRecursively, + "external/gwp_asan": Bp2BuildDefaultTrueRecursively, + "system/core/libcutils": Bp2BuildDefaultTrueRecursively, "system/core/property_service/libpropertyinfoparser": Bp2BuildDefaultTrueRecursively, "system/libbase": Bp2BuildDefaultTrueRecursively, "system/logging/liblog": Bp2BuildDefaultTrueRecursively, diff --git a/apex/apex.go b/apex/apex.go index 11df288a3..d385ac1c3 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2240,6 +2240,7 @@ func newApexBundle() *apexBundle { android.InitDefaultableModule(module) android.InitSdkAwareModule(module) android.InitOverridableModule(module, &module.overridableProperties.Overrides) + android.InitBazelModule(module) return module } diff --git a/bp2build/apex_conversion_test.go b/bp2build/apex_conversion_test.go index fbf6fa289..f4a1016bc 100644 --- a/bp2build/apex_conversion_test.go +++ b/bp2build/apex_conversion_test.go @@ -46,3 +46,23 @@ apex { manifest = "manifest.json", )`}}) } + +func TestApexBundleHasBazelModuleProps(t *testing.T) { + runApexTestCase(t, bp2buildTestCase{ + description: "apex - has bazel module props", + moduleTypeUnderTest: "apex", + moduleTypeUnderTestFactory: apex.BundleFactory, + moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build, + filesystem: map[string]string{}, + blueprint: ` +apex { + name: "apogee", + manifest: "manifest.json", + bazel_module: { bp2build_available: true }, +} +`, + expectedBazelTargets: []string{`apex( + name = "apogee", + manifest = "manifest.json", +)`}}) +}