diff options
Diffstat (limited to 'api')
| -rw-r--r-- | api/Android.bp | 5 | ||||
| -rw-r--r-- | api/ApiDocs.bp | 1 | ||||
| -rw-r--r-- | api/OWNERS | 5 | ||||
| -rw-r--r-- | api/StubLibraries.bp | 368 | ||||
| -rw-r--r-- | api/api.go | 165 | ||||
| -rw-r--r-- | api/api_test.go | 65 | ||||
| -rwxr-xr-x | api/gen_combined_removed_dex.sh | 2 | ||||
| -rw-r--r-- | api/go.mod | 12 | ||||
| -rw-r--r-- | api/go.work | 19 | ||||
| -rw-r--r-- | api/go.work.sum | 66 | ||||
| -rw-r--r-- | api/javadoc-lint-baseline | 0 |
11 files changed, 629 insertions, 79 deletions
diff --git a/api/Android.bp b/api/Android.bp index f5bafe8bf8da..590d5a52e51c 100644 --- a/api/Android.bp +++ b/api/Android.bp @@ -60,14 +60,14 @@ python_test_host { metalava_cmd = "$(location metalava)" // Silence reflection warnings. See b/168689341 metalava_cmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED " -metalava_cmd += " --quiet --no-banner --format=v2 " +metalava_cmd += " --quiet " genrule { name: "current-api-xml", tools: ["metalava"], srcs: [":frameworks-base-api-current.txt"], out: ["current.api"], - cmd: metalava_cmd + "-convert2xmlnostrip $(in) $(out)", + cmd: metalava_cmd + "signature-to-jdiff $(in) $(out)", visibility: ["//visibility:public"], } @@ -89,6 +89,7 @@ combined_apis { "framework-media", "framework-mediaprovider", "framework-ondevicepersonalization", + "framework-pdf", "framework-permission", "framework-permission-s", "framework-scheduling", diff --git a/api/ApiDocs.bp b/api/ApiDocs.bp index fbcaa52f9bb4..6461c00b1dcd 100644 --- a/api/ApiDocs.bp +++ b/api/ApiDocs.bp @@ -209,6 +209,7 @@ doc_defaults { custom_template: "droiddoc-templates-sdk", resourcesdir: "docs/html/reference/images/", resourcesoutdir: "reference/android/images/", + lint_baseline: "javadoc-lint-baseline", hdf: [ "dac true", "sdk.codename O", diff --git a/api/OWNERS b/api/OWNERS index bf6216c168e8..965093c9ab38 100644 --- a/api/OWNERS +++ b/api/OWNERS @@ -3,7 +3,10 @@ hansson@google.com # Modularization team file:platform/packages/modules/common:/OWNERS +# Soong plugin owned by Soong team. +per-file *.go,go.mod,go.work,go.work.sum = file:platform/build/soong:/OWNERS + per-file Android.bp = file:platform/build/soong:/OWNERS #{LAST_RESORT_SUGGESTION} # For metalava team to disable lint checks in platform -per-file Android.bp = aurimas@google.com,emberrose@google.com,sjgilbert@google.com +per-file Android.bp = aurimas@google.com,emberrose@google.com diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp index f08745b5cd2c..857077d60a5d 100644 --- a/api/StubLibraries.bp +++ b/api/StubLibraries.bp @@ -29,6 +29,9 @@ droidstubs { name: "api-stubs-docs-non-updatable", + srcs: [ + ":framework-minus-apex-aconfig-srcjars", + ], defaults: [ "android-non-updatable-stubs-defaults", "module-classpath-stubs-defaults", @@ -63,6 +66,7 @@ droidstubs { tag: ".removed-api.txt", }, ], + api_surface: "public", } priv_apps = " --show-annotation android.annotation.SystemApi\\(" + @@ -81,6 +85,9 @@ module_libs = " --show-annotation android.annotation.SystemApi\\(" + droidstubs { name: "system-api-stubs-docs-non-updatable", + srcs: [ + ":framework-minus-apex-aconfig-srcjars", + ], defaults: [ "android-non-updatable-stubs-defaults", "module-classpath-stubs-defaults", @@ -116,10 +123,14 @@ droidstubs { tag: ".removed-api.txt", }, ], + api_surface: "system", } droidstubs { name: "test-api-stubs-docs-non-updatable", + srcs: [ + ":framework-minus-apex-aconfig-srcjars", + ], defaults: [ "android-non-updatable-stubs-defaults", "module-classpath-stubs-defaults", @@ -161,10 +172,14 @@ droidstubs { tag: ".removed-api.txt", }, ], + api_surface: "test", } droidstubs { name: "module-lib-api-stubs-docs-non-updatable", + srcs: [ + ":framework-minus-apex-aconfig-srcjars", + ], defaults: [ "android-non-updatable-stubs-defaults", "module-classpath-stubs-defaults", @@ -200,6 +215,7 @@ droidstubs { tag: ".removed-api.txt", }, ], + api_surface: "module-lib", } ///////////////////////////////////////////////////////////////////// @@ -213,30 +229,106 @@ java_defaults { system_modules: "none", java_version: "1.8", compile_dex: true, - defaults_visibility: ["//visibility:private"], visibility: ["//visibility:public"], } java_defaults { - name: "android-non-updatable_defaults_stubs_current", - libs: ["stub-annotations"], - static_libs: ["framework-res-package-jar"], // Export package of framework-res + name: "android-non-updatable_defaults", sdk_version: "none", system_modules: "none", java_version: "1.8", compile_dex: true, +} + +java_defaults { + name: "android-non-updatable_from_source_defaults", + libs: ["stub-annotations"], + static_libs: ["framework-res-package-jar"], // Export package of framework-res dist: { targets: ["sdk"], tag: ".jar", dest: "android-non-updatable.jar", }, - defaults_visibility: ["//visibility:private"], - visibility: ["//visibility:private"], } java_library { name: "android-non-updatable.stubs", - defaults: ["android-non-updatable_defaults_stubs_current"], + defaults: ["android-non-updatable_defaults"], + static_libs: [ + "android-non-updatable.stubs.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "android-non-updatable.stubs.from-text", + ], + exclude_static_libs: [ + "android-non-updatable.stubs.from-source", + ], + }, + }, +} + +java_library { + name: "android-non-updatable.stubs.system", + defaults: ["android-non-updatable_defaults"], + static_libs: [ + "android-non-updatable.stubs.system.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "android-non-updatable.stubs.system.from-text", + ], + exclude_static_libs: [ + "android-non-updatable.stubs.system.from-source", + ], + }, + }, +} + +java_library { + name: "android-non-updatable.stubs.module_lib", + defaults: ["android-non-updatable_defaults"], + static_libs: [ + "android-non-updatable.stubs.module_lib.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "android-non-updatable.stubs.module_lib.from-text", + ], + exclude_static_libs: [ + "android-non-updatable.stubs.module_lib.from-source", + ], + }, + }, +} + +java_library { + name: "android-non-updatable.stubs.test", + defaults: ["android-non-updatable_defaults"], + static_libs: [ + "android-non-updatable.stubs.test.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "android-non-updatable.stubs.test.from-text", + ], + exclude_static_libs: [ + "android-non-updatable.stubs.test.from-source", + ], + }, + }, +} + +java_library { + name: "android-non-updatable.stubs.from-source", + defaults: [ + "android-non-updatable_defaults", + "android-non-updatable_from_source_defaults", + ], srcs: [":api-stubs-docs-non-updatable"], libs: ["all-modules-public-stubs"], dist: { @@ -245,8 +337,11 @@ java_library { } java_library { - name: "android-non-updatable.stubs.system", - defaults: ["android-non-updatable_defaults_stubs_current"], + name: "android-non-updatable.stubs.system.from-source", + defaults: [ + "android-non-updatable_defaults", + "android-non-updatable_from_source_defaults", + ], srcs: [":system-api-stubs-docs-non-updatable"], libs: ["all-modules-system-stubs"], dist: { @@ -255,17 +350,22 @@ java_library { } java_library { - name: "android-non-updatable.stubs.module_lib", - defaults: ["android-non-updatable_defaults_stubs_current"], + name: "android-non-updatable.stubs.module_lib.from-source", + defaults: [ + "android-non-updatable_defaults", + "android-non-updatable_from_source_defaults", + ], srcs: [":module-lib-api-stubs-docs-non-updatable"], libs: [ + // We cannot depend on all-modules-module-lib-stubs, because the module-lib stubs + // depend on this stub. We resolve dependencies on APIs in modules by depending + // on a prebuilt of the whole platform (sdk_system_current_android). + // That prebuilt does not include module-lib APIs, so use the prebuilt module-lib + // stubs for modules that export module-lib stubs that the non-updatable part + // depends on. "sdk_module-lib_current_framework-tethering", "sdk_module-lib_current_framework-connectivity-t", - "sdk_public_current_framework-bluetooth", - // NOTE: The below can be removed once the prebuilt stub contains bluetooth. "sdk_system_current_android", - // NOTE: The below can be removed once the prebuilt stub contains IKE. - "sdk_system_current_android.net.ipsec.ike", ], dist: { dir: "apistubs/android/module-lib", @@ -273,8 +373,11 @@ java_library { } java_library { - name: "android-non-updatable.stubs.test", - defaults: ["android-non-updatable_defaults_stubs_current"], + name: "android-non-updatable.stubs.test.from-source", + defaults: [ + "android-non-updatable_defaults", + "android-non-updatable_from_source_defaults", + ], srcs: [":test-api-stubs-docs-non-updatable"], libs: ["all-modules-system-stubs"], dist: { @@ -283,6 +386,57 @@ java_library { } java_defaults { + name: "android-non-updatable_from_text_defaults", + static_libs: ["framework-res-package-jar"], + libs: ["stub-annotations"], +} + +java_api_library { + name: "android-non-updatable.stubs.from-text", + api_surface: "public", + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + ], + defaults: ["android-non-updatable_from_text_defaults"], + full_api_surface_stub: "android_stubs_current.from-text", +} + +java_api_library { + name: "android-non-updatable.stubs.system.from-text", + api_surface: "system", + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + ], + defaults: ["android-non-updatable_from_text_defaults"], + full_api_surface_stub: "android_system_stubs_current.from-text", +} + +java_api_library { + name: "android-non-updatable.stubs.test.from-text", + api_surface: "test", + 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", + ], + defaults: ["android-non-updatable_from_text_defaults"], + full_api_surface_stub: "android_test_stubs_current.from-text", +} + +java_api_library { + name: "android-non-updatable.stubs.module_lib.from-text", + 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", + ], + defaults: ["android-non-updatable_from_text_defaults"], + full_api_surface_stub: "android_module_lib_stubs_current_full.from-text", +} + +java_defaults { name: "android_stubs_dists_default", dist: { targets: ["sdk"], @@ -293,7 +447,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", @@ -303,7 +457,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", @@ -327,7 +481,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. @@ -347,7 +501,7 @@ java_library { } java_library { - name: "android_module_lib_stubs_current", + name: "android_module_lib_stubs_current.from-source", defaults: [ "android.jar_defaults", "android_stubs_dists_default", @@ -363,7 +517,7 @@ java_library { } java_library { - name: "android_system_server_stubs_current", + name: "android_system_server_stubs_current.from-source", defaults: [ "android.jar_defaults", "android_stubs_dists_default", @@ -371,7 +525,7 @@ java_library { srcs: [":services-non-updatable-stubs"], installable: false, static_libs: [ - "android_module_lib_stubs_current", + "android_module_lib_stubs_current.from-source", ], dist: { dir: "apistubs/android/system-server", @@ -402,7 +556,6 @@ java_library { java_genrule { name: "android_stubs_private_hjar", - visibility: ["//visibility:private"], srcs: [":android_stubs_private_jar{.hjar}"], out: ["android_stubs_private.jar"], cmd: "cp $(in) $(out)", @@ -411,7 +564,6 @@ java_genrule { java_library { name: "android_stubs_private", defaults: ["android_stubs_dists_default"], - visibility: ["//visibility:private"], sdk_version: "none", system_modules: "none", static_libs: ["android_stubs_private_hjar"], @@ -422,7 +574,6 @@ java_library { java_genrule { name: "android_stubs_private_framework_aidl", - visibility: ["//visibility:private"], tools: ["sdkparcelables"], srcs: [":android_stubs_private"], out: ["framework.aidl"], @@ -439,6 +590,170 @@ 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", + ], +} + +// 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", + ], +} + +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", + ], +} + +// 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"], +} + +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"], +} + +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"], +} + +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", + "stub-annotation-defaults", + ], + api_contributions: [ + "api-stubs-docs-non-updatable.api.contribution", + "system-api-stubs-docs-non-updatable.api.contribution", + ], +} + +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"], +} + +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"], +} + +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"], +} + //////////////////////////////////////////////////////////////////////// // api-versions.xml generation, for public and system. This API database // also contains the android.test.* APIs. @@ -586,7 +901,6 @@ droidstubs { "metalava-manual", ], args: priv_apps, - visibility: ["//visibility:private"], } java_library { diff --git a/api/api.go b/api/api.go index 09c238336a39..692d38fe21a2 100644 --- a/api/api.go +++ b/api/api.go @@ -15,7 +15,9 @@ package api import ( + "fmt" "sort" + "strings" "github.com/google/blueprint/proptools" @@ -94,6 +96,7 @@ type libraryProps struct { Sdk_version *string Static_libs []string Visibility []string + Defaults []string } type fgProps struct { @@ -102,7 +105,16 @@ type fgProps struct { Visibility []string } +type defaultsProps struct { + Name *string + Api_surface *string + Api_contributions []string + Defaults_visibility []string + Previous_api *string +} + type Bazel_module struct { + Label *string Bp2build_available *bool } type bazelProperties struct { @@ -129,23 +141,27 @@ type MergedTxtDefinition struct { ModuleTag string // public, system, module-lib or system-server Scope string + // True if there is a bp2build definition for this module + Bp2buildDefined bool } func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { metalavaCmd := "$(location metalava)" // Silence reflection warnings. See b/168689341 metalavaCmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED " - metalavaCmd += " --quiet --no-banner --format=v2 " + metalavaCmd += " --quiet merge-signatures --format=v2 " filename := txt.TxtFilename if txt.Scope != "public" { filename = txt.Scope + "-" + filename } + moduleName := ctx.ModuleName() + "-" + filename + props := genruleProps{} - props.Name = proptools.StringPtr(ctx.ModuleName() + "-" + filename) + props.Name = proptools.StringPtr(moduleName) props.Tools = []string{"metalava"} props.Out = []string{filename} - props.Cmd = proptools.StringPtr(metalavaCmd + "$(in) --api $(out)") + props.Cmd = proptools.StringPtr(metalavaCmd + "$(in) --out $(out)") props.Srcs = append([]string{txt.BaseTxt}, createSrcs(txt.Modules, txt.ModuleTag)...) props.Dists = []android.Dist{ { @@ -160,30 +176,43 @@ func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { }, } props.Visibility = []string{"//visibility:public"} - ctx.CreateModule(genrule.GenRuleFactory, &props, &bp2buildNotAvailable) + bazelProps := bazelProperties{ + &Bazel_module{ + Bp2build_available: proptools.BoolPtr(false), + }, + } + if txt.Bp2buildDefined { + moduleDir := ctx.ModuleDir() + if moduleDir == android.Bp2BuildTopLevel { + moduleDir = "" + } + label := fmt.Sprintf("//%s:%s", moduleDir, moduleName) + bazelProps.Label = &label + } + ctx.CreateModule(genrule.GenRuleFactory, &props, &bazelProps) } func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, system_server_modules []string) { - for _, i := range []struct{ + for _, i := range []struct { name string tag string modules []string }{ { - name: "all-modules-public-annotations", - tag: "{.public.annotations.zip}", + name: "all-modules-public-annotations", + tag: "{.public.annotations.zip}", modules: modules, }, { - name: "all-modules-system-annotations", - tag: "{.system.annotations.zip}", + name: "all-modules-system-annotations", + tag: "{.system.annotations.zip}", modules: modules, }, { - name: "all-modules-module-lib-annotations", - tag: "{.module-lib.annotations.zip}", + name: "all-modules-module-lib-annotations", + tag: "{.module-lib.annotations.zip}", modules: modules, }, { - name: "all-modules-system-server-annotations", - tag: "{.system-server.annotations.zip}", + name: "all-modules-system-server-annotations", + tag: "{.system-server.annotations.zip}", modules: system_server_modules, }, } { @@ -290,38 +319,43 @@ func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_ tagSuffix := []string{".api.txt}", ".removed-api.txt}"} distFilename := []string{"android.txt", "android-removed.txt"} + bp2BuildDefined := []bool{true, false} for i, f := range []string{"current.txt", "removed.txt"} { textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-" + f, - Modules: bootclasspath, - ModuleTag: "{.public" + tagSuffix[i], - Scope: "public", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-" + f, + Modules: bootclasspath, + ModuleTag: "{.public" + tagSuffix[i], + Scope: "public", + Bp2buildDefined: bp2BuildDefined[i], }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-system-" + f, - Modules: bootclasspath, - ModuleTag: "{.system" + tagSuffix[i], - Scope: "system", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-system-" + f, + Modules: bootclasspath, + ModuleTag: "{.system" + tagSuffix[i], + Scope: "system", + Bp2buildDefined: bp2BuildDefined[i], }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-module-lib-" + f, - Modules: bootclasspath, - ModuleTag: "{.module-lib" + tagSuffix[i], - Scope: "module-lib", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-module-lib-" + f, + Modules: bootclasspath, + ModuleTag: "{.module-lib" + tagSuffix[i], + Scope: "module-lib", + Bp2buildDefined: bp2BuildDefined[i], }) textFiles = append(textFiles, MergedTxtDefinition{ - TxtFilename: f, - DistFilename: distFilename[i], - BaseTxt: ":non-updatable-system-server-" + f, - Modules: system_server_classpath, - ModuleTag: "{.system-server" + tagSuffix[i], - Scope: "system-server", + TxtFilename: f, + DistFilename: distFilename[i], + BaseTxt: ":non-updatable-system-server-" + f, + Modules: system_server_classpath, + ModuleTag: "{.system-server" + tagSuffix[i], + Scope: "system-server", + Bp2buildDefined: bp2BuildDefined[i], }) } for _, txt := range textFiles { @@ -329,6 +363,55 @@ 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.public.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_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"} + + ctx.CreateModule(java.LibraryFactory, &props) + } +} + func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { bootclasspath := a.properties.Bootclasspath system_server_classpath := a.properties.System_server_classpath @@ -347,6 +430,10 @@ func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { createMergedAnnotationsFilegroups(ctx, bootclasspath, system_server_classpath) createPublicStubsSourceFilegroup(ctx, bootclasspath) + + createApiContributionDefaults(ctx, bootclasspath) + + createFullApiLibraries(ctx) } func combinedApisModuleFactory() android.Module { @@ -365,7 +452,7 @@ type bazelCombinedApisAttributes struct { } // combined_apis bp2build converter -func (a *CombinedApis) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (a *CombinedApis) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { basePrefix := "non-updatable" scopeToSuffix := map[string]string{ "public": "-current.txt", @@ -374,7 +461,7 @@ func (a *CombinedApis) ConvertWithBp2build(ctx android.TopDownMutatorContext) { "system-server": "-system-server-current.txt", } - for scopeName, suffix := range scopeToSuffix{ + for scopeName, suffix := range scopeToSuffix { name := a.Name() + suffix var scope bazel.StringAttribute diff --git a/api/api_test.go b/api/api_test.go index 15b695ca0d36..70f2162348ad 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -19,6 +19,7 @@ import ( "android/soong/android" "android/soong/bp2build" + "android/soong/java" ) func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) { @@ -30,7 +31,11 @@ func runCombinedApisTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2build.Bp func runCombinedApisTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) { t.Helper() - runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {}) + runCombinedApisTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) { + ctx.RegisterModuleType("java_defaults", java.DefaultsFactory) + ctx.RegisterModuleType("java_sdk_library", java.SdkLibraryFactory) + ctx.RegisterModuleType("filegroup", android.FileGroupFactory) + }) } func TestCombinedApisGeneral(t *testing.T) { @@ -41,27 +46,69 @@ func TestCombinedApisGeneral(t *testing.T) { bootclasspath: ["bcp"], system_server_classpath: ["ssc"], } + +java_sdk_library { + name: "bcp", + srcs: ["a.java", "b.java"], + shared_library: false, +} +java_sdk_library { + name: "ssc", + srcs: ["a.java", "b.java"], + shared_library: false, +} +filegroup { + name: "non-updatable-current.txt", + srcs: ["current.txt"], +} +filegroup { + name: "non-updatable-system-current.txt", + srcs: ["system-current.txt"], +} +filegroup { + name: "non-updatable-module-lib-current.txt", + srcs: ["system-removed.txt"], +} +filegroup { + name: "non-updatable-system-server-current.txt", + srcs: ["system-lint-baseline.txt"], +} `, + Filesystem: map[string]string{ + "a/Android.bp": ` + java_defaults { + name: "android.jar_defaults", + } + `, + "api/current.txt": "", + "api/removed.txt": "", + "api/system-current.txt": "", + "api/system-removed.txt": "", + "api/test-current.txt": "", + "api/test-removed.txt": "", + }, + StubbedBuildDefinitions: []string{"bcp", "ssc", "non-updatable-current.txt", "non-updatable-system-current.txt", "non-updatable-module-lib-current.txt", "non-updatable-system-server-current.txt"}, + ExpectedHandcraftedModules: []string{"foo-current.txt", "foo-system-current.txt", "foo-module-lib-current.txt", "foo-system-server-current.txt"}, ExpectedBazelTargets: []string{ bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-current.txt", bp2build.AttrNameToString{ "scope": `"public"`, - "base": `":non-updatable-current.txt__BP2BUILD__MISSING__DEP"`, - "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`, + "base": `":non-updatable-current.txt"`, + "deps": `[":bcp"]`, }), bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-current.txt", bp2build.AttrNameToString{ "scope": `"system"`, - "base": `":non-updatable-system-current.txt__BP2BUILD__MISSING__DEP"`, - "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`, + "base": `":non-updatable-system-current.txt"`, + "deps": `[":bcp"]`, }), bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-module-lib-current.txt", bp2build.AttrNameToString{ "scope": `"module-lib"`, - "base": `":non-updatable-module-lib-current.txt__BP2BUILD__MISSING__DEP"`, - "deps": `[":bcp__BP2BUILD__MISSING__DEP"]`, + "base": `":non-updatable-module-lib-current.txt"`, + "deps": `[":bcp"]`, }), bp2build.MakeBazelTargetNoRestrictions("merged_txts", "foo-system-server-current.txt", bp2build.AttrNameToString{ "scope": `"system-server"`, - "base": `":non-updatable-system-server-current.txt__BP2BUILD__MISSING__DEP"`, - "deps": `[":ssc__BP2BUILD__MISSING__DEP"]`, + "base": `":non-updatable-system-server-current.txt"`, + "deps": `[":ssc"]`, }), }, }) diff --git a/api/gen_combined_removed_dex.sh b/api/gen_combined_removed_dex.sh index 9225fe8dfe85..71f366a6aae2 100755 --- a/api/gen_combined_removed_dex.sh +++ b/api/gen_combined_removed_dex.sh @@ -6,6 +6,6 @@ shift 2 # Convert each removed.txt to the "dex format" equivalent, and print all output. for f in "$@"; do - "$metalava_path" --no-banner "$f" --dex-api "${tmp_dir}/tmp" + "$metalava_path" "$f" --dex-api "${tmp_dir}/tmp" cat "${tmp_dir}/tmp" done diff --git a/api/go.mod b/api/go.mod new file mode 100644 index 000000000000..f8bb1c01cd96 --- /dev/null +++ b/api/go.mod @@ -0,0 +1,12 @@ +module android/soong/aidl + +go 1.18 + +require ( + android/soong v0.0.0 + github.com/google/blueprint v0.0.0 + google.golang.org/protobuf v0.0.0 + prebuilts/bazel/common/proto/analysis_v2 v0.0.0 + prebuilts/bazel/common/proto/build v0.0.0 + go.starlark.net v0.0.0 +) diff --git a/api/go.work b/api/go.work new file mode 100644 index 000000000000..aa2d2b1cb461 --- /dev/null +++ b/api/go.work @@ -0,0 +1,19 @@ +go 1.18 + +use ( + . + ../../../build/soong + ../../../build/blueprint + ../../../external/go-cmp + ../../../external/golang-protobuf +) + +replace ( + android/soong v0.0.0 => ../../../build/soong + google.golang.org/protobuf v0.0.0 => ../../../external/golang-protobuf + github.com/google/blueprint v0.0.0 => ../../../build/blueprint + github.com/google/go-cmp v0.0.0 => ../../../external/go-cmp + prebuilts/bazel/common/proto/analysis_v2 v0.0.0 => ../../../prebuilts/bazel/common/proto/analysis_v2 + prebuilts/bazel/common/proto/build v0.0.0 => ../../../prebuilts/bazel/common/proto/build + go.starlark.net v0.0.0 => ../../../external/starlark-go +) diff --git a/api/go.work.sum b/api/go.work.sum new file mode 100644 index 000000000000..d00184fa2aa5 --- /dev/null +++ b/api/go.work.sum @@ -0,0 +1,66 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/api/javadoc-lint-baseline b/api/javadoc-lint-baseline new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/api/javadoc-lint-baseline |