From 5593fbbca8b5d2dd3a4b76a0a5623c88b577c908 Mon Sep 17 00:00:00 2001 From: Nikita Ioffe Date: Thu, 1 Dec 2022 14:52:34 +0000 Subject: Allow non-updatable modules to contribute to @TestApi java_sdk_libraries can be part of non-updatable modules. Those modules might have a need to expose @TestApis that are only used in CTS tests. This change adds an ability for them to do so by introducing all-non-updatable-modules-test-stubs, and adding it to the android_test_stubs_current. Note that this change doesn't allow updatable modules to contribute to test API stubs, since the list of the modules that can contribute to test APIs stubs is hardcoded in the non_updatable_modules constant. Bug: 261004711 Test: m Change-Id: I9d17f49702bd64f5718b445f14b203c146bc6794 --- api/api.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'api/api.go') diff --git a/api/api.go b/api/api.go index ba0fdc18d23e..c91ff815395f 100644 --- a/api/api.go +++ b/api/api.go @@ -36,6 +36,8 @@ var core_libraries_modules = []string{art, conscrypt, i18n} // built against module_current SDK). Instead they are directly statically // linked into the all-framework-module-lib, which is building against hidden // APIs. +// In addition, the modules in this list are allowed to contribute to test APIs +// stubs. var non_updatable_modules = []string{virtualization} // The intention behind this soong plugin is to generate a number of "merged" @@ -246,9 +248,33 @@ func createMergedPublicStubs(ctx android.LoadHookContext, modules []string) { } func createMergedSystemStubs(ctx android.LoadHookContext, modules []string) { + // First create the all-updatable-modules-system-stubs + { + updatable_modules := removeAll(modules, non_updatable_modules) + props := libraryProps{} + props.Name = proptools.StringPtr("all-updatable-modules-system-stubs") + props.Static_libs = transformArray(updatable_modules, "", ".stubs.system") + props.Sdk_version = proptools.StringPtr("module_current") + props.Visibility = []string{"//frameworks/base"} + ctx.CreateModule(java.LibraryFactory, &props) + } + // Now merge all-updatable-modules-system-stubs and stubs from non-updatable modules + // into all-modules-system-stubs. + { + props := libraryProps{} + props.Name = proptools.StringPtr("all-modules-system-stubs") + props.Static_libs = transformArray(non_updatable_modules, "", ".stubs.system") + props.Static_libs = append(props.Static_libs, "all-updatable-modules-system-stubs") + props.Sdk_version = proptools.StringPtr("module_current") + props.Visibility = []string{"//frameworks/base"} + ctx.CreateModule(java.LibraryFactory, &props) + } +} + +func createMergedTestStubsForNonUpdatableModules(ctx android.LoadHookContext) { props := libraryProps{} - props.Name = proptools.StringPtr("all-modules-system-stubs") - props.Static_libs = transformArray(modules, "", ".stubs.system") + props.Name = proptools.StringPtr("all-non-updatable-modules-test-stubs") + props.Static_libs = transformArray(non_updatable_modules, "", ".stubs.test") props.Sdk_version = proptools.StringPtr("module_current") props.Visibility = []string{"//frameworks/base"} ctx.CreateModule(java.LibraryFactory, &props) @@ -360,6 +386,7 @@ func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { createMergedPublicStubs(ctx, bootclasspath) createMergedSystemStubs(ctx, bootclasspath) + createMergedTestStubsForNonUpdatableModules(ctx) createMergedFrameworkModuleLibStubs(ctx, bootclasspath) createMergedFrameworkImpl(ctx, bootclasspath) -- cgit v1.2.3-59-g8ed1b