apex: support "vendor: true"
When an apex sets "vendor: true", it becomes a vendor apex.
Vendor apexes use vendor variants for native modules and are
installed in /vendor/apex.
Bug: 159211312
Test: m
Change-Id: I2585dd990ba857a2ab3ec6ab24e09d4652e867f2
diff --git a/apex/apex.go b/apex/apex.go
index c330f82..2896965 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1329,6 +1329,7 @@
targets := ctx.MultiTargets()
config := ctx.DeviceConfig()
+ imageVariation := a.getImageVariation(ctx)
a.combineProperties(ctx)
@@ -1348,13 +1349,13 @@
Jni_libs: a.properties.Jni_libs,
Binaries: nil,
},
- target, a.getImageVariation(config))
+ target, imageVariation)
// Add native modules targetting both ABIs
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Both,
target,
- a.getImageVariation(config))
+ imageVariation)
isPrimaryAbi := i == 0
if isPrimaryAbi {
@@ -1367,13 +1368,13 @@
Jni_libs: nil,
Binaries: a.properties.Binaries,
},
- target, a.getImageVariation(config))
+ target, imageVariation)
// Add native modules targetting the first ABI
addDependenciesForNativeModules(ctx,
a.properties.Multilib.First,
target,
- a.getImageVariation(config))
+ imageVariation)
}
switch target.Arch.ArchType.Multilib {
@@ -1382,24 +1383,24 @@
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Lib32,
target,
- a.getImageVariation(config))
+ imageVariation)
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Prefer32,
target,
- a.getImageVariation(config))
+ imageVariation)
case "lib64":
// Add native modules targetting 64-bit ABI
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Lib64,
target,
- a.getImageVariation(config))
+ imageVariation)
if !has32BitTarget {
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Prefer32,
target,
- a.getImageVariation(config))
+ imageVariation)
}
}
}
@@ -1501,15 +1502,33 @@
return proptools.Bool(a.properties.Test_only_unsigned_payload)
}
-func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
+func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string {
+ deviceConfig := ctx.DeviceConfig()
if a.vndkApex {
- return cc.VendorVariationPrefix + a.vndkVersion(config)
+ return cc.VendorVariationPrefix + a.vndkVersion(deviceConfig)
}
- if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
- return cc.VendorVariationPrefix + config.PlatformVndkVersion()
- } else {
- return android.CoreVariation
+
+ var prefix string
+ var vndkVersion string
+ if deviceConfig.VndkVersion() != "" {
+ if proptools.Bool(a.properties.Use_vendor) {
+ prefix = cc.VendorVariationPrefix
+ vndkVersion = deviceConfig.PlatformVndkVersion()
+ } else if a.SocSpecific() || a.DeviceSpecific() {
+ prefix = cc.VendorVariationPrefix
+ vndkVersion = deviceConfig.VndkVersion()
+ } else if a.ProductSpecific() {
+ prefix = cc.ProductVariationPrefix
+ vndkVersion = deviceConfig.ProductVndkVersion()
+ }
}
+ if vndkVersion == "current" {
+ vndkVersion = deviceConfig.PlatformVndkVersion()
+ }
+ if vndkVersion != "" {
+ return prefix + vndkVersion
+ }
+ return android.CoreVariation
}
func (a *apexBundle) EnableSanitizer(sanitizerName string) {
@@ -1541,7 +1560,7 @@
for _, target := range ctx.MultiTargets() {
if target.Arch.ArchType.Multilib == "lib64" {
ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: a.getImageVariation(ctx.DeviceConfig())},
+ {Mutator: "image", Variation: a.getImageVariation(ctx)},
{Mutator: "link", Variation: "shared"},
{Mutator: "version", Variation: ""}, // "" is the non-stub variant
}...), sharedLibTag, "libclang_rt.hwasan-aarch64-android")
@@ -1785,6 +1804,12 @@
return
}
+ // Because APEXes targeting other than system/system_ext partitions
+ // can't set apex_available, we skip checks for these APEXes
+ if ctx.SocSpecific() || ctx.DeviceSpecific() || ctx.ProductSpecific() {
+ return
+ }
+
// Coverage build adds additional dependencies for the coverage-only runtime libraries.
// Requiring them and their transitive depencies with apex_available is not right
// because they just add noise.
@@ -2203,6 +2228,12 @@
a.installable() &&
!proptools.Bool(a.properties.Use_vendor)
+ // APEXes targeting other than system/system_ext partitions use vendor/product variants.
+ // So we can't link them to /system/lib libs which are core variants.
+ if a.SocSpecific() || a.DeviceSpecific() || a.ProductSpecific() {
+ a.linkToSystemLib = false
+ }
+
// We don't need the optimization for updatable APEXes, as it might give false signal
// to the system health when the APEXes are still bundled (b/149805758)
if a.Updatable() && a.properties.ApexType == imageApex {