Revert "Revert "Enforce min_sdk_version of apex(use_vendor:true)""
This reverts commit bacf34d986011a37dc45ebbd59d464950cd7574d.
Reason for revert: reland with fix
Change-Id: Ia03f2808353f5640597ae7ecbf2e06fc903c6977
diff --git a/cc/library.go b/cc/library.go
index 346e7d8..040e509 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1487,6 +1487,19 @@
}
}
+func createVersionVariations(mctx android.BottomUpMutatorContext, versions []string) {
+ // "" is for the non-stubs variant
+ versions = append([]string{""}, versions...)
+
+ modules := mctx.CreateVariations(versions...)
+ for i, m := range modules {
+ if versions[i] != "" {
+ m.(LinkableInterface).SetBuildStubs()
+ m.(LinkableInterface).SetStubsVersions(versions[i])
+ }
+ }
+}
+
// Version mutator splits a module into the mandatory non-stubs variant
// (which is unnamed) and zero or more stubs variants.
func VersionMutator(mctx android.BottomUpMutatorContext) {
@@ -1498,24 +1511,30 @@
return
}
- // save the list of versions for later use
stubsVersionsLock.Lock()
defer stubsVersionsLock.Unlock()
+ // save the list of versions for later use
stubsVersionsFor(mctx.Config())[mctx.ModuleName()] = versions
- // "" is for the non-stubs variant
- versions = append([]string{""}, versions...)
-
- modules := mctx.CreateVariations(versions...)
- for i, m := range modules {
- if versions[i] != "" {
- m.(LinkableInterface).SetBuildStubs()
- m.(LinkableInterface).SetStubsVersions(versions[i])
- }
- }
- } else {
- mctx.CreateVariations("")
+ createVersionVariations(mctx, versions)
+ return
}
+
+ if c, ok := library.(*Module); ok && c.IsStubs() {
+ stubsVersionsLock.Lock()
+ defer stubsVersionsLock.Unlock()
+ // For LLNDK llndk_library, we borrow vstubs.ersions from its implementation library.
+ // Since llndk_library has dependency to its implementation library,
+ // we can safely access stubsVersionsFor() with its baseModuleName.
+ versions := stubsVersionsFor(mctx.Config())[c.BaseModuleName()]
+ // save the list of versions for later use
+ stubsVersionsFor(mctx.Config())[mctx.ModuleName()] = versions
+
+ createVersionVariations(mctx, versions)
+ return
+ }
+
+ mctx.CreateVariations("")
return
}
if genrule, ok := mctx.Module().(*genrule.Module); ok {