extract: Handle module name conflicts
This commit is contained in:
parent
4c815172d4
commit
783129d138
1 changed files with 14 additions and 3 deletions
|
@ -3,7 +3,7 @@ import {promises as fs} from 'fs'
|
|||
import * as path from 'path'
|
||||
import * as chalk from 'chalk'
|
||||
|
||||
import { blobToSoongModule, serializeBlueprint, SoongModule } from '../build/soong'
|
||||
import { blobToSoongModule, serializeBlueprint, SharedLibraryModule, SoongModule } from '../build/soong'
|
||||
import { BlobEntry } from '../blobs/entry'
|
||||
import { parseFileList } from '../blobs/file_list'
|
||||
import { copyBlobs } from '../blobs/copy'
|
||||
|
@ -22,6 +22,7 @@ async function generateBuild(
|
|||
// Create Soong modules and Make rules
|
||||
let copyFiles = []
|
||||
let namedModules = new Map<string, SoongModule>()
|
||||
let conflictCounters = new Map<string, number>()
|
||||
for (let entry of entries) {
|
||||
let ext = path.extname(entry.path)
|
||||
|
||||
|
@ -32,9 +33,19 @@ async function generateBuild(
|
|||
// Module name = file name
|
||||
let name = path.basename(entry.path, ext)
|
||||
|
||||
// Skip if already done (e.g. other lib arch)
|
||||
// If already exists: skip if it's the other arch variant of a library,
|
||||
// otherwise rename the module to avoid conflict
|
||||
if (namedModules.has(name)) {
|
||||
continue
|
||||
let conflictModule = namedModules.get(name)!
|
||||
if (conflictModule._type == 'cc_prebuilt_library_shared' &&
|
||||
(conflictModule as SharedLibraryModule).compile_multilib == 'both') {
|
||||
continue
|
||||
}
|
||||
|
||||
// Increment conflict counter and append to name
|
||||
let conflictNum = (conflictCounters.get(name) ?? 1) + 1
|
||||
conflictCounters.set(name, conflictNum)
|
||||
name += `__${conflictNum}`
|
||||
}
|
||||
|
||||
let module = blobToSoongModule(name, ext, vendor, entry, entrySrcPaths)
|
||||
|
|
Loading…
Reference in a new issue