diff options
author | 2024-08-05 19:45:03 +0000 | |
---|---|---|
committer | 2024-08-05 19:45:09 +0000 | |
commit | 1ae36c84c23022df5541ca1f0f60ef7fe6aef9d5 (patch) | |
tree | 2018eaaee64a364a9fcb95676d514ee9fc4cd372 | |
parent | d6e978e2978b63e4d3b3cb03aef76fbe322000ba (diff) |
Revert "Remove full api surface from-text stubs java_api_library..."
Revert submission 2982300-java_api_library_non_sdk
Reason for revert: DroidMonitor: Potential culprit for b/357648959 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Reverted changes: /q/submissionid:2982300-java_api_library_non_sdk
Change-Id: I4224efbb47dc5ecf9afd7e3c9cd00b59a6c337ae
-rw-r--r-- | api/Android.bp | 7 | ||||
-rw-r--r-- | api/StubLibraries.bp | 259 | ||||
-rw-r--r-- | api/api.go | 81 | ||||
-rw-r--r-- | api/api_test.go | 111 | ||||
-rw-r--r-- | test-mock/Android.bp | 4 |
5 files changed, 365 insertions, 97 deletions
diff --git a/api/Android.bp b/api/Android.bp index d9966fd87ac3..4b26eb48f5de 100644 --- a/api/Android.bp +++ b/api/Android.bp @@ -284,7 +284,7 @@ packages_to_document = [ // These are libs from framework-internal-utils that are required (i.e. being referenced) // from framework-non-updatable-sources. Add more here when there's a need. // DO NOT add the entire framework-internal-utils. It might cause unnecessary circular -// dependencies when the list gets bigger. +// dependencies gets bigger. android_non_updatable_stubs_libs = [ "android.hardware.cas-V1.2-java", "android.hardware.health-V1.0-java-constants", @@ -381,11 +381,6 @@ non_updatable_api_deps_on_modules = [ "sdk_system_current_android", ] -java_defaults { - name: "module-classpath-java-defaults", - libs: non_updatable_api_deps_on_modules, -} - // Defaults with module APIs in the classpath (mostly from prebuilts). // Suitable for compiling android-non-updatable. stubs_defaults { diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp index d991da59f167..8dfddf0e13c8 100644 --- a/api/StubLibraries.bp +++ b/api/StubLibraries.bp @@ -563,12 +563,8 @@ java_library { java_defaults { name: "android-non-updatable_from_text_defaults", - defaults: ["android-non-updatable-stubs-libs-defaults"], static_libs: ["framework-res-package-jar"], libs: ["stub-annotations"], - sdk_version: "none", - system_modules: "none", - previous_api: ":android.api.public.latest", } java_defaults { @@ -586,10 +582,10 @@ java_api_library { "api-stubs-docs-non-updatable.api.contribution", ], defaults: ["android-non-updatable_everything_from_text_defaults"], + full_api_surface_stub: "android_stubs_current.from-text", // Use full Android API not just the non-updatable API as the latter is incomplete // and can result in incorrect behavior. previous_api: ":android.api.combined.public.latest", - libs: ["all-modules-public-stubs"], } java_api_library { @@ -600,10 +596,10 @@ java_api_library { "system-api-stubs-docs-non-updatable.api.contribution", ], defaults: ["android-non-updatable_everything_from_text_defaults"], + full_api_surface_stub: "android_system_stubs_current.from-text", // Use full Android API not just the non-updatable API as the latter is incomplete // and can result in incorrect behavior. previous_api: ":android.api.combined.system.latest", - libs: ["all-modules-system-stubs"], } java_api_library { @@ -615,10 +611,10 @@ java_api_library { "test-api-stubs-docs-non-updatable.api.contribution", ], defaults: ["android-non-updatable_everything_from_text_defaults"], + full_api_surface_stub: "android_test_stubs_current.from-text", // Use full Android API not just the non-updatable API as the latter is incomplete // and can result in incorrect behavior. previous_api: ":android.api.combined.test.latest", - libs: ["all-modules-system-stubs"], } java_api_library { @@ -629,10 +625,8 @@ java_api_library { "system-api-stubs-docs-non-updatable.api.contribution", "module-lib-api-stubs-docs-non-updatable.api.contribution", ], - defaults: [ - "module-classpath-java-defaults", - "android-non-updatable_everything_from_text_defaults", - ], + defaults: ["android-non-updatable_everything_from_text_defaults"], + full_api_surface_stub: "android_module_lib_stubs_current_full.from-text", // Use full Android API not just the non-updatable API as the latter is incomplete // and can result in incorrect behavior. previous_api: ":android.api.combined.module-lib.latest", @@ -650,16 +644,14 @@ java_api_library { "test-api-stubs-docs-non-updatable.api.contribution", "module-lib-api-stubs-docs-non-updatable.api.contribution", ], - defaults: [ - "module-classpath-java-defaults", - "android-non-updatable_everything_from_text_defaults", - ], + defaults: ["android-non-updatable_everything_from_text_defaults"], + full_api_surface_stub: "android_test_module_lib_stubs_current.from-text", // No need to specify previous_api as this is not used for compiling against. + // This module is only used for hiddenapi, and other modules should not // depend on this module. visibility: ["//visibility:private"], - libs: ["all-modules-system-stubs"], } java_defaults { @@ -673,7 +665,7 @@ java_defaults { } java_library { - name: "android_stubs_current", + name: "android_stubs_current.from-source", static_libs: [ "all-modules-public-stubs", "android-non-updatable.stubs", @@ -683,7 +675,7 @@ java_library { } java_library { - name: "android_stubs_current_exportable", + name: "android_stubs_current_exportable.from-source", static_libs: [ "all-modules-public-stubs-exportable", "android-non-updatable.stubs.exportable", @@ -693,7 +685,7 @@ java_library { } java_library { - name: "android_system_stubs_current", + name: "android_system_stubs_current.from-source", static_libs: [ "all-modules-system-stubs", "android-non-updatable.stubs.system", @@ -706,7 +698,7 @@ java_library { } java_library { - name: "android_system_stubs_current_exportable", + name: "android_system_stubs_current_exportable.from-source", static_libs: [ "all-modules-system-stubs-exportable", "android-non-updatable.stubs.exportable.system", @@ -730,7 +722,7 @@ java_library { } java_library { - name: "android_test_stubs_current", + name: "android_test_stubs_current.from-source", static_libs: [ // Updatable modules do not have test APIs, but we want to include their SystemApis, like we // include the SystemApi of framework-non-updatable-sources. @@ -747,7 +739,7 @@ java_library { } java_library { - name: "android_test_stubs_current_exportable", + name: "android_test_stubs_current_exportable.from-source", static_libs: [ // Updatable modules do not have test APIs, but we want to include their SystemApis, like we // include the SystemApi of framework-non-updatable-sources. @@ -768,7 +760,7 @@ java_library { // This module does not need to be copied to dist java_library { - name: "android_test_frameworks_core_stubs_current", + name: "android_test_frameworks_core_stubs_current.from-source", static_libs: [ "all-updatable-modules-system-stubs", "android-non-updatable.stubs.test", @@ -780,7 +772,7 @@ java_library { } java_library { - name: "android_module_lib_stubs_current", + name: "android_module_lib_stubs_current.from-source", defaults: [ "android.jar_defaults", ], @@ -793,7 +785,7 @@ java_library { } java_library { - name: "android_module_lib_stubs_current_exportable", + name: "android_module_lib_stubs_current_exportable.from-source", defaults: [ "android.jar_defaults", "android_stubs_dists_default", @@ -809,20 +801,20 @@ java_library { } java_library { - name: "android_system_server_stubs_current", + name: "android_system_server_stubs_current.from-source", defaults: [ "android.jar_defaults", ], srcs: [":services-non-updatable-stubs"], installable: false, static_libs: [ - "android_module_lib_stubs_current", + "android_module_lib_stubs_current.from-source", ], visibility: ["//frameworks/base/services"], } java_library { - name: "android_system_server_stubs_current_exportable", + name: "android_system_server_stubs_current_exportable.from-source", defaults: [ "android.jar_defaults", "android_stubs_dists_default", @@ -830,7 +822,7 @@ java_library { srcs: [":services-non-updatable-stubs{.exportable}"], installable: false, static_libs: [ - "android_module_lib_stubs_current_exportable", + "android_module_lib_stubs_current_exportable.from-source", ], dist: { dir: "apistubs/android/system-server", @@ -905,6 +897,215 @@ java_genrule { }, } +// +// Java API defaults and libraries for single tree build +// + +java_defaults { + name: "stub-annotation-defaults", + libs: [ + "stub-annotations", + ], + static_libs: [ + // stub annotations do not contribute to the API surfaces but are statically + // linked in the stubs for API surfaces (see frameworks/base/StubLibraries.bp). + // This is because annotation processors insist on loading the classes for any + // annotations found, thus should exist inside android.jar. + "private-stub-annotations-jar", + ], + is_stubs_module: true, +} + +// Listing of API domains contribution and dependencies per API surfaces +java_defaults { + name: "android_test_stubs_current_contributions", + api_surface: "test", + api_contributions: [ + "framework-virtualization.stubs.source.test.api.contribution", + "framework-location.stubs.source.test.api.contribution", + ], +} + +java_defaults { + name: "android_test_frameworks_core_stubs_current_contributions", + api_surface: "test", + api_contributions: [ + "test-api-stubs-docs-non-updatable.api.contribution", + ], +} + +java_defaults { + name: "android_module_lib_stubs_current_contributions", + api_surface: "module-lib", + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + "module-lib-api-stubs-docs-non-updatable.api.contribution", + "art.module.public.api.stubs.source.api.contribution", + "art.module.public.api.stubs.source.system.api.contribution", + "art.module.public.api.stubs.source.module_lib.api.contribution", + "i18n.module.public.api.stubs.source.api.contribution", + "i18n.module.public.api.stubs.source.system.api.contribution", + "i18n.module.public.api.stubs.source.module_lib.api.contribution", + ], + previous_api: ":android.api.combined.module-lib.latest", +} + +// Java API library definitions per API surface +java_api_library { + name: "android_stubs_current.from-text", + api_surface: "public", + defaults: [ + // This module is dynamically created at frameworks/base/api/api.go + // instead of being written out, in order to minimize edits in the codebase + // when there is a change in the list of modules. + // that contributes to an api surface. + "android_stubs_current_contributions", + "stub-annotation-defaults", + ], + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + ], + visibility: ["//visibility:public"], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_system_stubs_current.from-text", + api_surface: "system", + defaults: [ + "android_stubs_current_contributions", + "android_system_stubs_current_contributions", + "stub-annotation-defaults", + ], + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + ], + visibility: ["//visibility:public"], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_test_stubs_current.from-text", + api_surface: "test", + defaults: [ + "android_stubs_current_contributions", + "android_system_stubs_current_contributions", + "android_test_stubs_current_contributions", + "stub-annotation-defaults", + ], + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + "test-api-stubs-docs-non-updatable.api.contribution", + ], + visibility: ["//visibility:public"], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_test_frameworks_core_stubs_current.from-text", + api_surface: "test", + defaults: [ + "android_stubs_current_contributions", + "android_system_stubs_current_contributions", + "android_test_frameworks_core_stubs_current_contributions", + ], + libs: [ + "stub-annotations", + ], + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + ], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_module_lib_stubs_current_full.from-text", + api_surface: "module-lib", + defaults: [ + "android_stubs_current_contributions", + "android_system_stubs_current_contributions", + "android_module_lib_stubs_current_contributions_full", + ], + libs: [ + "stub-annotations", + ], + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + "module-lib-api-stubs-docs-non-updatable.api.contribution", + ], + visibility: ["//visibility:public"], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_module_lib_stubs_current.from-text", + api_surface: "module-lib", + defaults: [ + "android_module_lib_stubs_current_contributions", + ], + libs: [ + "android_module_lib_stubs_current_full.from-text", + "stub-annotations", + ], + visibility: ["//visibility:public"], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_test_module_lib_stubs_current.from-text", + api_surface: "module-lib", + defaults: [ + "android_stubs_current_contributions", + "android_system_stubs_current_contributions", + "android_test_stubs_current_contributions", + "android_module_lib_stubs_current_contributions", + ], + libs: [ + "android_module_lib_stubs_current_full.from-text", + "stub-annotations", + ], + api_contributions: [ + "test-api-stubs-docs-non-updatable.api.contribution", + ], + + // This module is only used to build android-non-updatable.stubs.test_module_lib + // and other modules should not depend on this module. + visibility: [ + "//visibility:private", + ], + enable_validation: false, + stubs_type: "everything", +} + +java_api_library { + name: "android_system_server_stubs_current.from-text", + api_surface: "system-server", + api_contributions: [ + "services-non-updatable-stubs.api.contribution", + ], + libs: [ + "android_module_lib_stubs_current.from-text", + "stub-annotations", + ], + static_libs: [ + "android_module_lib_stubs_current.from-text", + ], + visibility: ["//visibility:public"], + enable_validation: false, + stubs_type: "everything", +} + //////////////////////////////////////////////////////////////////////// // api-versions.xml generation, for public and system. This API database // also contains the android.test.* APIs. diff --git a/api/api.go b/api/api.go index 5b7f534443fb..b6b1a7e44510 100644 --- a/api/api.go +++ b/api/api.go @@ -15,7 +15,9 @@ package api import ( + "fmt" "sort" + "strings" "github.com/google/blueprint/proptools" @@ -462,6 +464,79 @@ func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_ } } +func createApiContributionDefaults(ctx android.LoadHookContext, modules []string) { + defaultsSdkKinds := []android.SdkKind{ + android.SdkPublic, android.SdkSystem, android.SdkModule, + } + for _, sdkKind := range defaultsSdkKinds { + props := defaultsProps{} + props.Name = proptools.StringPtr( + sdkKind.DefaultJavaLibraryName() + "_contributions") + if sdkKind == android.SdkModule { + props.Name = proptools.StringPtr( + sdkKind.DefaultJavaLibraryName() + "_contributions_full") + } + props.Api_surface = proptools.StringPtr(sdkKind.String()) + apiSuffix := "" + if sdkKind != android.SdkPublic { + apiSuffix = "." + strings.ReplaceAll(sdkKind.String(), "-", "_") + } + props.Api_contributions = transformArray( + modules, "", fmt.Sprintf(".stubs.source%s.api.contribution", apiSuffix)) + props.Defaults_visibility = []string{"//visibility:public"} + props.Previous_api = proptools.StringPtr(":android.api.combined." + sdkKind.String() + ".latest") + ctx.CreateModule(java.DefaultsFactory, &props) + } +} + +func createFullApiLibraries(ctx android.LoadHookContext) { + javaLibraryNames := []string{ + "android_stubs_current", + "android_system_stubs_current", + "android_test_stubs_current", + "android_test_frameworks_core_stubs_current", + "android_module_lib_stubs_current", + "android_system_server_stubs_current", + } + + for _, libraryName := range javaLibraryNames { + props := libraryProps{} + props.Name = proptools.StringPtr(libraryName) + staticLib := libraryName + ".from-source" + if ctx.Config().BuildFromTextStub() { + staticLib = libraryName + ".from-text" + } + props.Static_libs = []string{staticLib} + props.Defaults = []string{"android.jar_defaults"} + props.Visibility = []string{"//visibility:public"} + props.Is_stubs_module = proptools.BoolPtr(true) + + ctx.CreateModule(java.LibraryFactory, &props) + } +} + +func createFullExportableApiLibraries(ctx android.LoadHookContext) { + javaLibraryNames := []string{ + "android_stubs_current_exportable", + "android_system_stubs_current_exportable", + "android_test_stubs_current_exportable", + "android_module_lib_stubs_current_exportable", + "android_system_server_stubs_current_exportable", + } + + for _, libraryName := range javaLibraryNames { + props := libraryProps{} + props.Name = proptools.StringPtr(libraryName) + staticLib := libraryName + ".from-source" + props.Static_libs = []string{staticLib} + props.Defaults = []string{"android.jar_defaults"} + props.Visibility = []string{"//visibility:public"} + props.Is_stubs_module = proptools.BoolPtr(true) + + ctx.CreateModule(java.LibraryFactory, &props) + } +} + func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { bootclasspath := a.bootclasspath(ctx) system_server_classpath := a.systemServerClasspath(ctx) @@ -487,6 +562,12 @@ func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { createMergedAnnotationsFilegroups(ctx, bootclasspath, system_server_classpath) createPublicStubsSourceFilegroup(ctx, bootclasspath) + + createApiContributionDefaults(ctx, bootclasspath) + + createFullApiLibraries(ctx) + + createFullExportableApiLibraries(ctx) } func combinedApisModuleFactory() android.Module { diff --git a/api/api_test.go b/api/api_test.go index fb26f821eec1..47d167093b39 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -52,12 +52,6 @@ func gatherRequiredDepsForTest() string { "core.current.stubs", "ext", "framework", - "android_stubs_current", - "android_system_stubs_current", - "android_test_stubs_current", - "android_test_frameworks_core_stubs_current", - "android_module_lib_stubs_current", - "android_system_server_stubs_current", "android_stubs_current.from-text", "android_system_stubs_current.from-text", "android_test_stubs_current.from-text", @@ -196,60 +190,61 @@ func TestCombinedApisDefaults(t *testing.T) { } }), ).RunTestWithBp(t, ` - java_sdk_library { - name: "framework-foo", - srcs: ["a.java"], - public: { - enabled: true, - }, - system: { - enabled: true, - }, - test: { - enabled: true, - }, - module_lib: { - enabled: true, - }, - api_packages: [ - "foo", - ], - sdk_version: "core_current", - annotations_enabled: true, - } - java_sdk_library { - name: "framework-bar", - srcs: ["a.java"], - public: { - enabled: true, - }, - system: { - enabled: true, - }, - test: { - enabled: true, - }, - module_lib: { - enabled: true, - }, - api_packages: [ - "foo", - ], - sdk_version: "core_current", - annotations_enabled: true, - } + java_sdk_library { + name: "framework-foo", + srcs: ["a.java"], + public: { + enabled: true, + }, + system: { + enabled: true, + }, + test: { + enabled: true, + }, + module_lib: { + enabled: true, + }, + api_packages: [ + "foo", + ], + sdk_version: "core_current", + annotations_enabled: true, + } - combined_apis { - name: "foo", - bootclasspath: [ - "framework-bar", - ] + select(boolean_var_for_testing(), { - true: [ - "framework-foo", + java_sdk_library { + name: "framework-bar", + srcs: ["a.java"], + public: { + enabled: true, + }, + system: { + enabled: true, + }, + test: { + enabled: true, + }, + module_lib: { + enabled: true, + }, + api_packages: [ + "foo", ], - default: [], - }), - } + sdk_version: "core_current", + annotations_enabled: true, + } + + combined_apis { + name: "foo", + bootclasspath: [ + "framework-bar", + ] + select(boolean_var_for_testing(), { + true: [ + "framework-foo", + ], + default: [], + }), + } `) subModuleDependsOnSelectAppendedModule := java.CheckModuleHasDependency(t, diff --git a/test-mock/Android.bp b/test-mock/Android.bp index 71f303311047..59766579eee2 100644 --- a/test-mock/Android.bp +++ b/test-mock/Android.bp @@ -47,10 +47,6 @@ java_sdk_library { compile_dex: true, default_to_stubs: true, dist_group: "android", - - // This module cannot generate stubs from the api signature files as stubs depends on the - // private APIs, which are not visible in the api signature files. - build_from_text_stub: false, } java_library { |