Merge "Rename API surface provided to mainline modules"
This commit is contained in:
@@ -32,17 +32,18 @@ type ApiSurface int
|
|||||||
|
|
||||||
// TODO(b/246656800): Reconcile with android.SdkKind
|
// TODO(b/246656800): Reconcile with android.SdkKind
|
||||||
const (
|
const (
|
||||||
PublicApi ApiSurface = iota
|
// API surface provided by platform and mainline modules to other mainline modules
|
||||||
SystemApi
|
ModuleLibApi ApiSurface = iota
|
||||||
VendorApi
|
PublicApi // Aka NDK
|
||||||
|
VendorApi // Aka LLNDK
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a ApiSurface) String() string {
|
func (a ApiSurface) String() string {
|
||||||
switch a {
|
switch a {
|
||||||
|
case ModuleLibApi:
|
||||||
|
return "module-libapi"
|
||||||
case PublicApi:
|
case PublicApi:
|
||||||
return "publicapi"
|
return "publicapi"
|
||||||
case SystemApi:
|
|
||||||
return "systemapi"
|
|
||||||
case VendorApi:
|
case VendorApi:
|
||||||
return "vendorapi"
|
return "vendorapi"
|
||||||
default:
|
default:
|
||||||
|
@@ -2825,7 +2825,7 @@ func TestCcApiContributionsWithHdrs(t *testing.T) {
|
|||||||
expectedBazelTargets := []string{
|
expectedBazelTargets := []string{
|
||||||
MakeBazelTarget(
|
MakeBazelTarget(
|
||||||
"cc_api_library_headers",
|
"cc_api_library_headers",
|
||||||
"libfoo.systemapi.headers",
|
"libfoo.module-libapi.headers",
|
||||||
AttrNameToString{
|
AttrNameToString{
|
||||||
"export_includes": `["dir1"]`,
|
"export_includes": `["dir1"]`,
|
||||||
}),
|
}),
|
||||||
@@ -2842,18 +2842,18 @@ func TestCcApiContributionsWithHdrs(t *testing.T) {
|
|||||||
"api": `"libfoo.map.txt"`,
|
"api": `"libfoo.map.txt"`,
|
||||||
"library_name": `"libfoo"`,
|
"library_name": `"libfoo"`,
|
||||||
"api_surfaces": `[
|
"api_surfaces": `[
|
||||||
"systemapi",
|
"module-libapi",
|
||||||
"vendorapi",
|
"vendorapi",
|
||||||
]`,
|
]`,
|
||||||
"hdrs": `[
|
"hdrs": `[
|
||||||
":libfoo.systemapi.headers",
|
":libfoo.module-libapi.headers",
|
||||||
":libfoo.vendorapi.headers",
|
":libfoo.vendorapi.headers",
|
||||||
]`,
|
]`,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
|
RunApiBp2BuildTestCase(t, cc.RegisterLibraryBuildComponents, Bp2buildTestCase{
|
||||||
Blueprint: bp,
|
Blueprint: bp,
|
||||||
Description: "cc API contributions to systemapi and vendorapi",
|
Description: "cc API contributions to module-libapi and vendorapi",
|
||||||
ExpectedBazelTargets: expectedBazelTargets,
|
ExpectedBazelTargets: expectedBazelTargets,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -2872,8 +2872,8 @@ func TestCcApiSurfaceCombinations(t *testing.T) {
|
|||||||
stubs: {symbol_file: "a.map.txt"},
|
stubs: {symbol_file: "a.map.txt"},
|
||||||
}`,
|
}`,
|
||||||
expectedApi: `"a.map.txt"`,
|
expectedApi: `"a.map.txt"`,
|
||||||
expectedApiSurfaces: `["systemapi"]`,
|
expectedApiSurfaces: `["module-libapi"]`,
|
||||||
description: "Library that contributes to systemapi",
|
description: "Library that contributes to module-libapi",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bp: `
|
bp: `
|
||||||
@@ -2894,10 +2894,10 @@ func TestCcApiSurfaceCombinations(t *testing.T) {
|
|||||||
}`,
|
}`,
|
||||||
expectedApi: `"a.map.txt"`,
|
expectedApi: `"a.map.txt"`,
|
||||||
expectedApiSurfaces: `[
|
expectedApiSurfaces: `[
|
||||||
"systemapi",
|
"module-libapi",
|
||||||
"vendorapi",
|
"vendorapi",
|
||||||
]`,
|
]`,
|
||||||
description: "Library that contributes to systemapi and vendorapi",
|
description: "Library that contributes to module-libapi and vendorapi",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
@@ -475,10 +475,10 @@ func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module
|
|||||||
func apiContributionBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
func apiContributionBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
apiSurfaces := make([]string, 0)
|
apiSurfaces := make([]string, 0)
|
||||||
apiHeaders := make([]string, 0)
|
apiHeaders := make([]string, 0)
|
||||||
// systemapi (non-null `stubs` property)
|
// module-libapi for apexes (non-null `stubs` property)
|
||||||
if module.HasStubsVariants() {
|
if module.HasStubsVariants() {
|
||||||
apiSurfaces = append(apiSurfaces, android.SystemApi.String())
|
apiSurfaces = append(apiSurfaces, android.ModuleLibApi.String())
|
||||||
apiIncludes := getSystemApiIncludes(ctx, module)
|
apiIncludes := getModuleLibApiIncludes(ctx, module)
|
||||||
if !apiIncludes.isEmpty() {
|
if !apiIncludes.isEmpty() {
|
||||||
createApiHeaderTarget(ctx, apiIncludes)
|
createApiHeaderTarget(ctx, apiIncludes)
|
||||||
apiHeaders = append(apiHeaders, apiIncludes.name)
|
apiHeaders = append(apiHeaders, apiIncludes.name)
|
||||||
@@ -494,8 +494,8 @@ func apiContributionBp2Build(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create a target only if this module contributes to an api surface
|
// create a target only if this module contributes to an api surface
|
||||||
// TODO: Currently this does not distinguish systemapi-only headers and vendrorapi-only headers
|
// TODO: Currently this does not distinguish modulelibapi-only headers and vendrorapi-only headers
|
||||||
// TODO: Update so that systemapi-only headers do not get exported to vendorapi (and vice-versa)
|
// TODO: Update so that modulelibapi-only headers do not get exported to vendorapi (and vice-versa)
|
||||||
if len(apiSurfaces) > 0 {
|
if len(apiSurfaces) > 0 {
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "cc_api_contribution",
|
Rule_class: "cc_api_contribution",
|
||||||
@@ -527,8 +527,8 @@ func apiLabelAttribute(ctx android.TopDownMutatorContext, module *Module) bazel.
|
|||||||
linker := module.linker.(*libraryDecorator)
|
linker := module.linker.(*libraryDecorator)
|
||||||
if llndkApi := linker.Properties.Llndk.Symbol_file; llndkApi != nil {
|
if llndkApi := linker.Properties.Llndk.Symbol_file; llndkApi != nil {
|
||||||
apiFile = llndkApi
|
apiFile = llndkApi
|
||||||
} else if systemApi := linker.Properties.Stubs.Symbol_file; systemApi != nil {
|
} else if moduleLibApi := linker.Properties.Stubs.Symbol_file; moduleLibApi != nil {
|
||||||
apiFile = systemApi
|
apiFile = moduleLibApi
|
||||||
} else {
|
} else {
|
||||||
ctx.ModuleErrorf("API surface library does not have any API file")
|
ctx.ModuleErrorf("API surface library does not have any API file")
|
||||||
}
|
}
|
||||||
@@ -566,7 +566,8 @@ func (includes *apiIncludes) addDep(name string) {
|
|||||||
includes.attrs.Deps.Append(lla)
|
includes.attrs.Deps.Append(lla)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSystemApiIncludes(ctx android.TopDownMutatorContext, c *Module) apiIncludes {
|
// includes provided to the module-lib API surface. This API surface is used by apexes.
|
||||||
|
func getModuleLibApiIncludes(ctx android.TopDownMutatorContext, c *Module) apiIncludes {
|
||||||
flagProps := c.library.(*libraryDecorator).flagExporter.Properties
|
flagProps := c.library.(*libraryDecorator).flagExporter.Properties
|
||||||
linkProps := c.library.(*libraryDecorator).baseLinker.Properties
|
linkProps := c.library.(*libraryDecorator).baseLinker.Properties
|
||||||
includes := android.FirstUniqueStrings(flagProps.Export_include_dirs)
|
includes := android.FirstUniqueStrings(flagProps.Export_include_dirs)
|
||||||
@@ -579,7 +580,7 @@ func getSystemApiIncludes(ctx android.TopDownMutatorContext, c *Module) apiInclu
|
|||||||
}
|
}
|
||||||
|
|
||||||
return apiIncludes{
|
return apiIncludes{
|
||||||
name: c.Name() + ".systemapi.headers",
|
name: c.Name() + ".module-libapi.headers",
|
||||||
attrs: bazelCcApiLibraryHeadersAttributes{
|
attrs: bazelCcApiLibraryHeadersAttributes{
|
||||||
bazelCcLibraryHeadersAttributes: attrs,
|
bazelCcLibraryHeadersAttributes: attrs,
|
||||||
},
|
},
|
||||||
|
@@ -169,7 +169,7 @@ func apiLibraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module
|
|||||||
// For API export, create a top-level arch-agnostic target and list the arch-specific targets as its deps
|
// For API export, create a top-level arch-agnostic target and list the arch-specific targets as its deps
|
||||||
|
|
||||||
// arch-agnostic includes
|
// arch-agnostic includes
|
||||||
apiIncludes := getSystemApiIncludes(ctx, module)
|
apiIncludes := getModuleLibApiIncludes(ctx, module)
|
||||||
// arch and os specific includes
|
// arch and os specific includes
|
||||||
archApiIncludes, androidOsIncludes := archOsSpecificApiIncludes(ctx, module)
|
archApiIncludes, androidOsIncludes := archOsSpecificApiIncludes(ctx, module)
|
||||||
for _, arch := range allArches { // sorted iteration
|
for _, arch := range allArches { // sorted iteration
|
||||||
@@ -186,7 +186,7 @@ func apiLibraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !apiIncludes.isEmpty() {
|
if !apiIncludes.isEmpty() {
|
||||||
// override the name from <mod>.systemapi.headers --> <mod>.contribution
|
// override the name from <mod>.module-libapi.headers --> <mod>.contribution
|
||||||
apiIncludes.name = android.ApiContributionTargetName(module.Name())
|
apiIncludes.name = android.ApiContributionTargetName(module.Name())
|
||||||
createApiHeaderTarget(ctx, apiIncludes)
|
createApiHeaderTarget(ctx, apiIncludes)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user