Merge "Refactor SdkMemberType.AddDependencies()"
This commit is contained in:
@@ -31,9 +31,9 @@ type licenseSdkMemberType struct {
|
||||
SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (l *licenseSdkMemberType) AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
func (l *licenseSdkMemberType) AddDependencies(ctx SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
// Add dependencies onto the license module from the sdk module.
|
||||
mctx.AddDependency(mctx.Module(), dependencyTag, names...)
|
||||
ctx.AddDependency(ctx.Module(), dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (l *licenseSdkMemberType) IsInstance(module Module) bool {
|
||||
|
@@ -475,7 +475,7 @@ type SdkMemberType interface {
|
||||
// properties. The dependencies must be added with the supplied tag.
|
||||
//
|
||||
// The BottomUpMutatorContext provided is for the SDK module.
|
||||
AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string)
|
||||
AddDependencies(ctx SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string)
|
||||
|
||||
// Return true if the supplied module is an instance of this member type.
|
||||
//
|
||||
@@ -529,6 +529,12 @@ type SdkMemberType interface {
|
||||
CreateVariantPropertiesStruct() SdkMemberProperties
|
||||
}
|
||||
|
||||
// SdkDependencyContext provides access to information needed by the SdkMemberType.AddDependencies()
|
||||
// implementations.
|
||||
type SdkDependencyContext interface {
|
||||
BottomUpMutatorContext
|
||||
}
|
||||
|
||||
// Base type for SdkMemberType implementations.
|
||||
type SdkMemberTypeBase struct {
|
||||
PropertyName string
|
||||
|
@@ -38,16 +38,16 @@ type binarySdkMemberType struct {
|
||||
android.SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (mt *binarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
targets := mctx.MultiTargets()
|
||||
func (mt *binarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
targets := ctx.MultiTargets()
|
||||
for _, bin := range names {
|
||||
for _, target := range targets {
|
||||
variations := target.Variations()
|
||||
if mctx.Device() {
|
||||
if ctx.Device() {
|
||||
variations = append(variations,
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||
}
|
||||
mctx.AddFarVariationDependencies(variations, dependencyTag, bin)
|
||||
ctx.AddFarVariationDependencies(variations, dependencyTag, bin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -74,8 +74,8 @@ type librarySdkMemberType struct {
|
||||
linkTypes []string
|
||||
}
|
||||
|
||||
func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
targets := mctx.MultiTargets()
|
||||
func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
targets := ctx.MultiTargets()
|
||||
for _, lib := range names {
|
||||
for _, target := range targets {
|
||||
name, version := StubsLibNameAndVersion(lib)
|
||||
@@ -83,21 +83,21 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont
|
||||
version = "latest"
|
||||
}
|
||||
variations := target.Variations()
|
||||
if mctx.Device() {
|
||||
if ctx.Device() {
|
||||
variations = append(variations,
|
||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||
}
|
||||
if mt.linkTypes == nil {
|
||||
mctx.AddFarVariationDependencies(variations, dependencyTag, name)
|
||||
ctx.AddFarVariationDependencies(variations, dependencyTag, name)
|
||||
} else {
|
||||
for _, linkType := range mt.linkTypes {
|
||||
libVariations := append(variations,
|
||||
blueprint.Variation{Mutator: "link", Variation: linkType})
|
||||
if mctx.Device() && linkType == "shared" {
|
||||
if ctx.Device() && linkType == "shared" {
|
||||
libVariations = append(libVariations,
|
||||
blueprint.Variation{Mutator: "version", Variation: version})
|
||||
}
|
||||
mctx.AddFarVariationDependencies(libVariations, dependencyTag, name)
|
||||
ctx.AddFarVariationDependencies(libVariations, dependencyTag, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -718,8 +718,8 @@ type bootclasspathFragmentMemberType struct {
|
||||
android.SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (b *bootclasspathFragmentMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
func (b *bootclasspathFragmentMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (b *bootclasspathFragmentMemberType) IsInstance(module android.Module) bool {
|
||||
|
@@ -574,8 +574,8 @@ const (
|
||||
copyEverythingToSnapshot = false
|
||||
)
|
||||
|
||||
func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
|
||||
@@ -875,8 +875,8 @@ type testSdkMemberType struct {
|
||||
android.SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (mt *testSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
func (mt *testSdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (mt *testSdkMemberType) IsInstance(module android.Module) bool {
|
||||
|
@@ -134,8 +134,8 @@ type compatConfigMemberType struct {
|
||||
android.SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (b *compatConfigMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
func (b *compatConfigMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (b *compatConfigMemberType) IsInstance(module android.Module) bool {
|
||||
|
@@ -2471,8 +2471,8 @@ type sdkLibrarySdkMemberType struct {
|
||||
android.SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (s *sdkLibrarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
func (s *sdkLibrarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (s *sdkLibrarySdkMemberType) IsInstance(module android.Module) bool {
|
||||
|
@@ -245,8 +245,8 @@ type systemModulesSdkMemberType struct {
|
||||
android.SdkMemberTypeBase
|
||||
}
|
||||
|
||||
func (mt *systemModulesSdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
mctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
func (mt *systemModulesSdkMemberType) AddDependencies(ctx android.SdkDependencyContext, dependencyTag blueprint.DependencyTag, names []string) {
|
||||
ctx.AddVariationDependencies(nil, dependencyTag, names...)
|
||||
}
|
||||
|
||||
func (mt *systemModulesSdkMemberType) IsInstance(module android.Module) bool {
|
||||
|
16
sdk/sdk.go
16
sdk/sdk.go
@@ -341,6 +341,19 @@ func (s *sdk) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
}}
|
||||
}
|
||||
|
||||
// newDependencyContext creates a new SdkDependencyContext for this sdk.
|
||||
func (s *sdk) newDependencyContext(mctx android.BottomUpMutatorContext) android.SdkDependencyContext {
|
||||
return &dependencyContext{
|
||||
BottomUpMutatorContext: mctx,
|
||||
}
|
||||
}
|
||||
|
||||
type dependencyContext struct {
|
||||
android.BottomUpMutatorContext
|
||||
}
|
||||
|
||||
var _ android.SdkDependencyContext = (*dependencyContext)(nil)
|
||||
|
||||
// RegisterPreDepsMutators registers pre-deps mutators to support modules implementing SdkAware
|
||||
// interface and the sdk module type. This function has been made public to be called by tests
|
||||
// outside of the sdk package
|
||||
@@ -410,6 +423,7 @@ func memberMutator(mctx android.BottomUpMutatorContext) {
|
||||
if s, ok := mctx.Module().(*sdk); ok {
|
||||
// Add dependencies from enabled and non CommonOS variants to the sdk member variants.
|
||||
if s.Enabled() && !s.IsCommonOSVariant() {
|
||||
ctx := s.newDependencyContext(mctx)
|
||||
for _, memberListProperty := range s.memberListProperties() {
|
||||
if memberListProperty.getter == nil {
|
||||
continue
|
||||
@@ -417,7 +431,7 @@ func memberMutator(mctx android.BottomUpMutatorContext) {
|
||||
names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
|
||||
if len(names) > 0 {
|
||||
tag := memberListProperty.dependencyTag
|
||||
memberListProperty.memberType.AddDependencies(mctx, tag, names)
|
||||
memberListProperty.memberType.AddDependencies(ctx, tag, names)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user