Revert "java_sdk_library: Control shared library use"
This reverts commit e6428b4892
.
Reason for revert: Broke presubmit: b/157231582
Change-Id: I176f9940dfa7bef74cdb450774c7d09c2f6b4007
This commit is contained in:
@@ -1157,16 +1157,6 @@ func TestJavaSdkLibrary(t *testing.T) {
|
|||||||
libs: ["foo", "bar.stubs"],
|
libs: ["foo", "bar.stubs"],
|
||||||
sdk_version: "system_current",
|
sdk_version: "system_current",
|
||||||
}
|
}
|
||||||
java_sdk_library {
|
|
||||||
name: "barney",
|
|
||||||
srcs: ["c.java"],
|
|
||||||
api_only: true,
|
|
||||||
}
|
|
||||||
java_sdk_library {
|
|
||||||
name: "betty",
|
|
||||||
srcs: ["c.java"],
|
|
||||||
shared_library: false,
|
|
||||||
}
|
|
||||||
java_sdk_library_import {
|
java_sdk_library_import {
|
||||||
name: "quuz",
|
name: "quuz",
|
||||||
public: {
|
public: {
|
||||||
@@ -1179,17 +1169,10 @@ func TestJavaSdkLibrary(t *testing.T) {
|
|||||||
jars: ["b.jar"],
|
jars: ["b.jar"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
java_sdk_library_import {
|
|
||||||
name: "wilma",
|
|
||||||
public: {
|
|
||||||
jars: ["b.jar"],
|
|
||||||
},
|
|
||||||
shared_library: false,
|
|
||||||
}
|
|
||||||
java_library {
|
java_library {
|
||||||
name: "qux",
|
name: "qux",
|
||||||
srcs: ["c.java"],
|
srcs: ["c.java"],
|
||||||
libs: ["baz", "fred", "quuz.stubs", "wilma", "barney", "betty"],
|
libs: ["baz", "fred", "quuz.stubs"],
|
||||||
sdk_version: "system_current",
|
sdk_version: "system_current",
|
||||||
}
|
}
|
||||||
java_library {
|
java_library {
|
||||||
|
@@ -372,10 +372,7 @@ type sdkLibraryProperties struct {
|
|||||||
// Defaults to "api".
|
// Defaults to "api".
|
||||||
Api_dir *string
|
Api_dir *string
|
||||||
|
|
||||||
// Determines whether a runtime implementation library is built; defaults to false.
|
// If set to true there is no runtime library.
|
||||||
//
|
|
||||||
// If true then it also prevents the module from being used as a shared module, i.e.
|
|
||||||
// it is as is shared_library: false, was set.
|
|
||||||
Api_only *bool
|
Api_only *bool
|
||||||
|
|
||||||
// local files that are used within user customized droiddoc options.
|
// local files that are used within user customized droiddoc options.
|
||||||
@@ -535,13 +532,6 @@ type commonToSdkLibraryAndImportProperties struct {
|
|||||||
//
|
//
|
||||||
// TODO(b/155480189) - Remove once naming inconsistencies have been resolved.
|
// TODO(b/155480189) - Remove once naming inconsistencies have been resolved.
|
||||||
Naming_scheme *string
|
Naming_scheme *string
|
||||||
|
|
||||||
// Specifies whether this module can be used as an Android shared library; defaults
|
|
||||||
// to true.
|
|
||||||
//
|
|
||||||
// An Android shared library is one that can be referenced in a <uses-library> element
|
|
||||||
// in an AndroidManifest.xml.
|
|
||||||
Shared_library *bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common code between sdk library and sdk library import
|
// Common code between sdk library and sdk library import
|
||||||
@@ -552,7 +542,7 @@ type commonToSdkLibraryAndImport struct {
|
|||||||
|
|
||||||
namingScheme sdkLibraryComponentNamingScheme
|
namingScheme sdkLibraryComponentNamingScheme
|
||||||
|
|
||||||
commonSdkLibraryProperties commonToSdkLibraryAndImportProperties
|
commonProperties commonToSdkLibraryAndImportProperties
|
||||||
|
|
||||||
// Functionality related to this being used as a component of a java_sdk_library.
|
// Functionality related to this being used as a component of a java_sdk_library.
|
||||||
EmbeddableSdkLibraryComponent
|
EmbeddableSdkLibraryComponent
|
||||||
@@ -561,14 +551,14 @@ type commonToSdkLibraryAndImport struct {
|
|||||||
func (c *commonToSdkLibraryAndImport) initCommon(moduleBase *android.ModuleBase) {
|
func (c *commonToSdkLibraryAndImport) initCommon(moduleBase *android.ModuleBase) {
|
||||||
c.moduleBase = moduleBase
|
c.moduleBase = moduleBase
|
||||||
|
|
||||||
moduleBase.AddProperties(&c.commonSdkLibraryProperties)
|
moduleBase.AddProperties(&c.commonProperties)
|
||||||
|
|
||||||
// Initialize this as an sdk library component.
|
// Initialize this as an sdk library component.
|
||||||
c.initSdkLibraryComponent(moduleBase)
|
c.initSdkLibraryComponent(moduleBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android.DefaultableHookContext) bool {
|
func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android.DefaultableHookContext) bool {
|
||||||
schemeProperty := proptools.StringDefault(c.commonSdkLibraryProperties.Naming_scheme, "default")
|
schemeProperty := proptools.StringDefault(c.commonProperties.Naming_scheme, "default")
|
||||||
switch schemeProperty {
|
switch schemeProperty {
|
||||||
case "default":
|
case "default":
|
||||||
c.namingScheme = &defaultNamingScheme{}
|
c.namingScheme = &defaultNamingScheme{}
|
||||||
@@ -579,11 +569,8 @@ func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only track this sdk library if this can be used as a shared library.
|
// Use the name specified in the module definition as the owner.
|
||||||
if c.sharedLibrary() {
|
c.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack = proptools.StringPtr(c.moduleBase.BaseModuleName())
|
||||||
// Use the name specified in the module definition as the owner.
|
|
||||||
c.sdkLibraryComponentProperties.SdkLibraryToImplicitlyTrack = proptools.StringPtr(c.moduleBase.BaseModuleName())
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -753,24 +740,17 @@ func (c *commonToSdkLibraryAndImport) selectHeaderJarsForSdkVersion(ctx android.
|
|||||||
func (c *commonToSdkLibraryAndImport) sdkComponentPropertiesForChildLibrary() interface{} {
|
func (c *commonToSdkLibraryAndImport) sdkComponentPropertiesForChildLibrary() interface{} {
|
||||||
componentProps := &struct {
|
componentProps := &struct {
|
||||||
SdkLibraryToImplicitlyTrack *string
|
SdkLibraryToImplicitlyTrack *string
|
||||||
}{}
|
}{
|
||||||
|
|
||||||
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.moduleBase.BaseModuleName())
|
SdkLibraryToImplicitlyTrack: proptools.StringPtr(c.moduleBase.BaseModuleName()),
|
||||||
}
|
}
|
||||||
|
|
||||||
return componentProps
|
return componentProps
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this can be used as a shared library.
|
|
||||||
func (c *commonToSdkLibraryAndImport) sharedLibrary() bool {
|
|
||||||
return proptools.BoolDefault(c.commonSdkLibraryProperties.Shared_library, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|
||||||
@@ -927,15 +907,12 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
||||||
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())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only add the deps for the library if it is actually going to be built.
|
|
||||||
module.Library.deps(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.Library.deps(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
||||||
@@ -948,8 +925,8 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
// Only build an implementation library if required.
|
// Don't build an implementation library if this is api only.
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
||||||
module.Library.GenerateAndroidBuildActions(ctx)
|
module.Library.GenerateAndroidBuildActions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -972,7 +949,7 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
|
||||||
if !module.requiresRuntimeImplementationLibrary() {
|
if proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
entriesList := module.Library.AndroidMkEntries()
|
entriesList := module.Library.AndroidMkEntries()
|
||||||
@@ -1410,12 +1387,9 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
|
|||||||
module.createStubsLibrary(mctx, scope)
|
module.createStubsLibrary(mctx, scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
|
||||||
// Only create an XML permissions file that declares the library as being usable
|
// for runtime
|
||||||
// as a shared library if required.
|
module.createXmlFile(mctx)
|
||||||
if module.sharedLibrary() {
|
|
||||||
module.createXmlFile(mctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// record java_sdk_library modules so that they are exported to make
|
// record java_sdk_library modules so that they are exported to make
|
||||||
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
javaSdkLibraries := javaSdkLibraries(mctx.Config())
|
||||||
@@ -1440,10 +1414,6 @@ func (module *SdkLibrary) InitSdkLibraryProperties() {
|
|||||||
module.deviceProperties.IsSDKLibrary = true
|
module.deviceProperties.IsSDKLibrary = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) requiresRuntimeImplementationLibrary() bool {
|
|
||||||
return !proptools.Bool(module.sdkLibraryProperties.Api_only)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defines how to name the individual component modules the sdk library creates.
|
// Defines how to name the individual component modules the sdk library creates.
|
||||||
type sdkLibraryComponentNamingScheme interface {
|
type sdkLibraryComponentNamingScheme interface {
|
||||||
stubsLibraryModuleName(scope *apiScope, baseName string) string
|
stubsLibraryModuleName(scope *apiScope, baseName string) string
|
||||||
@@ -1522,18 +1492,6 @@ func SdkLibraryFactory() android.Module {
|
|||||||
android.AddVisibilityProperty(module, "stubs_source_visibility", &module.sdkLibraryProperties.Stubs_source_visibility)
|
android.AddVisibilityProperty(module, "stubs_source_visibility", &module.sdkLibraryProperties.Stubs_source_visibility)
|
||||||
|
|
||||||
module.SetDefaultableHook(func(ctx android.DefaultableHookContext) {
|
module.SetDefaultableHook(func(ctx android.DefaultableHookContext) {
|
||||||
// If no implementation is required then it cannot be used as a shared library
|
|
||||||
// either.
|
|
||||||
if !module.requiresRuntimeImplementationLibrary() {
|
|
||||||
// If shared_library has been explicitly set to true then it is incompatible
|
|
||||||
// with api_only: true.
|
|
||||||
if proptools.Bool(module.commonSdkLibraryProperties.Shared_library) {
|
|
||||||
ctx.PropertyErrorf("api_only/shared_library", "inconsistent settings, shared_library and api_only cannot both be true")
|
|
||||||
}
|
|
||||||
// Set shared_library: false.
|
|
||||||
module.commonSdkLibraryProperties.Shared_library = proptools.BoolPtr(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
if module.initCommonAfterDefaultsApplied(ctx) {
|
if module.initCommonAfterDefaultsApplied(ctx) {
|
||||||
module.CreateInternalModules(ctx)
|
module.CreateInternalModules(ctx)
|
||||||
}
|
}
|
||||||
@@ -1958,7 +1916,7 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.Libs = sdk.properties.Libs
|
s.Libs = sdk.properties.Libs
|
||||||
s.Naming_scheme = sdk.commonSdkLibraryProperties.Naming_scheme
|
s.Naming_scheme = sdk.commonProperties.Naming_scheme
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
||||||
|
Reference in New Issue
Block a user