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