diff options
Diffstat (limited to 'api')
| -rw-r--r-- | api/StubLibraries.bp | 58 | ||||
| -rw-r--r-- | api/api.go | 55 |
2 files changed, 96 insertions, 17 deletions
diff --git a/api/StubLibraries.bp b/api/StubLibraries.bp index f08745b5cd2c..93d20dd199bf 100644 --- a/api/StubLibraries.bp +++ b/api/StubLibraries.bp @@ -213,7 +213,6 @@ java_defaults { system_modules: "none", java_version: "1.8", compile_dex: true, - defaults_visibility: ["//visibility:private"], visibility: ["//visibility:public"], } @@ -230,8 +229,6 @@ java_defaults { tag: ".jar", dest: "android-non-updatable.jar", }, - defaults_visibility: ["//visibility:private"], - visibility: ["//visibility:private"], } java_library { @@ -283,6 +280,57 @@ java_library { } java_defaults { + name: "non_updatable_api_library_defaults", + static_libs: ["framework-res-package-jar"], + libs: ["stub-annotations"], +} + +java_api_library { + name: "android-non-updatable.stubs.from-text", + api_surface: "public", + api_files: [ + ":non-updatable-current.txt", + ], + defaults: ["non_updatable_api_library_defaults"], + dep_api_srcs: "android_stubs_current.from-text", +} + +java_api_library { + name: "android-non-updatable.stubs.system.from-text", + api_surface: "system", + api_files: [ + ":non-updatable-current.txt", + ":non-updatable-system-current.txt", + ], + defaults: ["non_updatable_api_library_defaults"], + dep_api_srcs: "android_system_stubs_current.from-text", +} + +java_api_library { + name: "android-non-updatable.stubs.test.from-text", + api_surface: "test", + api_files: [ + ":non-updatable-current.txt", + ":non-updatable-system-current.txt", + ":non-updatable-test-current.txt", + ], + defaults: ["non_updatable_api_library_defaults"], + dep_api_srcs: "android_test_stubs_current.from-text", +} + +java_api_library { + name: "android-non-updatable.stubs.module_lib.from-text", + api_surface: "module_lib", + api_files: [ + ":non-updatable-current.txt", + ":non-updatable-system-current.txt", + ":non-updatable-module-lib-current.txt", + ], + defaults: ["non_updatable_api_library_defaults"], + dep_api_srcs: "android_module_lib_stubs_current_full.from-text", +} + +java_defaults { name: "android_stubs_dists_default", dist: { targets: ["sdk"], @@ -402,7 +450,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 +458,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 +468,6 @@ java_library { java_genrule { name: "android_stubs_private_framework_aidl", - visibility: ["//visibility:private"], tools: ["sdkparcelables"], srcs: [":android_stubs_private"], out: ["framework.aidl"], @@ -586,7 +631,6 @@ droidstubs { "metalava-manual", ], args: priv_apps, - visibility: ["//visibility:private"], } java_library { diff --git a/api/api.go b/api/api.go index 09c238336a39..af817b5666cd 100644 --- a/api/api.go +++ b/api/api.go @@ -15,7 +15,9 @@ package api import ( + "fmt" "sort" + "strings" "github.com/google/blueprint/proptools" @@ -102,6 +104,13 @@ type fgProps struct { Visibility []string } +type defaultsProps struct { + Name *string + Api_surface *string + Api_contributions []string + Defaults_visibility []string +} + type Bazel_module struct { Bp2build_available *bool } @@ -164,26 +173,26 @@ func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) { } 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, }, } { @@ -329,6 +338,30 @@ 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"} + ctx.CreateModule(java.DefaultsFactory, &props) + } +} + func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { bootclasspath := a.properties.Bootclasspath system_server_classpath := a.properties.System_server_classpath @@ -347,6 +380,8 @@ func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) { createMergedAnnotationsFilegroups(ctx, bootclasspath, system_server_classpath) createPublicStubsSourceFilegroup(ctx, bootclasspath) + + createApiContributionDefaults(ctx, bootclasspath) } func combinedApisModuleFactory() android.Module { @@ -374,7 +409,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 |