Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 296701e3 authored by Paul Duffin's avatar Paul Duffin
Browse files

Refactor SdkMemberType.AddDependencies()

Replaces the BottomUpMutatorContext parameter with a new
SdkDependencyContext type that extends BottomUpMutatorContext. This is
to allow the sdk to pass additional information to the implementations
of that method to allow the behavior to be more finely tuned.

Bug: 195754365
Test: m nothing
Change-Id: I69c6d2c523934eb67d7a7e6c55c241e9b8a81773
parent 45de13f9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 {
+7 −1
Original line number Diff line number Diff line
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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)
		}
	}
}
+6 −6
Original line number Diff line number Diff line
@@ -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)
				}
			}
		}
+2 −2
Original line number Diff line number Diff line
@@ -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 {
Loading