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

Commit c2671f48 authored by Jiyong Park's avatar Jiyong Park Committed by Automerger Merge Worker
Browse files

Rename InApexes -> InApexVariants am: 712e8b5b

Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/14514153

Change-Id: I18003b297438176833764ec60b19261f2ec9346d
parents cef22354 712e8b5b
Loading
Loading
Loading
Loading
+34 −28
Original line number Diff line number Diff line
@@ -36,11 +36,16 @@ var (
// Accessible via `ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)`
type ApexInfo struct {
	// Name of the apex variation that this module (i.e. the apex variant of the module) is
	// mutated into, or "" for a platform (i.e. non-APEX) variant. Note that a module can be
	// included in multiple APEXes, in which case, the module is mutated into one or more
	// variants, each of which is for an APEX. The variants then can later be deduped if they
	// don't need to be compiled differently. This is an optimization done in
	// mergeApexVariations.
	// mutated into, or "" for a platform (i.e. non-APEX) variant. Note that this name and the
	// Soong module name of the APEX can be different. That happens when there is
	// `override_apex` that overrides `apex`. In that case, both Soong modules have the same
	// apex variation name which usually is `com.android.foo`. This name is also the `name`
	// in the path `/apex/<name>` where this apex is activated on at runtime.
	//
	// Also note that a module can be included in multiple APEXes, in which case, the module is
	// mutated into one or more variants, each of which is for an APEX. The variants then can
	// later be deduped if they don't need to be compiled differently. This is an optimization
	// done in mergeApexVariations.
	ApexVariationName string

	// ApiLevel that this module has to support at minimum.
@@ -52,11 +57,11 @@ type ApexInfo struct {
	// The list of SDK modules that the containing apexBundle depends on.
	RequiredSdks SdkRefs

	// List of apexBundles that this apex variant of the module is associated with. Initially,
	// the size of this list is one because one apex variant is associated with one apexBundle.
	// When multiple apex variants are merged in mergeApexVariations, ApexInfo struct of the
	// merged variant holds the list of apexBundles that are merged together.
	InApexes []string
	// List of Apex variant names that this module is associated with. This initially is the
	// same as the `ApexVariationName` field.  Then when multiple apex variants are merged in
	// mergeApexVariations, ApexInfo struct of the merged variant holds the list of apexBundles
	// that are merged together.
	InApexVariants []string

	// Pointers to the ApexContents struct each of which is for apexBundle modules that this
	// module is part of. The ApexContents gives information about which modules the apexBundle
@@ -93,23 +98,24 @@ func (i ApexInfo) IsForPlatform() bool {
	return i.ApexVariationName == ""
}

// InApex tells whether this apex variant of the module is part of the given apexBundle or not.
func (i ApexInfo) InApex(apex string) bool {
	for _, a := range i.InApexes {
		if a == apex {
// InApexVariant tells whether this apex variant of the module is part of the given apexVariant or
// not.
func (i ApexInfo) InApexVariant(apexVariant string) bool {
	for _, a := range i.InApexVariants {
		if a == apexVariant {
			return true
		}
	}
	return false
}

// InApexByBaseName tells whether this apex variant of the module is part of the given APEX or not,
// where the APEX is specified by its canonical base name, i.e. typically beginning with
// InApexByBaseName tells whether this apex variant of the module is part of the given apexVariant
// or not, where the APEX is specified by its canonical base name, i.e. typically beginning with
// "com.android.". In particular this function doesn't differentiate between source and prebuilt
// APEXes, where the latter may have "prebuilt_" prefixes.
func (i ApexInfo) InApexByBaseName(apex string) bool {
	for _, a := range i.InApexes {
		if RemoveOptionalPrebuiltPrefix(a) == apex {
func (i ApexInfo) InApexVariantByBaseName(apexVariant string) bool {
	for _, a := range i.InApexVariants {
		if RemoveOptionalPrebuiltPrefix(a) == apexVariant {
			return true
		}
	}
@@ -496,21 +502,21 @@ func mergeApexVariations(ctx PathContext, apexInfos []ApexInfo) (merged []ApexIn
		// Merge the ApexInfo together. If a compatible ApexInfo exists then merge the information from
		// this one into it, otherwise create a new merged ApexInfo from this one and save it away so
		// other ApexInfo instances can be merged into it.
		apexName := apexInfo.ApexVariationName
		variantName := apexInfo.ApexVariationName
		mergedName := apexInfo.mergedName(ctx)
		if index, exists := seen[mergedName]; exists {
			// Variants having the same mergedName are deduped
			merged[index].InApexes = append(merged[index].InApexes, apexName)
			merged[index].InApexVariants = append(merged[index].InApexVariants, variantName)
			merged[index].ApexContents = append(merged[index].ApexContents, apexInfo.ApexContents...)
			merged[index].Updatable = merged[index].Updatable || apexInfo.Updatable
		} else {
			seen[mergedName] = len(merged)
			apexInfo.ApexVariationName = mergedName
			apexInfo.InApexes = CopyOf(apexInfo.InApexes)
			apexInfo.InApexVariants = CopyOf(apexInfo.InApexVariants)
			apexInfo.ApexContents = append([]*ApexContents(nil), apexInfo.ApexContents...)
			merged = append(merged, apexInfo)
		}
		aliases = append(aliases, [2]string{apexName, mergedName})
		aliases = append(aliases, [2]string{variantName, mergedName})
	}
	return merged, aliases
}
@@ -583,15 +589,15 @@ func CreateApexVariations(mctx BottomUpMutatorContext, module ApexModule) []Modu
// in the same APEX have unique APEX variations so that the module can link against the right
// variant.
func UpdateUniqueApexVariationsForDeps(mctx BottomUpMutatorContext, am ApexModule) {
	// anyInSameApex returns true if the two ApexInfo lists contain any values in an InApexes
	// list in common. It is used instead of DepIsInSameApex because it needs to determine if
	// the dep is in the same APEX due to being directly included, not only if it is included
	// _because_ it is a dependency.
	// anyInSameApex returns true if the two ApexInfo lists contain any values in an
	// InApexVariants list in common. It is used instead of DepIsInSameApex because it needs to
	// determine if the dep is in the same APEX due to being directly included, not only if it
	// is included _because_ it is a dependency.
	anyInSameApex := func(a, b []ApexInfo) bool {
		collectApexes := func(infos []ApexInfo) []string {
			var ret []string
			for _, info := range infos {
				ret = append(ret, info.InApexes...)
				ret = append(ret, info.InApexVariants...)
			}
			return ret
		}
+2 −2
Original line number Diff line number Diff line
@@ -900,7 +900,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
		MinSdkVersion:     minSdkVersion,
		RequiredSdks:      a.RequiredSdks(),
		Updatable:         a.Updatable(),
		InApexes:          []string{mctx.ModuleName()},
		InApexVariants:    []string{mctx.ModuleName()},
		ApexContents:      []*android.ApexContents{apexContents},
	}
	mctx.WalkDeps(func(child, parent android.Module) bool {
@@ -1557,7 +1557,7 @@ func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.Paylo
		}

		ai := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
		externalDep := !android.InList(ctx.ModuleName(), ai.InApexes)
		externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)

		// Visit actually
		return do(ctx, parent, am, externalDep)
+1 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ func (p *prebuiltCommon) apexInfoMutator(mctx android.TopDownMutatorContext) {
	// Create an ApexInfo for the prebuilt_apex.
	apexInfo := android.ApexInfo{
		ApexVariationName: android.RemoveOptionalPrebuiltPrefix(mctx.ModuleName()),
		InApexes:          []string{mctx.ModuleName()},
		InApexVariants:    []string{mctx.ModuleName()},
		ApexContents:      []*android.ApexContents{apexContents},
		ForPrebuiltApex:   true,
	}
+1 −1
Original line number Diff line number Diff line
@@ -2831,7 +2831,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
						// Add the dependency to the APEX(es) providing the library so that
						// m <module> can trigger building the APEXes as well.
						depApexInfo := ctx.OtherModuleProvider(dep, android.ApexInfoProvider).(android.ApexInfo)
						for _, an := range depApexInfo.InApexes {
						for _, an := range depApexInfo.InApexVariants {
							c.Properties.ApexesProvidingSharedLibs = append(
								c.Properties.ApexesProvidingSharedLibs, an)
						}
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ func (b *bootJarsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
		name := android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName(module))
		if apex, ok := moduleToApex[name]; ok {
			apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
			if (apex == "platform" && apexInfo.IsForPlatform()) || apexInfo.InApexByBaseName(apex) {
			if (apex == "platform" && apexInfo.IsForPlatform()) || apexInfo.InApexVariantByBaseName(apex) {
				// The module name/apex variant should be unique in the system but double check
				// just in case something has gone wrong.
				if existing, ok := nameToApexVariant[name]; ok {
Loading