Add multi-target variants
Allow modules to specify that they will handle multiple targets in
the common variant. This will be used by android_app modules to
handle JNI libraries from multiple architectures.
Bug: 80095087
Test: m checkbuild
Change-Id: Iede3e9c23b64fb516341c3ae08074a322b511d40
diff --git a/android/module.go b/android/module.go
index 01766b4..9d9d9a9 100644
--- a/android/module.go
+++ b/android/module.go
@@ -58,6 +58,7 @@
type androidBaseContext interface {
Target() Target
TargetPrimary() bool
+ MultiTargets() []Target
Arch() Arch
Os() OsType
Host() bool
@@ -215,7 +216,8 @@
}
}
- Default_multilib string `blueprint:"mutated"`
+ UseTargetVariants bool `blueprint:"mutated"`
+ Default_multilib string `blueprint:"mutated"`
// whether this is a proprietary vendor module, and should be installed into /vendor
Proprietary *bool
@@ -264,8 +266,9 @@
Notice *string
// Set by TargetMutator
- CompileTarget Target `blueprint:"mutated"`
- CompilePrimary bool `blueprint:"mutated"`
+ CompileTarget Target `blueprint:"mutated"`
+ CompileMultiTargets []Target `blueprint:"mutated"`
+ CompilePrimary bool `blueprint:"mutated"`
// Set by InitAndroidModule
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
@@ -362,6 +365,7 @@
base.commonProperties.HostOrDeviceSupported = hod
base.commonProperties.Default_multilib = string(defaultMultilib)
base.commonProperties.ArchSpecific = true
+ base.commonProperties.UseTargetVariants = true
switch hod {
case HostAndDeviceSupported, HostAndDeviceDefault:
@@ -371,6 +375,11 @@
InitArchModule(m)
}
+func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
+ InitAndroidArchModule(m, hod, defaultMultilib)
+ m.base().commonProperties.UseTargetVariants = false
+}
+
// A ModuleBase object contains the properties that are common to all Android
// modules. It should be included as an anonymous field in every module
// struct definition. InitAndroidModule should then be called from the module's
@@ -477,8 +486,9 @@
return a
}
-func (a *ModuleBase) SetTarget(target Target, primary bool) {
+func (a *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
a.commonProperties.CompileTarget = target
+ a.commonProperties.CompileMultiTargets = multiTargets
a.commonProperties.CompilePrimary = primary
}
@@ -490,6 +500,10 @@
return a.commonProperties.CompilePrimary
}
+func (a *ModuleBase) MultiTargets() []Target {
+ return a.commonProperties.CompileMultiTargets
+}
+
func (a *ModuleBase) Os() OsType {
return a.Target().Os
}
@@ -731,6 +745,7 @@
return androidBaseContextImpl{
target: a.commonProperties.CompileTarget,
targetPrimary: a.commonProperties.CompilePrimary,
+ multiTargets: a.commonProperties.CompileMultiTargets,
kind: determineModuleKind(a, ctx),
config: ctx.Config().(Config),
}
@@ -785,6 +800,7 @@
type androidBaseContextImpl struct {
target Target
+ multiTargets []Target
targetPrimary bool
debug bool
kind moduleKind
@@ -1022,6 +1038,10 @@
return a.targetPrimary
}
+func (a *androidBaseContextImpl) MultiTargets() []Target {
+ return a.multiTargets
+}
+
func (a *androidBaseContextImpl) Arch() Arch {
return a.target.Arch
}