Supports VNDK APEX with different versions
Older VNDK libraries are provided as vndk_prebuilt_shared modules. Those
are added to corresponding VNDK APEX as dependencies.
With VNDK APEX installed, VNDK libs are unnecessary. By the way, since
there can be vendor modules which depend on VNDK libs, Make targets are
still emitted with UNINSTALLABLE=true.
Android.mk has additional modules for vndk libraries which are named
with apex name as suffices. For example, if libfoo is a vndk library,
then libfoo.vendor is its vendor variant and it would be in
/system/lib/vndk. But with vndk apex, it has additional
libfoo.com.android.vndk.current variant.
Bug: 141451661
Bug: 139772411
Test: m (soong tests)
Test: boot with aosp_arm64 system image on Q vendor device
Change-Id: I269c28a4d4c4e2f1518bd51df558438fe5316774
diff --git a/apex/apex.go b/apex/apex.go
index bb90cb9..d84ddb7 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -182,10 +182,7 @@
android.RegisterModuleType("apex_defaults", defaultsFactory)
android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
- android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
- ctx.TopDown("apex_vndk_gather", apexVndkGatherMutator).Parallel()
- ctx.BottomUp("apex_vndk_add_deps", apexVndkAddDepsMutator).Parallel()
- })
+ android.PreDepsMutators(RegisterPreDepsMutators)
android.PostDepsMutators(RegisterPostDepsMutators)
android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
@@ -195,6 +192,11 @@
})
}
+func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
+ ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
+ ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
+}
+
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.TopDown("apex_deps", apexDepsMutator)
ctx.BottomUp("apex", apexMutator).Parallel()
@@ -207,44 +209,39 @@
vndkApexListMutex sync.Mutex
)
-func vndkApexList(config android.Config) map[string]*apexBundle {
+func vndkApexList(config android.Config) map[string]string {
return config.Once(vndkApexListKey, func() interface{} {
- return map[string]*apexBundle{}
- }).(map[string]*apexBundle)
+ return map[string]string{}
+ }).(map[string]string)
}
-// apexVndkGatherMutator gathers "apex_vndk" modules and puts them in a map with vndk_version as a key.
-func apexVndkGatherMutator(mctx android.TopDownMutatorContext) {
+func apexVndkMutator(mctx android.TopDownMutatorContext) {
if ab, ok := mctx.Module().(*apexBundle); ok && ab.vndkApex {
if ab.IsNativeBridgeSupported() {
mctx.PropertyErrorf("native_bridge_supported", "%q doesn't support native bridge binary.", mctx.ModuleType())
}
- vndkVersion := proptools.String(ab.vndkProperties.Vndk_version)
+ vndkVersion := ab.vndkVersion(mctx.DeviceConfig())
+ // Ensure VNDK APEX mount point is formatted as com.android.vndk.v###
+ ab.properties.Apex_name = proptools.StringPtr("com.android.vndk.v" + vndkVersion)
+ // vndk_version should be unique
vndkApexListMutex.Lock()
defer vndkApexListMutex.Unlock()
vndkApexList := vndkApexList(mctx.Config())
if other, ok := vndkApexList[vndkVersion]; ok {
- mctx.PropertyErrorf("vndk_version", "%v is already defined in %q", vndkVersion, other.BaseModuleName())
+ mctx.PropertyErrorf("vndk_version", "%v is already defined in %q", vndkVersion, other)
}
- vndkApexList[vndkVersion] = ab
+ vndkApexList[vndkVersion] = mctx.ModuleName()
}
}
-// apexVndkAddDepsMutator adds (reverse) dependencies from vndk libs to apex_vndk modules.
-// It filters only libs with matching targets.
-func apexVndkAddDepsMutator(mctx android.BottomUpMutatorContext) {
- if cc, ok := mctx.Module().(*cc.Module); ok && cc.IsVndkOnSystem() {
+func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) {
+ if m, ok := mctx.Module().(*cc.Module); ok && cc.IsForVndkApex(mctx, m) {
+ vndkVersion := m.VndkVersion()
vndkApexList := vndkApexList(mctx.Config())
- if ab, ok := vndkApexList[cc.VndkVersion()]; ok {
- targetArch := cc.Target().String()
- for _, target := range ab.MultiTargets() {
- if target.String() == targetArch {
- mctx.AddReverseDependency(mctx.Module(), sharedLibTag, ab.Name())
- break
- }
- }
+ if vndkApex, ok := vndkApexList[vndkVersion]; ok {
+ mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApex)
}
}
}
@@ -650,7 +647,6 @@
}
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
-
targets := ctx.MultiTargets()
config := ctx.DeviceConfig()
@@ -821,6 +817,9 @@
}
func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
+ if a.vndkApex {
+ return "vendor." + a.vndkVersion(config)
+ }
if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
return "vendor." + config.PlatformVndkVersion()
} else {
@@ -1237,7 +1236,7 @@
// prepend the name of this APEX to the module names. These names will be the names of
// modules that will be defined if the APEX is flattened.
for i := range filesInfo {
- filesInfo[i].moduleName = ctx.ModuleName() + "." + filesInfo[i].moduleName
+ filesInfo[i].moduleName = filesInfo[i].moduleName + "." + ctx.ModuleName()
}
a.installDir = android.PathForModuleInstall(ctx, "apex")
@@ -1563,7 +1562,7 @@
if a.installable() {
// For flattened APEX, do nothing but make sure that apex_manifest.json and apex_pubkey are also copied along
// with other ordinary files.
- a.filesInfo = append(a.filesInfo, apexFile{a.manifestOut, ctx.ModuleName() + ".apex_manifest.json", ".", etc, nil, nil})
+ a.filesInfo = append(a.filesInfo, apexFile{a.manifestOut, "apex_manifest.json." + ctx.ModuleName(), ".", etc, nil, nil})
// rename to apex_pubkey
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
@@ -1572,7 +1571,7 @@
Input: a.public_key_file,
Output: copiedPubkey,
})
- a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, ctx.ModuleName() + ".apex_pubkey", ".", etc, nil, nil})
+ a.filesInfo = append(a.filesInfo, apexFile{copiedPubkey, "apex_pubkey." + ctx.ModuleName(), ".", etc, nil, nil})
if ctx.Config().FlattenApex() {
apexName := proptools.StringDefault(a.properties.Apex_name, ctx.ModuleName())
@@ -1812,19 +1811,18 @@
}{
proptools.StringPtr("both"),
})
-
- vndkVersion := proptools.StringDefault(bundle.vndkProperties.Vndk_version, "current")
- if vndkVersion == "current" {
- vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
- bundle.vndkProperties.Vndk_version = proptools.StringPtr(vndkVersion)
- }
-
- // Ensure VNDK APEX mount point is formatted as com.android.vndk.v###
- bundle.properties.Apex_name = proptools.StringPtr("com.android.vndk.v" + vndkVersion)
})
return bundle
}
+func (a *apexBundle) vndkVersion(config android.DeviceConfig) string {
+ vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current")
+ if vndkVersion == "current" {
+ vndkVersion = config.PlatformVndkVersion()
+ }
+ return vndkVersion
+}
+
//
// Defaults
//