extract: Preserve file extension if not used for type

This commit is contained in:
Danny Lin 2021-11-07 06:34:59 -08:00
parent ac207243b0
commit fcf232085d
2 changed files with 13 additions and 3 deletions

View file

@ -2,6 +2,15 @@ import * as util from 'util'
import { BlobEntry, partPathToSrcPath } from '../blobs/entry' import { BlobEntry, partPathToSrcPath } from '../blobs/entry'
export const SPECIAL_FILE_EXTENSIONS = new Set([
'.sh',
'.so',
'.apk',
'.jar',
'.xml',
'.apex',
])
export interface TargetSrcs { export interface TargetSrcs {
srcs: Array<string> srcs: Array<string>
} }

View file

@ -3,7 +3,7 @@ import {promises as fs} from 'fs'
import * as path from 'path' import * as path from 'path'
import * as chalk from 'chalk' 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 { BlobEntry, blobNeedsSoong } from '../blobs/entry'
import { parseFileList } from '../blobs/file_list' import { parseFileList } from '../blobs/file_list'
import { copyBlobs } from '../blobs/copy' import { copyBlobs } from '../blobs/copy'
@ -35,8 +35,9 @@ async function generateBuild(
if (blobNeedsSoong(entry, ext)) { if (blobNeedsSoong(entry, ext)) {
// Named dependencies -> Soong blueprint // Named dependencies -> Soong blueprint
// Module name = file name // Module name = file name, excluding extension if it was used
let name = path.basename(entry.path, ext) 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, // If already exists: skip if it's the other arch variant of a library,
// otherwise rename the module to avoid conflict // otherwise rename the module to avoid conflict