Create os and arch variants for GoBinaryTool modules
AddFarVariationDependencies was broken, which allowed modules to add
dependencies on GoBinaryTool modules using os and arch variations
even though GoBinaryTool modules did not have any variations. Mutate
GoBinaryTool modules in the os and arch mutators so that they have the
expected os and arch variations.
Test: all soong tests
Change-Id: Ida7bc75a51ab1d2d38a6be11f574399097380cc9
diff --git a/android/arch.go b/android/arch.go
index 9a54614..2ddb3f9 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -23,6 +23,7 @@
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
)
@@ -689,15 +690,24 @@
}
}
-func osMutator(mctx BottomUpMutatorContext) {
+func osMutator(bpctx blueprint.BottomUpMutatorContext) {
var module Module
var ok bool
- if module, ok = mctx.Module().(Module); !ok {
+ 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())
+ }
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
}
@@ -819,15 +829,24 @@
//
// 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(mctx BottomUpMutatorContext) {
+func archMutator(bpctx blueprint.BottomUpMutatorContext) {
var module Module
var ok bool
- if module, ok = mctx.Module().(Module); !ok {
+ 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())
+ }
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
}
@@ -903,7 +922,7 @@
modules := mctx.CreateVariations(targetNames...)
for i, m := range modules {
addTargetProperties(m, targets[i], multiTargets, i == 0)
- m.(Module).base().setArchProperties(mctx)
+ m.base().setArchProperties(mctx)
}
}