From 062eb663c5144f8d9e4ab273558633a15bb75abd Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Thu, 29 Feb 2024 21:51:12 +0000 Subject: Enable from-text stub generation in non-sdk java_sdk_library This change allows from-text stubs to be generated for all java_sdk_library modules, unlike how it is currently limited to the modules that contribute to the api surfaces (i.e. the SDK). This change accomplish this by modifying the dependency of the from-text stubs generation, so that the sdk_library generated from-text stubs generating java_api_library modules no longer depend on the full api surface stubs, but generate the stubs in the module level, and combined later to generate the full api surface stubs. This change also removes the java_api_library modules defined in core-libraries/Android.bp, which are passed to generate the system modules. Given that the from-text vs from-source toggle is done within the java_sdk_library stubs level, these modules no longer need to exist. Implementation details: - Allow sdk_version to be specified in java_api_library modules. For java_sdk_library-generated java_api_library modules, they inherit that of the sdk_library module. Some java_sdk_library modules that do not contribute to the api surface are allowed to set sdk_version to something other than "none" or "core". - Implement java_api_library to implement `SdkContext`. This allows java_api_library to collect required deps from sdk_version (classpath, bootclasspath, system modules), and pass the collected jars when generating the stubs srcjar in metalava and compiling the stubs srcjar in javac. - Remove hardcoded list of sdk_library modules that are allowed to genereate stubs from the api signature files, and allow from-text stubs generation by default. Modules that are not able to generate stubs from the api signature files are specified by setting the newly introduced `Build_from_text_stubs` property to `false`. Test: ENABLE_HIDDENAPI_FLAGS=true m Bug: 327507877 Change-Id: Ia35d2f3cf9fae48fc8c4bd99a84ae18d7c0e7bee --- java/testing.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'java/testing.go') diff --git a/java/testing.go b/java/testing.go index 7a42e4cce..a99baf8a2 100644 --- a/java/testing.go +++ b/java/testing.go @@ -486,21 +486,17 @@ func gatherRequiredDepsForTest() string { } extraApiLibraryModules := map[string]droidstubsStruct{ - "android_stubs_current.from-text": publicDroidstubs, - "android_system_stubs_current.from-text": systemDroidstubs, - "android_test_stubs_current.from-text": testDroidstubs, - "android_module_lib_stubs_current.from-text": moduleLibDroidstubs, - "android_module_lib_stubs_current_full.from-text": moduleLibDroidstubs, - "android_system_server_stubs_current.from-text": systemServerDroidstubs, - "core.current.stubs.from-text": publicDroidstubs, - "legacy.core.platform.api.stubs.from-text": publicDroidstubs, - "stable.core.platform.api.stubs.from-text": publicDroidstubs, - "core-lambda-stubs.from-text": publicDroidstubs, - "android-non-updatable.stubs.from-text": publicDroidstubs, - "android-non-updatable.stubs.system.from-text": systemDroidstubs, - "android-non-updatable.stubs.test.from-text": testDroidstubs, - "android-non-updatable.stubs.module_lib.from-text": moduleLibDroidstubs, - "android-non-updatable.stubs.test_module_lib": moduleLibDroidstubs, + "android_stubs_current.from-text": publicDroidstubs, + "android_system_stubs_current.from-text": systemDroidstubs, + "android_test_stubs_current.from-text": testDroidstubs, + "android_module_lib_stubs_current.from-text": moduleLibDroidstubs, + "android_module_lib_stubs_current_full.from-text": moduleLibDroidstubs, + "android_system_server_stubs_current.from-text": systemServerDroidstubs, + "core.current.stubs.from-text": publicDroidstubs, + "legacy.core.platform.api.stubs.from-text": publicDroidstubs, + "stable.core.platform.api.stubs.from-text": publicDroidstubs, + "core-lambda-stubs.from-text": publicDroidstubs, + "android-non-updatable.stubs.test_module_lib": moduleLibDroidstubs, } for _, droidstubs := range droidstubsStructs { @@ -529,6 +525,8 @@ func gatherRequiredDepsForTest() string { name: "%s", api_contributions: ["%s"], stubs_type: "everything", + sdk_version: "none", + system_modules: "none", } `, libName, droidstubs.name+".api.contribution") } -- cgit v1.2.3-59-g8ed1b