Merge "java_sdk_library: Create separate impl library"
This commit is contained in:
commit
b1e61be41d
|
@ -348,6 +348,10 @@ type ApiScopeProperties struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type sdkLibraryProperties struct {
|
type sdkLibraryProperties struct {
|
||||||
|
// Visibility for impl library module. If not specified then defaults to the
|
||||||
|
// visibility property.
|
||||||
|
Impl_library_visibility []string
|
||||||
|
|
||||||
// Visibility for stubs library modules. If not specified then defaults to the
|
// Visibility for stubs library modules. If not specified then defaults to the
|
||||||
// visibility property.
|
// visibility property.
|
||||||
Stubs_library_visibility []string
|
Stubs_library_visibility []string
|
||||||
|
@ -910,6 +914,8 @@ func IsXmlPermissionsFileDepTag(depTag blueprint.DependencyTag) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var implLibraryTag = dependencyTag{name: "impl-library"}
|
||||||
|
|
||||||
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
for _, apiScope := range module.getGeneratedApiScopes(ctx) {
|
for _, apiScope := range module.getGeneratedApiScopes(ctx) {
|
||||||
// Add dependencies to the stubs library
|
// Add dependencies to the stubs library
|
||||||
|
@ -928,6 +934,9 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
|
// Add dependency to the rule for generating the implementation library.
|
||||||
|
ctx.AddDependency(module, implLibraryTag, module.implLibraryModuleName())
|
||||||
|
|
||||||
if module.sharedLibrary() {
|
if module.sharedLibrary() {
|
||||||
// Add dependency to the rule for generating the xml permissions file
|
// Add dependency to the rule for generating the xml permissions file
|
||||||
ctx.AddDependency(module, xmlPermissionsFileTag, module.xmlFileName())
|
ctx.AddDependency(module, xmlPermissionsFileTag, module.xmlFileName())
|
||||||
|
@ -982,8 +991,8 @@ func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module name of the runtime implementation library
|
// Module name of the runtime implementation library
|
||||||
func (module *SdkLibrary) implName() string {
|
func (module *SdkLibrary) implLibraryModuleName() string {
|
||||||
return module.BaseModuleName()
|
return module.BaseModuleName() + ".impl"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module name of the XML file for the lib
|
// Module name of the XML file for the lib
|
||||||
|
@ -1027,6 +1036,27 @@ func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) stri
|
||||||
return ":" + module.BaseModuleName() + "-removed.api." + apiScope.name + ".latest"
|
return ":" + module.BaseModuleName() + "-removed.api." + apiScope.name + ".latest"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates the implementation java library
|
||||||
|
func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) {
|
||||||
|
props := struct {
|
||||||
|
Name *string
|
||||||
|
Visibility []string
|
||||||
|
}{
|
||||||
|
Name: proptools.StringPtr(module.implLibraryModuleName()),
|
||||||
|
Visibility: module.sdkLibraryProperties.Impl_library_visibility,
|
||||||
|
}
|
||||||
|
|
||||||
|
properties := []interface{}{
|
||||||
|
&module.properties,
|
||||||
|
&module.protoProperties,
|
||||||
|
&module.deviceProperties,
|
||||||
|
&module.dexpreoptProperties,
|
||||||
|
&props,
|
||||||
|
module.sdkComponentPropertiesForChildLibrary(),
|
||||||
|
}
|
||||||
|
mctx.CreateModule(LibraryFactory, properties...)
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a static java library that has API stubs
|
// Creates a static java library that has API stubs
|
||||||
func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
props := struct {
|
props := struct {
|
||||||
|
@ -1434,6 +1464,14 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
|
||||||
}
|
}
|
||||||
|
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
|
// Create child module to create an implementation library.
|
||||||
|
//
|
||||||
|
// This temporarily creates a second implementation library that can be explicitly
|
||||||
|
// referenced.
|
||||||
|
//
|
||||||
|
// TODO(b/156618935) - update comment once only one implementation library is created.
|
||||||
|
module.createImplLibrary(mctx)
|
||||||
|
|
||||||
// Only create an XML permissions file that declares the library as being usable
|
// Only create an XML permissions file that declares the library as being usable
|
||||||
// as a shared library if required.
|
// as a shared library if required.
|
||||||
if module.sharedLibrary() {
|
if module.sharedLibrary() {
|
||||||
|
@ -1541,6 +1579,7 @@ func SdkLibraryFactory() android.Module {
|
||||||
module.scopeToProperties = scopeToProperties
|
module.scopeToProperties = scopeToProperties
|
||||||
|
|
||||||
// Add the properties containing visibility rules so that they are checked.
|
// Add the properties containing visibility rules so that they are checked.
|
||||||
|
android.AddVisibilityProperty(module, "impl_library_visibility", &module.sdkLibraryProperties.Impl_library_visibility)
|
||||||
android.AddVisibilityProperty(module, "stubs_library_visibility", &module.sdkLibraryProperties.Stubs_library_visibility)
|
android.AddVisibilityProperty(module, "stubs_library_visibility", &module.sdkLibraryProperties.Stubs_library_visibility)
|
||||||
android.AddVisibilityProperty(module, "stubs_source_visibility", &module.sdkLibraryProperties.Stubs_source_visibility)
|
android.AddVisibilityProperty(module, "stubs_source_visibility", &module.sdkLibraryProperties.Stubs_source_visibility)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue