Make sdkMemberDependencyTag usable outside sdk package
Moves the struct to android/sdk.go and abstracts it behind a factory method and interface. That allows it to be used outside the sdk package. This change is in preparation for adding support for module types that have transitive sdk members. Bug: 142940300 Test: m nothing Change-Id: I71e5e0adf839b28a3a0952f82637637887f02688
This commit is contained in:
parent
5b511a200e
commit
f8539922d4
3 changed files with 23 additions and 11 deletions
|
@ -218,6 +218,25 @@ type SdkMember interface {
|
|||
Variants() []SdkAware
|
||||
}
|
||||
|
||||
type SdkMemberTypeDependencyTag interface {
|
||||
blueprint.DependencyTag
|
||||
|
||||
SdkMemberType() SdkMemberType
|
||||
}
|
||||
|
||||
type sdkMemberDependencyTag struct {
|
||||
blueprint.BaseDependencyTag
|
||||
memberType SdkMemberType
|
||||
}
|
||||
|
||||
func (t *sdkMemberDependencyTag) SdkMemberType() SdkMemberType {
|
||||
return t.memberType
|
||||
}
|
||||
|
||||
func DependencyTagForSdkMemberType(memberType SdkMemberType) SdkMemberTypeDependencyTag {
|
||||
return &sdkMemberDependencyTag{memberType: memberType}
|
||||
}
|
||||
|
||||
// Interface that must be implemented for every type that can be a member of an
|
||||
// sdk.
|
||||
//
|
||||
|
|
11
sdk/sdk.go
11
sdk/sdk.go
|
@ -65,11 +65,6 @@ type sdkProperties struct {
|
|||
Module_exports bool `blueprint:"mutated"`
|
||||
}
|
||||
|
||||
type sdkMemberDependencyTag struct {
|
||||
blueprint.BaseDependencyTag
|
||||
memberType android.SdkMemberType
|
||||
}
|
||||
|
||||
// Contains information about the sdk properties that list sdk members, e.g.
|
||||
// Java_header_libs.
|
||||
type sdkMemberListProperty struct {
|
||||
|
@ -81,7 +76,7 @@ type sdkMemberListProperty struct {
|
|||
|
||||
// the dependency tag used for items in this list that can be used to determine the memberType
|
||||
// for a resolved dependency.
|
||||
dependencyTag *sdkMemberDependencyTag
|
||||
dependencyTag android.SdkMemberTypeDependencyTag
|
||||
}
|
||||
|
||||
func (p *sdkMemberListProperty) propertyName() string {
|
||||
|
@ -167,9 +162,7 @@ func createDynamicSdkMemberTypes(sdkMemberTypes []android.SdkMemberType) *dynami
|
|||
|
||||
memberType: memberType,
|
||||
|
||||
dependencyTag: &sdkMemberDependencyTag{
|
||||
memberType: memberType,
|
||||
},
|
||||
dependencyTag: android.DependencyTagForSdkMemberType(memberType),
|
||||
}
|
||||
|
||||
listProperties = append(listProperties, memberListProperty)
|
||||
|
|
|
@ -113,8 +113,8 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) []*sdkMember {
|
|||
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
tag := ctx.OtherModuleDependencyTag(m)
|
||||
if memberTag, ok := tag.(*sdkMemberDependencyTag); ok {
|
||||
memberType := memberTag.memberType
|
||||
if memberTag, ok := tag.(android.SdkMemberTypeDependencyTag); ok {
|
||||
memberType := memberTag.SdkMemberType()
|
||||
|
||||
// Make sure that the resolved module is allowed in the member list property.
|
||||
if !memberType.IsInstance(m) {
|
||||
|
|
Loading…
Reference in a new issue