Remove global state from VNDK apexes
Use the name of the apex instead of a global map to find the right
VNDK apex for each VNDK version.
Bug: 181689854
Test: apex tests
Change-Id: If9f8fb10d09e125c9e7d44228e1aa746bf53c082
diff --git a/apex/vndk.go b/apex/vndk.go
index f4b12b5..75c0fb0 100644
--- a/apex/vndk.go
+++ b/apex/vndk.go
@@ -17,7 +17,6 @@
import (
"path/filepath"
"strings"
- "sync"
"android/soong/android"
"android/soong/cc"
@@ -60,17 +59,6 @@
Vndk_version *string
}
-var (
- vndkApexListKey = android.NewOnceKey("vndkApexList")
- vndkApexListMutex sync.Mutex
-)
-
-func vndkApexList(config android.Config) map[string]string {
- return config.Once(vndkApexListKey, func() interface{} {
- return map[string]string{}
- }).(map[string]string)
-}
-
func apexVndkMutator(mctx android.TopDownMutatorContext) {
if ab, ok := mctx.Module().(*apexBundle); ok && ab.vndkApex {
if ab.IsNativeBridgeSupported() {
@@ -80,15 +68,6 @@
vndkVersion := ab.vndkVersion(mctx.DeviceConfig())
// Ensure VNDK APEX mount point is formatted as com.android.vndk.v###
ab.properties.Apex_name = proptools.StringPtr(vndkApexNamePrefix + 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)
- }
- vndkApexList[vndkVersion] = mctx.ModuleName()
}
}
@@ -99,9 +78,16 @@
if vndkVersion == "" {
vndkVersion = mctx.DeviceConfig().PlatformVndkVersion()
}
- vndkApexList := vndkApexList(mctx.Config())
- if vndkApex, ok := vndkApexList[vndkVersion]; ok {
- mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApex)
+ if vndkVersion == mctx.DeviceConfig().PlatformVndkVersion() {
+ vndkVersion = "current"
+ } else {
+ vndkVersion = "v" + vndkVersion
+ }
+
+ vndkApexName := "com.android.vndk." + vndkVersion
+
+ if mctx.OtherModuleExists(vndkApexName) {
+ mctx.AddReverseDependency(mctx.Module(), sharedLibTag, vndkApexName)
}
} else if a, ok := mctx.Module().(*apexBundle); ok && a.vndkApex {
vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current")