Merge "Create os and arch variants for bootstrap Go modules"
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/bootstrap"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -698,13 +699,31 @@ func (target Target) Variations() []blueprint.Variation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func osMutator(mctx BottomUpMutatorContext) {
|
func osMutator(bpctx blueprint.BottomUpMutatorContext) {
|
||||||
var module Module
|
var module Module
|
||||||
var ok bool
|
var ok bool
|
||||||
if module, ok = mctx.Module().(Module); !ok {
|
if module, ok = bpctx.Module().(Module); !ok {
|
||||||
|
if bootstrap.IsBootstrapModule(bpctx.Module()) {
|
||||||
|
// Bootstrap Go modules are always the build OS or linux bionic.
|
||||||
|
config := bpctx.Config().(Config)
|
||||||
|
osNames := []string{config.BuildOSTarget.OsVariation()}
|
||||||
|
for _, hostCrossTarget := range config.Targets[LinuxBionic] {
|
||||||
|
if hostCrossTarget.Arch.ArchType == config.BuildOSTarget.Arch.ArchType {
|
||||||
|
osNames = append(osNames, hostCrossTarget.OsVariation())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
osNames = FirstUniqueStrings(osNames)
|
||||||
|
bpctx.CreateVariations(osNames...)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bootstrap Go module 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)
|
||||||
|
|
||||||
base := module.base()
|
base := module.base()
|
||||||
|
|
||||||
if !base.ArchSpecific() {
|
if !base.ArchSpecific() {
|
||||||
@@ -828,13 +847,23 @@ func GetOsSpecificVariantsOfCommonOSVariant(mctx BaseModuleContext) []Module {
|
|||||||
//
|
//
|
||||||
// Modules can be initialized with InitAndroidMultiTargetsArchModule, in which case they will be split by OsClass,
|
// 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().
|
// but will have a common Target that is expected to handle all other selected Targets via ctx.MultiTargets().
|
||||||
func archMutator(mctx BottomUpMutatorContext) {
|
func archMutator(bpctx blueprint.BottomUpMutatorContext) {
|
||||||
var module Module
|
var module Module
|
||||||
var ok bool
|
var ok bool
|
||||||
if module, ok = mctx.Module().(Module); !ok {
|
if module, ok = bpctx.Module().(Module); !ok {
|
||||||
|
if bootstrap.IsBootstrapModule(bpctx.Module()) {
|
||||||
|
// Bootstrap Go modules are always the build architecture.
|
||||||
|
bpctx.CreateVariations(bpctx.Config().(Config).BuildOSTarget.ArchVariation())
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bootstrap Go module 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)
|
||||||
|
|
||||||
base := module.base()
|
base := module.base()
|
||||||
|
|
||||||
if !base.ArchSpecific() {
|
if !base.ArchSpecific() {
|
||||||
@@ -912,7 +941,7 @@ func archMutator(mctx BottomUpMutatorContext) {
|
|||||||
modules := mctx.CreateVariations(targetNames...)
|
modules := mctx.CreateVariations(targetNames...)
|
||||||
for i, m := range modules {
|
for i, m := range modules {
|
||||||
addTargetProperties(m, targets[i], multiTargets, i == 0)
|
addTargetProperties(m, targets[i], multiTargets, i == 0)
|
||||||
m.(Module).base().setArchProperties(mctx)
|
m.base().setArchProperties(mctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,6 +75,7 @@ type registerMutatorsContext struct {
|
|||||||
type RegisterMutatorsContext interface {
|
type RegisterMutatorsContext interface {
|
||||||
TopDown(name string, m TopDownMutator) MutatorHandle
|
TopDown(name string, m TopDownMutator) MutatorHandle
|
||||||
BottomUp(name string, m BottomUpMutator) MutatorHandle
|
BottomUp(name string, m BottomUpMutator) MutatorHandle
|
||||||
|
BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
type RegisterMutatorFunc func(RegisterMutatorsContext)
|
type RegisterMutatorFunc func(RegisterMutatorsContext)
|
||||||
@@ -143,9 +144,9 @@ var preArch = []RegisterMutatorFunc{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func registerArchMutator(ctx RegisterMutatorsContext) {
|
func registerArchMutator(ctx RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("os", osMutator).Parallel()
|
ctx.BottomUpBlueprint("os", osMutator).Parallel()
|
||||||
ctx.BottomUp("image", imageMutator).Parallel()
|
ctx.BottomUp("image", imageMutator).Parallel()
|
||||||
ctx.BottomUp("arch", archMutator).Parallel()
|
ctx.BottomUpBlueprint("arch", archMutator).Parallel()
|
||||||
}
|
}
|
||||||
|
|
||||||
var preDeps = []RegisterMutatorFunc{
|
var preDeps = []RegisterMutatorFunc{
|
||||||
@@ -225,16 +226,21 @@ type bottomUpMutatorContext struct {
|
|||||||
finalPhase bool
|
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 {
|
func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) MutatorHandle {
|
||||||
finalPhase := x.finalPhase
|
finalPhase := x.finalPhase
|
||||||
f := func(ctx blueprint.BottomUpMutatorContext) {
|
f := func(ctx blueprint.BottomUpMutatorContext) {
|
||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &bottomUpMutatorContext{
|
m(bottomUpMutatorContextFactory(ctx, a, finalPhase))
|
||||||
bp: ctx,
|
|
||||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
|
||||||
finalPhase: finalPhase,
|
|
||||||
}
|
|
||||||
m(actx)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutator := &mutator{name: name, bottomUpMutator: f}
|
mutator := &mutator{name: name, bottomUpMutator: f}
|
||||||
@@ -242,6 +248,12 @@ func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) Mutat
|
|||||||
return mutator
|
return mutator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *registerMutatorsContext) BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle {
|
||||||
|
mutator := &mutator{name: name, bottomUpMutator: m}
|
||||||
|
x.mutators = append(x.mutators, mutator)
|
||||||
|
return mutator
|
||||||
|
}
|
||||||
|
|
||||||
func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle {
|
func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) MutatorHandle {
|
||||||
f := func(ctx blueprint.TopDownMutatorContext) {
|
f := func(ctx blueprint.TopDownMutatorContext) {
|
||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
|
Reference in New Issue
Block a user