Don't rewrite LLNDK dependencies with .llndk suffix
Rewriting LLNDK dependencies with .llndk suffix requries referencing
a global data structure to determine if a given library is an LLNDK
library and therefore needs the .llndk suffix. References to
global data structures from mutators must be removed to support
incremental Soong analysis. Instead, move the LLNDK stubs rules
into the vendor variant of the implementing cc_library so that
the original name can be used.
As an incremental step, the llndk_library modules are left in
place, and the properties are copied into the cc_library via
the dependency specified by the llndk_stub property. A followup
will move the LLNDK properties directly into the cc_library and
delete the llndk_library modules.
The global list of LLNDK libraries is kept for now as it is used
to generate the vndk.libraries.txt file.
Bug: 170784825
Test: m checkbuild
Test: compare Soong outputs
Test: all Soong tests
Change-Id: I2a942b21c162541a49e27b2e5833c9aebccff1d0
diff --git a/cc/vndk.go b/cc/vndk.go
index 1529ac5..c1bce16 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -156,9 +156,15 @@
}
if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() {
// Check only shared libraries.
- // Other (static and LL-NDK) libraries are allowed to link.
+ // Other (static) libraries are allowed to link.
return
}
+
+ if to.IsLlndk() {
+ // LL-NDK libraries are allowed to link
+ return
+ }
+
if !to.UseVndk() {
ctx.ModuleErrorf("(%s) should not link to %q which is not a vendor-available library",
vndk.typeName(), to.Name())
@@ -250,22 +256,12 @@
}).(map[string]string)
}
-func isLlndkLibrary(baseModuleName string, config android.Config) bool {
- _, ok := llndkLibraries(config)[strings.TrimSuffix(baseModuleName, llndkLibrarySuffix)]
- return ok
-}
-
func llndkLibraries(config android.Config) map[string]string {
return config.Once(llndkLibrariesKey, func() interface{} {
return make(map[string]string)
}).(map[string]string)
}
-func isVndkPrivateLibrary(baseModuleName string, config android.Config) bool {
- _, ok := vndkPrivateLibraries(config)[baseModuleName]
- return ok
-}
-
func vndkPrivateLibraries(config android.Config) map[string]string {
return config.Once(vndkPrivateLibrariesKey, func() interface{} {
return make(map[string]string)
@@ -301,12 +297,10 @@
defer vndkLibrariesLock.Unlock()
llndkLibraries(mctx.Config())[name] = filename
+ m.VendorProperties.IsLLNDK = true
if !Bool(lib.Properties.Vendor_available) {
vndkPrivateLibraries(mctx.Config())[name] = filename
- }
-
- if mctx.OtherModuleExists(name) {
- mctx.AddFarVariationDependencies(m.Target().Variations(), llndkImplDep, name)
+ m.VendorProperties.IsLLNDKPrivate = true
}
}
@@ -410,9 +404,31 @@
return
}
+ // This is a temporary measure to copy the properties from an llndk_library into the cc_library
+ // that will actually build the stubs. It will be removed once the properties are moved into
+ // the cc_library in the Android.bp files.
+ mergeLLNDKToLib := func(llndk *Module, llndkProperties *llndkLibraryProperties, flagExporter *flagExporter) {
+ if llndkLib := moduleLibraryInterface(llndk); llndkLib != nil {
+ *llndkProperties = llndkLib.(*llndkStubDecorator).Properties
+ flagExporter.Properties = llndkLib.(*llndkStubDecorator).flagExporter.Properties
+
+ m.VendorProperties.IsLLNDK = llndk.VendorProperties.IsLLNDK
+ m.VendorProperties.IsLLNDKPrivate = llndk.VendorProperties.IsLLNDKPrivate
+ }
+ }
+
lib, is_lib := m.linker.(*libraryDecorator)
prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker)
+ if m.UseVndk() && is_lib && lib.hasLLNDKStubs() {
+ llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(lib.Properties.Llndk_stubs))
+ mergeLLNDKToLib(llndk[0].(*Module), &lib.Properties.Llndk, &lib.flagExporter)
+ }
+ if m.UseVndk() && is_prebuilt_lib && prebuilt_lib.hasLLNDKStubs() {
+ llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(prebuilt_lib.Properties.Llndk_stubs))
+ mergeLLNDKToLib(llndk[0].(*Module), &prebuilt_lib.Properties.Llndk, &prebuilt_lib.flagExporter)
+ }
+
if (is_lib && lib.buildShared()) || (is_prebuilt_lib && prebuilt_lib.buildShared()) {
if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
processVndkLibrary(mctx, m)
@@ -819,13 +835,11 @@
// they been moved to an apex.
movedToApexLlndkLibraries := make(map[string]bool)
ctx.VisitAllModules(func(module android.Module) {
- if m, ok := module.(*Module); ok {
- if llndk, ok := m.linker.(*llndkStubDecorator); ok {
- // Skip bionic libs, they are handled in different manner
- name := llndk.implementationModuleName(m.BaseModuleName())
- if llndk.movedToApex && !isBionic(name) {
- movedToApexLlndkLibraries[name] = true
- }
+ if library := moduleLibraryInterface(module); library != nil && library.hasLLNDKStubs() {
+ // Skip bionic libs, they are handled in different manner
+ name := library.implementationModuleName(module.(*Module).BaseModuleName())
+ if module.(android.ApexModule).DirectlyInAnyApex() && !isBionic(name) {
+ movedToApexLlndkLibraries[name] = true
}
}
})