diff --git a/src/blobs/entry.ts b/src/blobs/entry.ts index 9302a87..3337284 100644 --- a/src/blobs/entry.ts +++ b/src/blobs/entry.ts @@ -1,4 +1,6 @@ -import { EXT_PARTITIONS } from "../partitions"; +import * as path from 'path' + +import { EXT_PARTITIONS } from '../partitions'; export interface BlobEntry { partition: string @@ -16,3 +18,24 @@ export function partPathToSrcPath(partition: string, path: string) { return path } } + +export function blobNeedsSoong(entry: BlobEntry, ext: string) { + // Explicit named dependency = Soong + if (entry.isNamedDependency) { + return true + } + + // On Android 12, Soong is required for ELF files (executables and libraries) + if (entry.path.startsWith('bin/') || ext == '.so') { + return true + } + + // Soong is also required for APKs, framework JARs, and vintf XMLs + if (ext == '.apk' || ext == '.jar' || + (entry.path.startsWith('etc/vintf/') && ext == '.xml')) { + return true + } + + // Otherwise, just copy the file + return false +} diff --git a/src/commands/extract.ts b/src/commands/extract.ts index 9f9c67c..e623874 100644 --- a/src/commands/extract.ts +++ b/src/commands/extract.ts @@ -4,7 +4,7 @@ import * as path from 'path' import * as chalk from 'chalk' import { blobToSoongModule, serializeBlueprint, SharedLibraryModule, SoongModule } from '../build/soong' -import { BlobEntry } from '../blobs/entry' +import { BlobEntry, blobNeedsSoong } from '../blobs/entry' import { parseFileList } from '../blobs/file_list' import { copyBlobs } from '../blobs/copy' import { blobToFileCopy, serializeProductMakefile } from '../build/make' @@ -26,8 +26,7 @@ async function generateBuild( for (let entry of entries) { let ext = path.extname(entry.path) - // On Android 12, Soong is required for ELF files (executables and libraries) - if (entry.isNamedDependency || entry.path.startsWith('bin/') || ext == '.so') { + if (blobNeedsSoong(entry, ext)) { // Named dependencies -> Soong blueprint // Module name = file name