Merge "Make licenseModule SdkAware"
This commit is contained in:
@@ -51,6 +51,7 @@ type licenseProperties struct {
|
|||||||
type licenseModule struct {
|
type licenseModule struct {
|
||||||
ModuleBase
|
ModuleBase
|
||||||
DefaultableModuleBase
|
DefaultableModuleBase
|
||||||
|
SdkBase
|
||||||
|
|
||||||
properties licenseProperties
|
properties licenseProperties
|
||||||
}
|
}
|
||||||
@@ -75,6 +76,7 @@ func LicenseFactory() Module {
|
|||||||
// The visibility property needs to be checked and parsed by the visibility module.
|
// The visibility property needs to be checked and parsed by the visibility module.
|
||||||
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
|
setPrimaryVisibilityProperty(module, "visibility", &module.properties.Visibility)
|
||||||
|
|
||||||
|
InitSdkAwareModule(module)
|
||||||
initAndroidModuleBase(module)
|
initAndroidModuleBase(module)
|
||||||
InitDefaultableModule(module)
|
InitDefaultableModule(module)
|
||||||
|
|
||||||
|
@@ -41,6 +41,11 @@ type sdkAwareWithoutModule interface {
|
|||||||
sdkBase() *SdkBase
|
sdkBase() *SdkBase
|
||||||
MakeMemberOf(sdk SdkRef)
|
MakeMemberOf(sdk SdkRef)
|
||||||
IsInAnySdk() bool
|
IsInAnySdk() bool
|
||||||
|
|
||||||
|
// IsVersioned determines whether the module is versioned, i.e. has a name of the form
|
||||||
|
// <name>@<version>
|
||||||
|
IsVersioned() bool
|
||||||
|
|
||||||
ContainingSdk() SdkRef
|
ContainingSdk() SdkRef
|
||||||
MemberName() string
|
MemberName() string
|
||||||
BuildWithSdks(sdks SdkRefs)
|
BuildWithSdks(sdks SdkRefs)
|
||||||
@@ -140,6 +145,11 @@ func (s *SdkBase) IsInAnySdk() bool {
|
|||||||
return s.properties.ContainingSdk != nil
|
return s.properties.ContainingSdk != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsVersioned returns true if this module is versioned.
|
||||||
|
func (s *SdkBase) IsVersioned() bool {
|
||||||
|
return strings.Contains(s.module.Name(), "@")
|
||||||
|
}
|
||||||
|
|
||||||
// ContainingSdk returns the SDK that this module is a member of
|
// ContainingSdk returns the SDK that this module is a member of
|
||||||
func (s *SdkBase) ContainingSdk() SdkRef {
|
func (s *SdkBase) ContainingSdk() SdkRef {
|
||||||
if s.properties.ContainingSdk != nil {
|
if s.properties.ContainingSdk != nil {
|
||||||
|
@@ -444,7 +444,7 @@ func memberDepsMutator(mctx android.TopDownMutatorContext) {
|
|||||||
// built with libfoo.mysdk.11 and libfoo.mysdk.12, respectively depending on which sdk they are
|
// built with libfoo.mysdk.11 and libfoo.mysdk.12, respectively depending on which sdk they are
|
||||||
// using.
|
// using.
|
||||||
func memberInterVersionMutator(mctx android.BottomUpMutatorContext) {
|
func memberInterVersionMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if m, ok := mctx.Module().(android.SdkAware); ok && m.IsInAnySdk() {
|
if m, ok := mctx.Module().(android.SdkAware); ok && m.IsInAnySdk() && m.IsVersioned() {
|
||||||
if !m.ContainingSdk().Unversioned() {
|
if !m.ContainingSdk().Unversioned() {
|
||||||
memberName := m.MemberName()
|
memberName := m.MemberName()
|
||||||
tag := sdkMemberVersionedDepTag{member: memberName, version: m.ContainingSdk().Version}
|
tag := sdkMemberVersionedDepTag{member: memberName, version: m.ContainingSdk().Version}
|
||||||
@@ -483,7 +483,7 @@ func sdkDepsMutator(mctx android.TopDownMutatorContext) {
|
|||||||
// Step 5: if libfoo.mysdk.11 is in the context where version 11 of mysdk is requested, the
|
// Step 5: if libfoo.mysdk.11 is in the context where version 11 of mysdk is requested, the
|
||||||
// versioned module is used instead of the un-versioned (in-development) module libfoo
|
// versioned module is used instead of the un-versioned (in-development) module libfoo
|
||||||
func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) {
|
func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if versionedSdkMember, ok := mctx.Module().(android.SdkAware); ok && versionedSdkMember.IsInAnySdk() {
|
if versionedSdkMember, ok := mctx.Module().(android.SdkAware); ok && versionedSdkMember.IsInAnySdk() && versionedSdkMember.IsVersioned() {
|
||||||
if sdk := versionedSdkMember.ContainingSdk(); !sdk.Unversioned() {
|
if sdk := versionedSdkMember.ContainingSdk(); !sdk.Unversioned() {
|
||||||
// Only replace dependencies to <sdkmember> with <sdkmember@required-version>
|
// Only replace dependencies to <sdkmember> with <sdkmember@required-version>
|
||||||
// if the depending module requires it. e.g.
|
// if the depending module requires it. e.g.
|
||||||
@@ -499,7 +499,7 @@ func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
// TODO(b/183204176): Remove this after fixing.
|
// TODO(b/183204176): Remove this after fixing.
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
mctx.ModuleErrorf("%s", r)
|
mctx.ModuleErrorf("sdkDepsReplaceMutator %s", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user