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

Commit 6deda0a3 authored by Colin Cross's avatar Colin Cross Committed by Automerger Merge Worker
Browse files

Merge "Revert "Create os and arch variants for GoBinaryTool modules"" am: 02789ab3

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

Change-Id: I3d563ce07c76ae3d0200be599f7576d4253b3bcd
parents cab67c0d 02789ab3
Loading
Loading
Loading
Loading
+5 −24
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import (
	"strings"

	"github.com/google/blueprint"
	"github.com/google/blueprint/bootstrap"
	"github.com/google/blueprint/proptools"
)

@@ -690,24 +689,15 @@ func (target Target) Variations() []blueprint.Variation {
	}
}

func osMutator(bpctx blueprint.BottomUpMutatorContext) {
func osMutator(mctx BottomUpMutatorContext) {
	var module Module
	var ok bool
	if module, ok = bpctx.Module().(Module); !ok {
		if _, ok := bpctx.Module().(bootstrap.GoBinaryTool); ok {
			// Go tools are always build OS tools.
			bpctx.CreateVariations(bpctx.Config().(Config).BuildOSTarget.OsVariation())
		}
	if module, ok = mctx.Module().(Module); !ok {
		return
	}

	base := module.base()

	// GoBinaryTool support above requires this mutator to be a blueprint.BottomUpMutatorContext
	// because android.BottomUpMutatorContext filters out non-Soong modules.  Now that we've
	// handled them, create a normal android.BottomUpMutatorContext.
	mctx := bottomUpMutatorContextFactory(bpctx, module, false)

	if !base.ArchSpecific() {
		return
	}
@@ -829,24 +819,15 @@ func GetOsSpecificVariantsOfCommonOSVariant(mctx BaseModuleContext) []Module {
//
// Modules can be initialized with InitAndroidMultiTargetsArchModule, in which case they will be split by OsClass,
// but will have a common Target that is expected to handle all other selected Targets via ctx.MultiTargets().
func archMutator(bpctx blueprint.BottomUpMutatorContext) {
func archMutator(mctx BottomUpMutatorContext) {
	var module Module
	var ok bool
	if module, ok = bpctx.Module().(Module); !ok {
		if _, ok := bpctx.Module().(bootstrap.GoBinaryTool); ok {
			// Go tools are always build OS tools.
			bpctx.CreateVariations(bpctx.Config().(Config).BuildOSTarget.ArchVariation())
		}
	if module, ok = mctx.Module().(Module); !ok {
		return
	}

	base := module.base()

	// GoBinaryTool support above requires this mutator to be a blueprint.BottomUpMutatorContext
	// because android.BottomUpMutatorContext filters out non-Soong modules.  Now that we've
	// handled them, create a normal android.BottomUpMutatorContext.
	mctx := bottomUpMutatorContextFactory(bpctx, module, false)

	if !base.ArchSpecific() {
		return
	}
@@ -922,7 +903,7 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
	modules := mctx.CreateVariations(targetNames...)
	for i, m := range modules {
		addTargetProperties(m, targets[i], multiTargets, i == 0)
		m.base().setArchProperties(mctx)
		m.(Module).base().setArchProperties(mctx)
	}
}

+8 −20
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ type registerMutatorsContext struct {
type RegisterMutatorsContext interface {
	TopDown(name string, m TopDownMutator) MutatorHandle
	BottomUp(name string, m BottomUpMutator) MutatorHandle
	BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle
}

type RegisterMutatorFunc func(RegisterMutatorsContext)
@@ -144,9 +143,9 @@ var preArch = []RegisterMutatorFunc{
}

func registerArchMutator(ctx RegisterMutatorsContext) {
	ctx.BottomUpBlueprint("os", osMutator).Parallel()
	ctx.BottomUp("os", osMutator).Parallel()
	ctx.BottomUp("image", imageMutator).Parallel()
	ctx.BottomUpBlueprint("arch", archMutator).Parallel()
	ctx.BottomUp("arch", archMutator).Parallel()
}

var preDeps = []RegisterMutatorFunc{
@@ -226,30 +225,19 @@ type bottomUpMutatorContext struct {
	finalPhase bool
}

func bottomUpMutatorContextFactory(ctx blueprint.BottomUpMutatorContext, a Module,
	finalPhase bool) BottomUpMutatorContext {

	return &bottomUpMutatorContext{
		bp:                ctx,
		baseModuleContext: a.base().baseModuleContextFactory(ctx),
		finalPhase:        finalPhase,
	}
}

func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
	finalPhase := x.finalPhase
	f := func(ctx blueprint.BottomUpMutatorContext) {
		if a, ok := ctx.Module().(Module); ok {
			m(bottomUpMutatorContextFactory(ctx, a, finalPhase))
			actx := &bottomUpMutatorContext{
				bp:                ctx,
				baseModuleContext: a.base().baseModuleContextFactory(ctx),
				finalPhase:        finalPhase,
			}
			m(actx)
		}
	mutator := &mutator{name: name, bottomUpMutator: f}
	x.mutators = append(x.mutators, mutator)
	return mutator
	}

func (x *registerMutatorsContext) BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle {
	mutator := &mutator{name: name, bottomUpMutator: m}
	mutator := &mutator{name: name, bottomUpMutator: f}
	x.mutators = append(x.mutators, mutator)
	return mutator
}