Add apex.use_vndk_as_stable property
Vendor APEXes(in general, APEXes for non-system partitions) which is
supposed to be tied to a specific VNDK version can set this new property
so that it excludes VNDK libs and use them from VNDK APEX (provided by
system parition).
For these APEXes to use VNDK libs from VNDK APEX, linkerconfig should
link "vndk" linker namespace to the namespaces of these APEXes.
Bug: 159195575
Test: m (soong test added)
Change-Id: If90650973239ef7aab0ff084488bda57d9b0364e
diff --git a/apex/apex.go b/apex/apex.go
index fa986cd..b64a735 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -691,6 +691,14 @@
MinSdkVersion: a.minSdkVersion(mctx),
Updatable: a.Updatable(),
}
+
+ useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
+ excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable)
+ if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) {
+ mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
+ return
+ }
+
mctx.WalkDeps(func(child, parent android.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
@@ -699,6 +707,11 @@
if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) && !inAnySdk(child) {
return false
}
+ if excludeVndkLibs {
+ if c, ok := child.(*cc.Module); ok && c.IsVndk() {
+ return false
+ }
+ }
depName := mctx.OtherModuleName(child)
// If the parent is apexBundle, this child is directly depended.
@@ -1009,6 +1022,11 @@
// The minimum SDK version that this apex must be compatibile with.
Min_sdk_version *string
+
+ // If set true, VNDK libs are considered as stable libs and are not included in this apex.
+ // Should be only used in non-system apexes (e.g. vendor: true).
+ // Default is false.
+ Use_vndk_as_stable *bool
}
type apexTargetBundleProperties struct {
@@ -1821,7 +1839,8 @@
// 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() {
+ if a.SocSpecific() || a.DeviceSpecific() ||
+ (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
return
}
@@ -2137,6 +2156,13 @@
// don't include it in this APEX
return false
}
+ if cc.UseVndk() && proptools.Bool(a.properties.Use_vndk_as_stable) && cc.IsVndk() {
+ // For vendor APEX with use_vndk_as_stable: true, we don't include VNDK libs
+ // and use them from VNDK APEX.
+ // TODO(b/159576928): add "vndk" as requiredDeps so that linkerconfig can make "vndk"
+ // linker namespace avaiable to this apex.
+ return false
+ }
af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
af.transitiveDep = true
if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), depName) && (cc.IsStubs() || cc.HasStubsVariants()) {
@@ -2254,7 +2280,8 @@
// 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() {
+ if a.SocSpecific() || a.DeviceSpecific() ||
+ (a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
a.linkToSystemLib = false
}