Implement API surface import with APEX stub

Implement APEX stub of API surface so any stub can be replaced with API
surface when APEX stub interface is required.

Unlike other stub interface, APEX stub can be decided if it should be
used after APEX postdeps mutator analyzes which modules should be
included in which APEX. To cover this, APEX stub is being added to the
dependency if the dependency should not be covered with LLNDK or NDK
stub, and APEX stub exists. From depsToPaths, if dependency to both
original module and API library exists, then it choose one of the
dependency and ignore the other.

To cover this logic, a new property is added to the api_surface :
apex_libs. This is introduced as it is difficult to
gather all api library with apex stub before DepsMutator.

Bug: 264963986
Test: cf_x86_64_phone_vendor build succeeded
Change-Id: I9f0b1f70968e32eba94d3e0d7bb1f4bb29ff2438
This commit is contained in:
Kiyoung Kim
2023-02-06 22:08:13 +09:00
parent 8ecedd4dfc
commit 76b06f3973
6 changed files with 520 additions and 265 deletions

View File

@@ -62,21 +62,26 @@ func sdkMutator(ctx android.BottomUpMutatorContext) {
} else if isCcModule && ccModule.isImportedApiLibrary() {
apiLibrary, _ := ccModule.linker.(*apiLibraryDecorator)
if apiLibrary.hasNDKStubs() && ccModule.canUseSdk() {
variations := []string{"sdk"}
if apiLibrary.hasApexStubs() {
variations = append(variations, "")
}
// Handle cc_api_library module with NDK stubs and variants only which can use SDK
modules := ctx.CreateVariations("", "sdk")
modules := ctx.CreateVariations(variations...)
// Mark the SDK variant.
modules[1].(*Module).Properties.IsSdkVariant = true
// SDK variant is not supposed to be installed
modules[1].(*Module).Properties.PreventInstall = true
modules[0].(*Module).Properties.IsSdkVariant = true
if ctx.Config().UnbundledBuildApps() {
// For an unbundled apps build, hide the platform variant from Make.
modules[0].(*Module).Properties.HideFromMake = true
if apiLibrary.hasApexStubs() {
// For an unbundled apps build, hide the platform variant from Make.
modules[1].(*Module).Properties.HideFromMake = true
modules[1].(*Module).Properties.PreventInstall = true
}
} else {
// For a platform build, mark the SDK variant so that it gets a ".sdk" suffix when
// exposed to Make.
modules[1].(*Module).Properties.SdkAndPlatformVariantVisibleToMake = true
modules[0].(*Module).Properties.SdkAndPlatformVariantVisibleToMake = true
// SDK variant is not supposed to be installed
modules[0].(*Module).Properties.PreventInstall = true
}
} else {
ccModule.Properties.Sdk_version = nil