Move API providing modules from bp2build to api_bp2build workspace
The module types in scope are
1. ndk_library
2. ndk_headers, versioned_ndk_headers
3. api_domain
These modules will no longer generate Bazel targets in bp2build
workspace. A new soong mode `api_bp2build` will be used to generate API
specific targets in a separate Bazel workspace at out/soong/api_bp2build
Test: go test ./bp2build
Change-Id: I01d06b6d8b8364c0d56d6d3f07f8f8bf21db31d7
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 16feb74..8569cfa 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -632,13 +632,10 @@
Bp2buildModuleTypeAlwaysConvertList = []string{
"aidl_interface_headers",
- "api_domain",
"license",
"linker_config",
"java_import",
"java_import_host",
- "ndk_headers",
- "ndk_library",
"sysprop_library",
"bpf",
}
diff --git a/android/api_domain.go b/android/api_domain.go
index 8ff4752..7876654 100644
--- a/android/api_domain.go
+++ b/android/api_domain.go
@@ -67,7 +67,6 @@
m := &apiDomain{}
m.AddProperties(&m.properties)
InitAndroidArchModule(m, DeviceSupported, MultilibBoth)
- InitBazelModule(m)
return m
}
@@ -108,7 +107,9 @@
Cc_api_contributions bazel.LabelListAttribute
}
-func (a *apiDomain) ConvertWithBp2build(ctx TopDownMutatorContext) {
+var _ ApiProvider = (*apiDomain)(nil)
+
+func (a *apiDomain) ConvertWithApiBp2build(ctx TopDownMutatorContext) {
props := bazel.BazelTargetModuleProperties{
Rule_class: "api_domain",
Bzl_load_location: "//build/bazel/rules/apis:api_domain.bzl",
diff --git a/bp2build/api_domain_conversion_test.go b/bp2build/api_domain_conversion_test.go
index fc9d1d5..224008f 100644
--- a/bp2build/api_domain_conversion_test.go
+++ b/bp2build/api_domain_conversion_test.go
@@ -60,7 +60,7 @@
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
},
)
- RunBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{
+ RunApiBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{
Blueprint: bp,
ExpectedBazelTargets: []string{expectedBazelTarget},
Filesystem: fs,
diff --git a/bp2build/ndk_headers_conversion_test.go b/bp2build/ndk_headers_conversion_test.go
index c7cc6b2..9d0f1f2 100644
--- a/bp2build/ndk_headers_conversion_test.go
+++ b/bp2build/ndk_headers_conversion_test.go
@@ -79,7 +79,7 @@
"hdrs": testCase.expectedHdrs,
},
)
- RunBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
+ RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
Description: testCase.desc,
Blueprint: fmt.Sprintf(bpTemplate, testCase.srcs, testCase.excludeSrcs),
ExpectedBazelTargets: []string{expectedBazelTarget},
@@ -121,7 +121,7 @@
"include_dir": testCase.expectedIncludeDir,
},
)
- RunBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
+ RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
Description: testCase.desc,
Blueprint: fmt.Sprintf(bpTemplate, testCase.from),
ExpectedBazelTargets: []string{expectedBazelTarget},
@@ -156,7 +156,7 @@
]`,
},
)
- RunBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
+ RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
Blueprint: bp,
Filesystem: fs,
ExpectedBazelTargets: []string{expectedBazelTarget},
diff --git a/bp2build/ndk_library_conversion_test.go b/bp2build/ndk_library_conversion_test.go
index 244ce20..819ab25 100644
--- a/bp2build/ndk_library_conversion_test.go
+++ b/bp2build/ndk_library_conversion_test.go
@@ -37,7 +37,7 @@
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
},
)
- RunBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
+ RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
Blueprint: bp,
ExpectedBazelTargets: []string{expectedBazelTarget},
})
@@ -69,7 +69,7 @@
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
},
)
- RunBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
+ RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
Blueprint: bp,
Filesystem: fs,
ExpectedBazelTargets: []string{expectedBazelTarget},
diff --git a/cc/cc.go b/cc/cc.go
index 1c845f6..b319c5c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3729,6 +3729,13 @@
} else {
sharedOrStaticLibraryBp2Build(ctx, c, false)
}
+ }
+}
+
+var _ android.ApiProvider = (*Module)(nil)
+
+func (c *Module) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
+ switch c.typ() {
case ndkLibrary:
ndkLibraryBp2build(ctx, c)
}
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 08e2a39..7354be9 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -173,7 +173,9 @@
}, attrs)
}
-func (h *headerModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+var _ android.ApiProvider = (*headerModule)(nil)
+
+func (h *headerModule) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
// Generate `cc_api_headers` target for Multi-tree API export
createCcApiHeadersTarget(ctx, h.properties.Srcs, h.properties.Exclude_srcs, h.properties.From)
}
@@ -192,7 +194,6 @@
module := &headerModule{}
module.AddProperties(&module.properties)
android.InitAndroidModule(module)
- android.InitBazelModule(module)
return module
}
@@ -263,7 +264,9 @@
processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, srcFiles, installPaths)
}
-func (h *versionedHeaderModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+var _ android.ApiProvider = (*versionedHeaderModule)(nil)
+
+func (h *versionedHeaderModule) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
// Glob all .h files under `From`
includePattern := headerGlobPattern(proptools.String(h.properties.From))
// Generate `cc_api_headers` target for Multi-tree API export
@@ -319,7 +322,6 @@
module.AddProperties(&module.properties)
android.InitAndroidModule(module)
- android.InitBazelModule(module)
return module
}