Merge "Support using java_sdk_library components in stub_libs"
This commit is contained in:
@@ -197,7 +197,7 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
core_platform_api: {
|
core_platform_api: {
|
||||||
stub_libs: ["mycoreplatform"],
|
stub_libs: ["mycoreplatform.stubs"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -586,6 +586,13 @@ type StubDexJarsByModule map[string]ModuleStubDexJars
|
|||||||
// addStubDexJar adds a stub dex jar path provided by the specified module for the specified scope.
|
// addStubDexJar adds a stub dex jar path provided by the specified module for the specified scope.
|
||||||
func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module android.Module, scope *HiddenAPIScope, stubDexJar android.Path) {
|
func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module android.Module, scope *HiddenAPIScope, stubDexJar android.Path) {
|
||||||
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
|
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
|
||||||
|
|
||||||
|
// Each named module provides one dex jar for each scope. However, in some cases different API
|
||||||
|
// versions of a single classes are provided by separate modules. e.g. the core platform
|
||||||
|
// version of java.lang.Object is provided by the legacy.art.module.platform.api module but the
|
||||||
|
// public version is provided by the art.module.public.api module. In those cases it is necessary
|
||||||
|
// to treat all those modules as they were the same name, otherwise it will result in multiple
|
||||||
|
// definitions of a single class being passed to hidden API processing which will cause an error.
|
||||||
if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule {
|
if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule {
|
||||||
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
|
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
|
||||||
// java_sdk_library.
|
// java_sdk_library.
|
||||||
@@ -606,6 +613,14 @@ func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module and
|
|||||||
// conscrypt.module.public.api java_sdk_library which will be the case once the former has been
|
// conscrypt.module.public.api java_sdk_library which will be the case once the former has been
|
||||||
// migrated to a module_lib API.
|
// migrated to a module_lib API.
|
||||||
name = "conscrypt.module.public.api"
|
name = "conscrypt.module.public.api"
|
||||||
|
} else if d, ok := module.(SdkLibraryComponentDependency); ok {
|
||||||
|
sdkLibraryName := d.SdkLibraryName()
|
||||||
|
if sdkLibraryName != nil {
|
||||||
|
// The module is a component of a java_sdk_library so use the name of the java_sdk_library.
|
||||||
|
// e.g. if this module is `foo.system.stubs` and is part of the `foo` java_sdk_library then
|
||||||
|
// use `foo` as the name.
|
||||||
|
name = *sdkLibraryName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stubDexJarsByScope := s[name]
|
stubDexJarsByScope := s[name]
|
||||||
if stubDexJarsByScope == nil {
|
if stubDexJarsByScope == nil {
|
||||||
|
@@ -675,10 +675,13 @@ func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namePtr := proptools.StringPtr(c.module.BaseModuleName())
|
||||||
|
c.sdkLibraryComponentProperties.SdkLibraryName = namePtr
|
||||||
|
|
||||||
// Only track this sdk library if this can be used as a shared library.
|
// Only track this sdk library if this can be used as a shared library.
|
||||||
if c.sharedLibrary() {
|
if c.sharedLibrary() {
|
||||||
// Use the name specified in the module definition as the owner.
|
// Use the name specified in the module definition as the owner.
|
||||||
c.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack = proptools.StringPtr(c.module.BaseModuleName())
|
c.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack = namePtr
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@@ -922,15 +925,19 @@ func (c *commonToSdkLibraryAndImport) SdkRemovedTxtFile(ctx android.BaseModuleCo
|
|||||||
|
|
||||||
func (c *commonToSdkLibraryAndImport) sdkComponentPropertiesForChildLibrary() interface{} {
|
func (c *commonToSdkLibraryAndImport) sdkComponentPropertiesForChildLibrary() interface{} {
|
||||||
componentProps := &struct {
|
componentProps := &struct {
|
||||||
|
SdkLibraryName *string
|
||||||
SdkLibraryToImplicitlyTrack *string
|
SdkLibraryToImplicitlyTrack *string
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
|
namePtr := proptools.StringPtr(c.module.BaseModuleName())
|
||||||
|
componentProps.SdkLibraryName = namePtr
|
||||||
|
|
||||||
if c.sharedLibrary() {
|
if c.sharedLibrary() {
|
||||||
// Mark the stubs library as being components of this java_sdk_library so that
|
// Mark the stubs library as being components of this java_sdk_library so that
|
||||||
// any app that includes code which depends (directly or indirectly) on the stubs
|
// any app that includes code which depends (directly or indirectly) on the stubs
|
||||||
// library will have the appropriate <uses-library> invocation inserted into its
|
// library will have the appropriate <uses-library> invocation inserted into its
|
||||||
// manifest if necessary.
|
// manifest if necessary.
|
||||||
componentProps.SdkLibraryToImplicitlyTrack = proptools.StringPtr(c.module.BaseModuleName())
|
componentProps.SdkLibraryToImplicitlyTrack = namePtr
|
||||||
}
|
}
|
||||||
|
|
||||||
return componentProps
|
return componentProps
|
||||||
@@ -949,6 +956,8 @@ func (c *commonToSdkLibraryAndImport) stubLibrariesCompiledForDex() bool {
|
|||||||
|
|
||||||
// Properties related to the use of a module as an component of a java_sdk_library.
|
// Properties related to the use of a module as an component of a java_sdk_library.
|
||||||
type SdkLibraryComponentProperties struct {
|
type SdkLibraryComponentProperties struct {
|
||||||
|
// The name of the java_sdk_library/_import module.
|
||||||
|
SdkLibraryName *string `blueprint:"mutated"`
|
||||||
|
|
||||||
// The name of the java_sdk_library/_import to add to a <uses-library> entry
|
// The name of the java_sdk_library/_import to add to a <uses-library> entry
|
||||||
// in the AndroidManifest.xml of any Android app that includes code that references
|
// in the AndroidManifest.xml of any Android app that includes code that references
|
||||||
@@ -966,6 +975,11 @@ func (e *EmbeddableSdkLibraryComponent) initSdkLibraryComponent(module android.M
|
|||||||
module.AddProperties(&e.sdkLibraryComponentProperties)
|
module.AddProperties(&e.sdkLibraryComponentProperties)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to satisfy SdkLibraryComponentDependency
|
||||||
|
func (e *EmbeddableSdkLibraryComponent) SdkLibraryName() *string {
|
||||||
|
return e.sdkLibraryComponentProperties.SdkLibraryName
|
||||||
|
}
|
||||||
|
|
||||||
// to satisfy SdkLibraryComponentDependency
|
// to satisfy SdkLibraryComponentDependency
|
||||||
func (e *EmbeddableSdkLibraryComponent) OptionalImplicitSdkLibrary() *string {
|
func (e *EmbeddableSdkLibraryComponent) OptionalImplicitSdkLibrary() *string {
|
||||||
return e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack
|
return e.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack
|
||||||
@@ -982,6 +996,9 @@ func (e *EmbeddableSdkLibraryComponent) OptionalSdkLibraryImplementation() *stri
|
|||||||
type SdkLibraryComponentDependency interface {
|
type SdkLibraryComponentDependency interface {
|
||||||
UsesLibraryDependency
|
UsesLibraryDependency
|
||||||
|
|
||||||
|
// SdkLibraryName returns the name of the java_sdk_library/_import module.
|
||||||
|
SdkLibraryName() *string
|
||||||
|
|
||||||
// The optional name of the sdk library that should be implicitly added to the
|
// The optional name of the sdk library that should be implicitly added to the
|
||||||
// AndroidManifest of an app that contains code which references the sdk library.
|
// AndroidManifest of an app that contains code which references the sdk library.
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user