java_sdk_library: Specify visibility of stubs modules
Adds two new properties to specify the visibility of the stubs modules (source and library) created by the java_sdk_library. Excludes visibility property from being inherited when creating the module so it can be properly specified by copying across the relevant property. Test: m checkapi Bug: 155164730 Change-Id: Iffdd9f191ff0d74646356ac577560cc38efdd790
This commit is contained in:
parent
f49f431c33
commit
4911a89181
|
@ -257,6 +257,14 @@ type ApiScopeProperties struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type sdkLibraryProperties struct {
|
type sdkLibraryProperties struct {
|
||||||
|
// Visibility for stubs library modules. If not specified then defaults to the
|
||||||
|
// visibility property.
|
||||||
|
Stubs_library_visibility []string
|
||||||
|
|
||||||
|
// Visibility for stubs source modules. If not specified then defaults to the
|
||||||
|
// visibility property.
|
||||||
|
Stubs_source_visibility []string
|
||||||
|
|
||||||
// List of Java libraries that will be in the classpath when building stubs
|
// List of Java libraries that will be in the classpath when building stubs
|
||||||
Stub_only_libs []string `android:"arch_variant"`
|
Stub_only_libs []string `android:"arch_variant"`
|
||||||
|
|
||||||
|
@ -551,6 +559,7 @@ func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) stri
|
||||||
func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Visibility []string
|
||||||
Srcs []string
|
Srcs []string
|
||||||
Installable *bool
|
Installable *bool
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
@ -581,6 +590,12 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(module.stubsName(apiScope))
|
props.Name = proptools.StringPtr(module.stubsName(apiScope))
|
||||||
|
|
||||||
|
// If stubs_library_visibility is not set then the created module will use the
|
||||||
|
// visibility of this module.
|
||||||
|
visibility := module.sdkLibraryProperties.Stubs_library_visibility
|
||||||
|
props.Visibility = visibility
|
||||||
|
|
||||||
// sources are generated from the droiddoc
|
// sources are generated from the droiddoc
|
||||||
props.Srcs = []string{":" + module.docsName(apiScope)}
|
props.Srcs = []string{":" + module.docsName(apiScope)}
|
||||||
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
|
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
|
||||||
|
@ -622,6 +637,7 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
|
||||||
func (module *SdkLibrary) createStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
func (module *SdkLibrary) createStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
|
Visibility []string
|
||||||
Srcs []string
|
Srcs []string
|
||||||
Installable *bool
|
Installable *bool
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
@ -655,6 +671,12 @@ func (module *SdkLibrary) createStubsSources(mctx android.DefaultableHookContext
|
||||||
// * libs (static_libs/libs)
|
// * libs (static_libs/libs)
|
||||||
|
|
||||||
props.Name = proptools.StringPtr(module.docsName(apiScope))
|
props.Name = proptools.StringPtr(module.docsName(apiScope))
|
||||||
|
|
||||||
|
// If stubs_source_visibility is not set then the created module will use the
|
||||||
|
// visibility of this module.
|
||||||
|
visibility := module.sdkLibraryProperties.Stubs_source_visibility
|
||||||
|
props.Visibility = visibility
|
||||||
|
|
||||||
props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
|
props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
|
||||||
props.Sdk_version = module.Library.Module.deviceProperties.Sdk_version
|
props.Sdk_version = module.Library.Module.deviceProperties.Sdk_version
|
||||||
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
props.System_modules = module.Library.Module.deviceProperties.System_modules
|
||||||
|
@ -958,6 +980,10 @@ func SdkLibraryFactory() android.Module {
|
||||||
}
|
}
|
||||||
module.scopeToProperties = scopeToProperties
|
module.scopeToProperties = scopeToProperties
|
||||||
|
|
||||||
|
// Add the properties containing visibility rules so that they are checked.
|
||||||
|
android.AddVisibilityProperty(module, "stubs_library_visibility", &module.sdkLibraryProperties.Stubs_library_visibility)
|
||||||
|
android.AddVisibilityProperty(module, "stubs_source_visibility", &module.sdkLibraryProperties.Stubs_source_visibility)
|
||||||
|
|
||||||
module.SetDefaultableHook(func(ctx android.DefaultableHookContext) { module.CreateInternalModules(ctx) })
|
module.SetDefaultableHook(func(ctx android.DefaultableHookContext) { module.CreateInternalModules(ctx) })
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
|
@ -989,6 +989,8 @@ func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
|
||||||
apex_available: ["//apex_available:anyapex"],
|
apex_available: ["//apex_available:anyapex"],
|
||||||
srcs: ["Test.java"],
|
srcs: ["Test.java"],
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
|
stubs_library_visibility: ["//other"],
|
||||||
|
stubs_source_visibility: ["//another"],
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue