Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/commands/generate-all.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Command, Flags } from '@oclif/core'
import { Command, Errors, Flags } from '@oclif/core'
import chalk from 'chalk'
import { CopyOptions, promises as fs } from 'fs'
import path from 'path'
Expand Down Expand Up @@ -54,6 +54,7 @@ import { deleteUnpackedDeviceImages, DeviceImages, prepareDeviceImages } from '.
import { BuildIndex, ImageType, loadBuildIndex } from '../images/build-index'
import { APK_PARSER_CONFIG_DIR_NAME, processApks } from '../processor/apk-processor'
import { processSystemServerClassPaths } from '../processor/classpath'
import { checkBackportedElfs } from '../processor/elf'
import { processSepolicy } from '../processor/sepolicy'
import { processSysconfig } from '../processor/sysconfig'
import { processVintf } from '../processor/vintf'
Expand All @@ -79,10 +80,12 @@ async function doDevice(
dirs: VendorDirectories,
config: DeviceConfig,
pathResolver: PathResolver,
kernelPathResolver: PathResolver,
customSrc: string,
verbose: boolean,
skipElfChecks: boolean,
) {
let kernelCopy = copyKernel(pathResolver, dirs)
let kernelCopy = copyKernel(kernelPathResolver, dirs)

// customSrc can point to a (directory containing) system state JSON
let customState = await loadCustomState(config, customSrc)
Expand Down Expand Up @@ -125,6 +128,19 @@ async function doDevice(
// modifies entries array, needs await
let systemServerCpJars = await processSystemServerClassPaths(entries, pathResolver, customState)

if (pathResolver.overlay !== undefined && !skipElfChecks) {
if (verbose) log('Checking backported ELF files')
let elfIssues = await checkBackportedElfs(entries, pathResolver, [
...customState.extraModules,
...config.extra_packages,
])
if (elfIssues !== null) {
// oclif reformats multi-line error messages, so log before exiting
log(elfIssues)
Errors.exit(1)
}
}

if (verbose) log('Copying blobs')
let copyBlobsPromise = copyBlobs(
entries,
Expand Down Expand Up @@ -206,6 +222,8 @@ export default class GenerateFull extends Command {
default: [],
}),

skipElfChecks: Flags.boolean({}),

...DEVICE_CONFIGS_FLAG_WITH_BUILD_ID,
}

Expand All @@ -229,6 +247,7 @@ export default class GenerateFull extends Command {
let images: Map<DeviceBuildId, DeviceImages> = await prepareDeviceImages(index, [ImageType.Factory], [config])
let deviceImages = mapGet(images, getDeviceBuildId(config))
let pathResolver = new PathResolver(deviceImages.unpackedFactoryImageDir)
let kernelPathResolver = new PathResolver(deviceImages.unpackedFactoryImageDir)
let backportBuildId = config.device.backport_build_id
if (backportBuildId !== undefined) {
let backportDeviceImages = mapGet(images, getDeviceBuildId(config, backportBuildId))
Expand Down Expand Up @@ -260,11 +279,15 @@ export default class GenerateFull extends Command {
fileOverlays,
fileOverlaysByDir,
}

if (config.device.backport_kernel) {
kernelPathResolver = new PathResolver(backportDeviceImages.unpackedFactoryImageDir)
}
}
// Prepare output directories
let vendorDirs = await createVendorDirs(config.device.vendor, config.device.name)

let deviceInfo = await doDevice(vendorDirs, config, pathResolver, flags.customSrc, flags.verbose)
let deviceInfo = await doDevice(vendorDirs, config, pathResolver, kernelPathResolver, flags.customSrc, flags.verbose, flags.skipElfChecks)

if (!flags.doNotReplaceCarrierSettings) {
if (flags.updateSpec && config.device.has_cellular && !flags.doNotDownloadCarrierSettings) {
Expand Down
1 change: 1 addition & 0 deletions src/config/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface DeviceConfig {
backport_build_id: string | undefined
is_beta_backport_build_id: boolean
backport_base_firmware?: boolean
backport_kernel?: boolean
prev_build_id: string
has_cellular: boolean
// ignored when undefined
Expand Down
7 changes: 0 additions & 7 deletions src/frontend/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,6 @@ export async function generateBuildFiles(
resolvedName += `__${conflictNum}`
}

if (config.device.backport_build_id !== undefined) {
if (resolvedName === 'libc++' || resolvedName === 'libaconfig_storage_read_api_cc') {
copyFiles.push(blobToFileCopy(entry, dirs.proprietary))
continue
}
}

let module = blobToSoongModule(
config,
resolvedName,
Expand Down
Loading