From 2e20befcd49b9082cf5fff206a6d6e86ed38c97b Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Sun, 7 Nov 2021 06:10:58 -0800 Subject: [PATCH] extract: Prioritize explicit named dependencies in conflict resolution --- src/commands/extract.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/commands/extract.ts b/src/commands/extract.ts index e623874..c1c7c28 100644 --- a/src/commands/extract.ts +++ b/src/commands/extract.ts @@ -9,6 +9,10 @@ import { parseFileList } from '../blobs/file_list' import { copyBlobs } from '../blobs/copy' import { blobToFileCopy, serializeProductMakefile } from '../build/make' +function nameDepKey(entry: BlobEntry) { + return `${entry.isNamedDependency ? 0 : 1}${entry.srcPath}` +} + async function generateBuild( entries: Array, vendor: string, @@ -16,6 +20,10 @@ async function generateBuild( outDir: string, proprietaryDir: string, ) { + // Re-sort entries to give priority to explicit named dependencies in name + // conflict resolution + entries = Array.from(entries).sort((a, b) => nameDepKey(a).localeCompare(nameDepKey(b))) + // Fast lookup for other arch libs let entrySrcPaths = new Set(entries.map(e => e.srcPath))