Loading android/allowlists/allowlists.go +32 −25 Original line number Diff line number Diff line Loading @@ -340,8 +340,12 @@ var ( "packages/modules/adb/pairing_connection": Bp2BuildDefaultTrueRecursively, "packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively, "packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/bpf_progs": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/service-t": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/service/native": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/staticlibs/native": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/staticlibs/netd/libnetdutils": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/staticlibs/netd": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/tests/unit/jni": Bp2BuildDefaultTrueRecursively, "packages/modules/Gki/libkver": Bp2BuildDefaultTrue, "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue, "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue, Loading Loading @@ -997,6 +1001,9 @@ var ( "tradefed-device-build-interfaces", "tradefed-invocation-interfaces", "tradefed-lib-core", "libandroid_net_connectivity_com_android_net_module_util_jni", "libservice-connectivity", } Bp2buildModuleTypeAlwaysConvertList = []string{ Loading android/bazel.go +11 −0 Original line number Diff line number Diff line Loading @@ -544,7 +544,18 @@ func (b *BazelModuleBase) shouldConvertWithBp2build(ctx shouldConvertModuleConte } moduleName := moduleNameWithPossibleOverride(ctx, module, p.moduleName) // use "prebuilt_" + original module name as the java_import(_host) module name, // to avoid the failure that a normal module and a prebuilt module with // the same name are both allowlisted. This cannot be applied to all the *_import // module types. For example, android_library_import has to use original module // name here otherwise the *-nodeps targets cannot be handled correctly. // TODO(b/304385140): remove this special casing if p.moduleType == "java_import" || p.moduleType == "java_import_host" { moduleName = module.Name() } allowlist := ctx.Config().Bp2buildPackageConfig moduleNameAllowed := allowlist.moduleAlwaysConvert[moduleName] moduleTypeAllowed := allowlist.moduleTypeAlwaysConvert[p.moduleType] allowlistConvert := moduleNameAllowed || moduleTypeAllowed Loading android/config.go +7 −1 Original line number Diff line number Diff line Loading @@ -1015,12 +1015,18 @@ func (c *config) FinalApiLevels() []ApiLevel { func (c *config) PreviewApiLevels() []ApiLevel { var levels []ApiLevel for i, codename := range c.PlatformVersionActiveCodenames() { i := 0 for _, codename := range c.PlatformVersionActiveCodenames() { if codename == "REL" { continue } levels = append(levels, ApiLevel{ value: codename, number: i, isPreview: true, }) i++ } return levels } Loading bp2build/cc_library_conversion_test.go +59 −0 Original line number Diff line number Diff line Loading @@ -5178,6 +5178,7 @@ ndk_library { ExpectedBazelTargets: []string{ MakeBazelTarget("cc_stub_suite", "libfoo.ndk_stub_libs", AttrNameToString{ "api_surface": `"publicapi"`, "included_in_ndk": `True`, "soname": `"libfoo.so"`, "source_library_label": `"//:libfoo"`, "symbol_file": `"libfoo.map.txt"`, Loading Loading @@ -5305,3 +5306,61 @@ cc_library_static { }, }) } func TestPropertiesIfStubLibraryIsInNdk(t *testing.T) { tc := Bp2buildTestCase{ Description: "If an equivalent ndk_library exists, set included_in_ndk=true for module-libapi stubs", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: ` // libfoo is an ndk library and contributes to module-libapi cc_library { name: "libfoo", stubs: {symbol_file: "libfoo.map.txt"}, } ndk_library { name: "libfoo", first_version: "29", symbol_file: "libfoo.map.txt", } // libbar is not an ndk library, but contributes to module-libapi cc_library { name: "libbar", stubs: {symbol_file: "libbar.map.txt"}, } `, StubbedBuildDefinitions: []string{"libfoo.ndk"}, ExpectedBazelTargets: []string{ MakeBazelTarget("cc_library_static", "libfoo_bp2build_cc_library_static", AttrNameToString{ "local_includes": `["."]`, }), MakeBazelTarget("cc_library_shared", "libfoo", AttrNameToString{ "local_includes": `["."]`, "stubs_symbol_file": `"libfoo.map.txt"`, }), MakeBazelTarget("cc_stub_suite", "libfoo_stub_libs", AttrNameToString{ "api_surface": `"module-libapi"`, "soname": `"libfoo.so"`, "source_library_label": `"//:libfoo"`, "symbol_file": `"libfoo.map.txt"`, "versions": `["current"]`, "included_in_ndk": `True`, }), MakeBazelTarget("cc_library_static", "libbar_bp2build_cc_library_static", AttrNameToString{ "local_includes": `["."]`, }), MakeBazelTarget("cc_library_shared", "libbar", AttrNameToString{ "local_includes": `["."]`, "stubs_symbol_file": `"libbar.map.txt"`, }), MakeBazelTarget("cc_stub_suite", "libbar_stub_libs", AttrNameToString{ "api_surface": `"module-libapi"`, "soname": `"libbar.so"`, "source_library_label": `"//:libbar"`, "symbol_file": `"libbar.map.txt"`, "versions": `["current"]`, }), }, } runCcLibraryTestCase(t, tc) } bp2build/cc_test_conversion_test.go +0 −20 Original line number Diff line number Diff line Loading @@ -631,23 +631,3 @@ cc_test { }, }) } func TestCcTest_UnitTestFalse(t *testing.T) { runCcTestTestCase(t, ccTestBp2buildTestCase{ description: "cc test with test_options.tags converted to tags", blueprint: ` cc_test { name: "mytest", host_supported: true, srcs: ["test.cpp"], test_options: { unit_test: false }, } ` + simpleModule("cc_library_static", "libgtest_main") + simpleModule("cc_library_static", "libgtest"), stubbedBuildDefinitions: []string{ "libgtest_main", "libgtest", }, targets: []testBazelTarget{}, }) } Loading
android/allowlists/allowlists.go +32 −25 Original line number Diff line number Diff line Loading @@ -340,8 +340,12 @@ var ( "packages/modules/adb/pairing_connection": Bp2BuildDefaultTrueRecursively, "packages/modules/adb/proto": Bp2BuildDefaultTrueRecursively, "packages/modules/adb/tls": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/bpf_progs": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/service-t": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/service/native": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/staticlibs/native": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/staticlibs/netd/libnetdutils": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/staticlibs/netd": Bp2BuildDefaultTrueRecursively, "packages/modules/Connectivity/tests/unit/jni": Bp2BuildDefaultTrueRecursively, "packages/modules/Gki/libkver": Bp2BuildDefaultTrue, "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue, "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue, Loading Loading @@ -997,6 +1001,9 @@ var ( "tradefed-device-build-interfaces", "tradefed-invocation-interfaces", "tradefed-lib-core", "libandroid_net_connectivity_com_android_net_module_util_jni", "libservice-connectivity", } Bp2buildModuleTypeAlwaysConvertList = []string{ Loading
android/bazel.go +11 −0 Original line number Diff line number Diff line Loading @@ -544,7 +544,18 @@ func (b *BazelModuleBase) shouldConvertWithBp2build(ctx shouldConvertModuleConte } moduleName := moduleNameWithPossibleOverride(ctx, module, p.moduleName) // use "prebuilt_" + original module name as the java_import(_host) module name, // to avoid the failure that a normal module and a prebuilt module with // the same name are both allowlisted. This cannot be applied to all the *_import // module types. For example, android_library_import has to use original module // name here otherwise the *-nodeps targets cannot be handled correctly. // TODO(b/304385140): remove this special casing if p.moduleType == "java_import" || p.moduleType == "java_import_host" { moduleName = module.Name() } allowlist := ctx.Config().Bp2buildPackageConfig moduleNameAllowed := allowlist.moduleAlwaysConvert[moduleName] moduleTypeAllowed := allowlist.moduleTypeAlwaysConvert[p.moduleType] allowlistConvert := moduleNameAllowed || moduleTypeAllowed Loading
android/config.go +7 −1 Original line number Diff line number Diff line Loading @@ -1015,12 +1015,18 @@ func (c *config) FinalApiLevels() []ApiLevel { func (c *config) PreviewApiLevels() []ApiLevel { var levels []ApiLevel for i, codename := range c.PlatformVersionActiveCodenames() { i := 0 for _, codename := range c.PlatformVersionActiveCodenames() { if codename == "REL" { continue } levels = append(levels, ApiLevel{ value: codename, number: i, isPreview: true, }) i++ } return levels } Loading
bp2build/cc_library_conversion_test.go +59 −0 Original line number Diff line number Diff line Loading @@ -5178,6 +5178,7 @@ ndk_library { ExpectedBazelTargets: []string{ MakeBazelTarget("cc_stub_suite", "libfoo.ndk_stub_libs", AttrNameToString{ "api_surface": `"publicapi"`, "included_in_ndk": `True`, "soname": `"libfoo.so"`, "source_library_label": `"//:libfoo"`, "symbol_file": `"libfoo.map.txt"`, Loading Loading @@ -5305,3 +5306,61 @@ cc_library_static { }, }) } func TestPropertiesIfStubLibraryIsInNdk(t *testing.T) { tc := Bp2buildTestCase{ Description: "If an equivalent ndk_library exists, set included_in_ndk=true for module-libapi stubs", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: ` // libfoo is an ndk library and contributes to module-libapi cc_library { name: "libfoo", stubs: {symbol_file: "libfoo.map.txt"}, } ndk_library { name: "libfoo", first_version: "29", symbol_file: "libfoo.map.txt", } // libbar is not an ndk library, but contributes to module-libapi cc_library { name: "libbar", stubs: {symbol_file: "libbar.map.txt"}, } `, StubbedBuildDefinitions: []string{"libfoo.ndk"}, ExpectedBazelTargets: []string{ MakeBazelTarget("cc_library_static", "libfoo_bp2build_cc_library_static", AttrNameToString{ "local_includes": `["."]`, }), MakeBazelTarget("cc_library_shared", "libfoo", AttrNameToString{ "local_includes": `["."]`, "stubs_symbol_file": `"libfoo.map.txt"`, }), MakeBazelTarget("cc_stub_suite", "libfoo_stub_libs", AttrNameToString{ "api_surface": `"module-libapi"`, "soname": `"libfoo.so"`, "source_library_label": `"//:libfoo"`, "symbol_file": `"libfoo.map.txt"`, "versions": `["current"]`, "included_in_ndk": `True`, }), MakeBazelTarget("cc_library_static", "libbar_bp2build_cc_library_static", AttrNameToString{ "local_includes": `["."]`, }), MakeBazelTarget("cc_library_shared", "libbar", AttrNameToString{ "local_includes": `["."]`, "stubs_symbol_file": `"libbar.map.txt"`, }), MakeBazelTarget("cc_stub_suite", "libbar_stub_libs", AttrNameToString{ "api_surface": `"module-libapi"`, "soname": `"libbar.so"`, "source_library_label": `"//:libbar"`, "symbol_file": `"libbar.map.txt"`, "versions": `["current"]`, }), }, } runCcLibraryTestCase(t, tc) }
bp2build/cc_test_conversion_test.go +0 −20 Original line number Diff line number Diff line Loading @@ -631,23 +631,3 @@ cc_test { }, }) } func TestCcTest_UnitTestFalse(t *testing.T) { runCcTestTestCase(t, ccTestBp2buildTestCase{ description: "cc test with test_options.tags converted to tags", blueprint: ` cc_test { name: "mytest", host_supported: true, srcs: ["test.cpp"], test_options: { unit_test: false }, } ` + simpleModule("cc_library_static", "libgtest_main") + simpleModule("cc_library_static", "libgtest"), stubbedBuildDefinitions: []string{ "libgtest_main", "libgtest", }, targets: []testBazelTarget{}, }) }