Remove global state from apex modules
A global variant was used to store the global mapping between
modules and APEXes. Replace it with storing pointers to APEX
contents inside each module so that they can query the contents
of any APEXes they belong to.
Bug: 146393795
Test: all Soong tests
Test: single line change to build.ninja host install dependency ordering
Test: no Android-${TARGET_PRODUCT}.mk, make_vars-${TARGET_PRODUCT}.mk or late-${TARGET_PRODUCT}.mk
Change-Id: Id2d7b73ea27f8c3b41d30820bdd86b65c539bfa4
diff --git a/cc/vndk.go b/cc/vndk.go
index 9a2fa09..4169e21 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -300,6 +300,7 @@
if !Bool(lib.Properties.Vendor_available) {
vndkPrivateLibraries(mctx.Config())[name] = filename
}
+
if mctx.OtherModuleExists(name) {
mctx.AddFarVariationDependencies(m.Target().Variations(), llndkImplDep, name)
}
@@ -533,11 +534,13 @@
vndkSnapshotZipFile android.OptionalPath
}
-func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module) (i snapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) {
+func isVndkSnapshotLibrary(config android.DeviceConfig, m *Module,
+ apexInfo android.ApexInfo) (i snapshotLibraryInterface, vndkType string, isVndkSnapshotLib bool) {
+
if m.Target().NativeBridge == android.NativeBridgeEnabled {
return nil, "", false
}
- if !m.inVendor() || !m.installable() || m.isSnapshotPrebuilt() {
+ if !m.inVendor() || !m.installable(apexInfo) || m.isSnapshotPrebuilt() {
return nil, "", false
}
l, ok := m.linker.(snapshotLibraryInterface)
@@ -659,7 +662,9 @@
return
}
- l, vndkType, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m)
+ apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
+
+ l, vndkType, ok := isVndkSnapshotLibrary(ctx.DeviceConfig(), m, apexInfo)
if !ok {
return
}
@@ -823,14 +828,21 @@
func (c *vndkSnapshotSingleton) MakeVars(ctx android.MakeVarsContext) {
// Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to avoid installing libraries on /system if
// they been moved to an apex.
- movedToApexLlndkLibraries := []string{}
- for lib := range llndkLibraries(ctx.Config()) {
- // Skip bionic libs, they are handled in different manner
- if android.DirectlyInAnyApex(¬OnHostContext{}, lib) && !isBionic(lib) {
- movedToApexLlndkLibraries = append(movedToApexLlndkLibraries, lib)
+ 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 := m.BaseModuleName()
+ if llndk.movedToApex && !isBionic(m.BaseModuleName()) {
+ movedToApexLlndkLibraries[name] = true
+ }
+ }
}
- }
- ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", strings.Join(movedToApexLlndkLibraries, " "))
+ })
+
+ ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES",
+ strings.Join(android.SortedStringKeys(movedToApexLlndkLibraries), " "))
// Make uses LLNDK_LIBRARIES to determine which libraries to install.
// HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.