From fcf232085dd2cad246aad54a43d81f51fc38e468 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Sun, 7 Nov 2021 06:34:59 -0800 Subject: [PATCH] extract: Preserve file extension if not used for type --- src/build/soong.ts | 9 +++++++++ src/commands/extract.ts | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/build/soong.ts b/src/build/soong.ts index 8b89cf0..a2f629a 100644 --- a/src/build/soong.ts +++ b/src/build/soong.ts @@ -2,6 +2,15 @@ import * as util from 'util' import { BlobEntry, partPathToSrcPath } from '../blobs/entry' +export const SPECIAL_FILE_EXTENSIONS = new Set([ + '.sh', + '.so', + '.apk', + '.jar', + '.xml', + '.apex', +]) + export interface TargetSrcs { srcs: Array } diff --git a/src/commands/extract.ts b/src/commands/extract.ts index 635d572..e712a65 100644 --- a/src/commands/extract.ts +++ b/src/commands/extract.ts @@ -3,7 +3,7 @@ import {promises as fs} from 'fs' import * as path from 'path' import * as chalk from 'chalk' -import { blobToSoongModule, serializeBlueprint, SharedLibraryModule, SoongModule } from '../build/soong' +import { blobToSoongModule, serializeBlueprint, SharedLibraryModule, SoongModule, SPECIAL_FILE_EXTENSIONS } from '../build/soong' import { BlobEntry, blobNeedsSoong } from '../blobs/entry' import { parseFileList } from '../blobs/file_list' import { copyBlobs } from '../blobs/copy' @@ -35,8 +35,9 @@ async function generateBuild( if (blobNeedsSoong(entry, ext)) { // Named dependencies -> Soong blueprint - // Module name = file name - let name = path.basename(entry.path, ext) + // Module name = file name, excluding extension if it was used + let baseExt = SPECIAL_FILE_EXTENSIONS.has(ext) ? ext : undefined + let name = path.basename(entry.path, baseExt) // If already exists: skip if it's the other arch variant of a library, // otherwise rename the module to avoid conflict