build: Fix multilib override resolution for 64/32-bit only

This commit is contained in:
Danny Lin 2021-12-17 18:01:03 -08:00
parent 45ade060d8
commit 6e923438f1

View file

@ -1,3 +1,4 @@
import { setIntersection } from '../util/data'
import { parseLines } from '../util/parse'
import { SoongModuleInfo, TargetModuleInfo } from './soong-info'
@ -20,11 +21,19 @@ export function parseOverrides(list: string) {
}
export function findOverrideModules(overridePaths: Iterable<string>, modulesMap: SoongModuleInfo) {
// Build index of multilib modules
let multilibs = new Set<string>()
for (let [name, module] of modulesMap.entries()) {
if (name.endsWith('_32')) {
multilibs.add(module.module_name)
}
}
// Build installed path->module index
let pathMap = new Map<string, TargetModuleInfo>()
for (let module of modulesMap.values()) {
let pathMap = new Map<string, [string, string]>()
for (let [key, module] of modulesMap.entries()) {
for (let path of module.installed) {
pathMap.set(path, module)
pathMap.set(path, [key, module.module_name])
}
}
@ -32,16 +41,51 @@ export function findOverrideModules(overridePaths: Iterable<string>, modulesMap:
let buildModules = new Set<string>()
let builtPaths = []
let missingPaths = []
// Defer multlib modules (these are module_names without _32 or :32/:64)
let multilib32 = new Set<string>()
let multilib64 = new Set<string>()
for (let path of overridePaths) {
let module = pathMap.get(path)
if (module != null) {
buildModules.add(module.module_name)
let value = pathMap.get(path)
if (value != null) {
let [key, module] = value
if (multilibs.has(module)) {
// If this module is multilib, add it to the respective arch set instead
if (key.endsWith('_32')) {
// 32-bit only
multilib32.add(module)
} else {
// 64-bit only
multilib64.add(module)
}
} else {
// Otherwise, just build the module normally
buildModules.add(module)
}
// Always add the path
builtPaths.push(path)
} else {
missingPaths.push(path)
}
}
// Now resolve the multilib modules. Example:
// Both = libX
let multilibBoth = setIntersection(multilib32, multilib64)
// Then separate the remaining arch-specific modules (faster than new set difference)
multilibBoth.forEach(m => {
// 32 = libX:32
multilib32.delete(m)
// 64 = libX:64
multilib64.delete(m)
})
// Add final multilib modules
multilibBoth.forEach(m => buildModules.add(m))
multilib32.forEach(m => buildModules.add(m + ':32'))
multilib64.forEach(m => buildModules.add(m + ':64'))
return {
modules: Array.from(buildModules).sort((a, b) => a.localeCompare(b)),
builtPaths: builtPaths,