diff options
author | 2025-01-24 18:27:07 +0000 | |
---|---|---|
committer | 2025-01-24 22:30:47 +0000 | |
commit | d01f0b2c72c1a5160653e47ba68f56105212cc73 (patch) | |
tree | f3c002ea4f6795228ce6f3eb0848539754e5d310 /java/sdk_library_internal.go | |
parent | 68548906d74db932966a272afb82332c543386f8 (diff) |
Allow java_sdk_library to override the droidstubs api_surface per scope
Previously, every `java_sdk_library` would create a `droidstubs` module
passing in the name of the `apiScope` as the `api_surface` property.
e.g. the `public` scope was always called `public`, etc. While that
works for the vast majority of `java_sdk_library` modules there are a
few in `libcore`, `external/conscrypt` and `external/icu` which create
`public` scope APIs but which are not actually `public`. e.g. libcore
creates `intra-core` APIs, conscrypt and icu also create
`core-platform` APIs. They are different from `public` in the
annotations that they pass to Metalava.
A future change will pass the `api_surface` property down to Metalava
and that will be used to retrieve a corresponding configuration from
`build/soong/java/metalava/main-config.xml`. That configuration will
include the annotations. Therefore, each set of annotations that are
passed will need a unique name.
This change allows the `api_surface` for the default `public` scope
to be overridden to select the correct `api_surface` in the
configuration.
Bug: 391554590
Test: m checkapi
Change-Id: Iaa2c8325f0ffae2daf77201abe4e77c919528ad3
Diffstat (limited to 'java/sdk_library_internal.go')
-rw-r--r-- | java/sdk_library_internal.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/java/sdk_library_internal.go b/java/sdk_library_internal.go index ec9c160ea..db9cd24ce 100644 --- a/java/sdk_library_internal.go +++ b/java/sdk_library_internal.go @@ -174,6 +174,20 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) mctx.CreateModule(LibraryFactory, properties...) } +// getApiSurfaceForScope returns the api surface name to use for the apiScope. If one is specified +// in the corresponding ApiScopeProperties.Api_surface property that is used, otherwise the name of +// the apiScope is used. +func (module *SdkLibrary) getApiSurfaceForScope(apiScope *apiScope) *string { + scopeProperties := module.scopeToProperties[apiScope] + + apiSurface := scopeProperties.Api_surface + if apiSurface == nil { + apiSurface = &apiScope.name + } + + return apiSurface +} + // Creates the [Droidstubs] module with ".stubs.source.<[apiScope.name]>" that creates stubs // source files from the given full source files and also updates and checks the API // specification files (i.e. "*-current.txt", "*-removed.txt" files). @@ -227,7 +241,7 @@ func (module *SdkLibrary) createDroidstubs(mctx android.DefaultableHookContext, props.Srcs = append(props.Srcs, module.properties.Srcs...) props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...) props.Sdk_version = module.deviceProperties.Sdk_version - props.Api_surface = &apiScope.name + props.Api_surface = module.getApiSurfaceForScope(apiScope) props.System_modules = module.deviceProperties.System_modules props.Installable = proptools.BoolPtr(false) // A droiddoc module has only one Libs property and doesn't distinguish between |