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

Commit 7af6b706 authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge "Extract handling of image variations from target loop"

parents d8fd1242 b1f0f2aa
Loading
Loading
Loading
Loading
+58 −20
Original line number Diff line number Diff line
@@ -102,22 +102,59 @@ func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext
			// Include the native bridge targets as well.
			targets = includeNativeBridgeTargets
		}
		for _, target := range targets {

		// memberDependency encapsulates information about the dependencies to add for this member.
		type memberDependency struct {
			// The targets to depend upon.
			targets []android.Target

			// Additional image variations to depend upon, is either nil for no image variation or
			// contains a single image variation.
			imageVariations []blueprint.Variation
		}

		// Extract the name and version from the module name.
		name, version := StubsLibNameAndVersion(lib)
		if version == "" {
			version = "latest"
		}

		// Compute the set of dependencies to add.
		var memberDependencies []memberDependency
		if ctx.Host() {
			// Host does not support image variations so add a dependency without any.
			memberDependencies = append(memberDependencies, memberDependency{
				targets: targets,
			})
		} else {
			// Otherwise, this is targeting the device so add a dependency on the core image variation
			// (image:"").
			memberDependencies = append(memberDependencies, memberDependency{
				imageVariations: []blueprint.Variation{{Mutator: "image", Variation: android.CoreVariation}},
				targets:         targets,
			})
		}

		// For each dependency in the list add dependencies on the targets with the correct variations.
		for _, dependency := range memberDependencies {
			// For each target add a dependency on the target with any additional dependencies.
			for _, target := range dependency.targets {
				// Get the variations for the target.
				variations := target.Variations()
			if ctx.Device() {
				variations = append(variations,
					blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
			}

				// Add any additional dependencies needed.
				variations = append(variations, dependency.imageVariations...)

				if mt.linkTypes == nil {
					// No link types are supported so add a dependency directly.
					ctx.AddFarVariationDependencies(variations, dependencyTag, name)
				} else {
					// Otherwise, add a dependency on each supported link type in turn.
					for _, linkType := range mt.linkTypes {
						libVariations := append(variations,
							blueprint.Variation{Mutator: "link", Variation: linkType})
						// If this is for the device and a shared link type then add a dependency onto the
						// appropriate version specific variant of the module.
						if ctx.Device() && linkType == "shared" {
							libVariations = append(libVariations,
								blueprint.Variation{Mutator: "version", Variation: version})
@@ -128,6 +165,7 @@ func (mt *librarySdkMemberType) AddDependencies(ctx android.SdkDependencyContext
			}
		}
	}
}

func (mt *librarySdkMemberType) IsInstance(module android.Module) bool {
	// Check the module to see if it can be used with this module type.