Kaynağa Gözat

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
Spandan Das 1 yıl önce
ebeveyn
işleme
8b4a5f352e

+ 0 - 3
android/allowlists/allowlists.go

@@ -632,13 +632,10 @@ var (
 
 	Bp2buildModuleTypeAlwaysConvertList = []string{
 		"aidl_interface_headers",
-		"api_domain",
 		"license",
 		"linker_config",
 		"java_import",
 		"java_import_host",
-		"ndk_headers",
-		"ndk_library",
 		"sysprop_library",
 		"bpf",
 	}

+ 3 - 2
android/api_domain.go

@@ -67,7 +67,6 @@ func ApiDomainFactory() Module {
 	m := &apiDomain{}
 	m.AddProperties(&m.properties)
 	InitAndroidArchModule(m, DeviceSupported, MultilibBoth)
-	InitBazelModule(m)
 	return m
 }
 
@@ -108,7 +107,9 @@ type bazelApiDomainAttributes struct {
 	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",

+ 1 - 1
bp2build/api_domain_conversion_test.go

@@ -60,7 +60,7 @@ func TestApiDomainContributionsTest(t *testing.T) {
 			"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
 		},
 	)
-	RunBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{
+	RunApiBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{
 		Blueprint:            bp,
 		ExpectedBazelTargets: []string{expectedBazelTarget},
 		Filesystem:           fs,

+ 3 - 3
bp2build/ndk_headers_conversion_test.go

@@ -79,7 +79,7 @@ func TestNdkHeaderFilepaths(t *testing.T) {
 				"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 @@ func TestNdkHeaderIncludeDir(t *testing.T) {
 				"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 @@ func TestVersionedNdkHeaderFilepaths(t *testing.T) {
     ]`,
 		},
 	)
-	RunBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
+	RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{
 		Blueprint:            bp,
 		Filesystem:           fs,
 		ExpectedBazelTargets: []string{expectedBazelTarget},

+ 2 - 2
bp2build/ndk_library_conversion_test.go

@@ -37,7 +37,7 @@ func TestNdkLibraryContributionSymbolFile(t *testing.T) {
 			"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 @@ func TestNdkLibraryContributionHeaders(t *testing.T) {
 			"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},

+ 7 - 0
cc/cc.go

@@ -3729,6 +3729,13 @@ func (c *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
 		} 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)
 	}

+ 6 - 4
cc/ndk_headers.go

@@ -173,7 +173,9 @@ func createCcApiHeadersTarget(ctx android.TopDownMutatorContext, includes []stri
 	}, 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 @@ func ndkHeadersFactory() android.Module {
 	module := &headerModule{}
 	module.AddProperties(&module.properties)
 	android.InitAndroidModule(module)
-	android.InitBazelModule(module)
 	return module
 }
 
@@ -263,7 +264,9 @@ func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleCo
 	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 @@ func versionedNdkHeadersFactory() android.Module {
 	module.AddProperties(&module.properties)
 
 	android.InitAndroidModule(module)
-	android.InitBazelModule(module)
 
 	return module
 }