From ab3cc0d13c1b22d60d9dacbaa94701ec1cecb761 Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Sat, 14 Oct 2023 18:52:30 +0300 Subject: [PATCH] add support for specifying PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS See https://android.googlesource.com/platform/build/+/da2d4a29bf21e0375b40d2654619e529978cf97f --- src/build/make.ts | 6 ++++++ src/commands/generate-all.ts | 9 +++++++++ src/commands/generate-prep.ts | 2 +- src/config/device.ts | 2 ++ src/frontend/generate.ts | 5 +++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/build/make.ts b/src/build/make.ts index 3d61f04..ed068cd 100644 --- a/src/build/make.ts +++ b/src/build/make.ts @@ -52,6 +52,8 @@ export interface DeviceMakefile { vintfManifestPaths?: Map + vendorLinkerConfigPath?: string + props?: PartitionProps fingerprint?: string enforceRros?: string @@ -193,6 +195,10 @@ export function serializeDeviceMakefile(mk: DeviceMakefile) { } } + if (mk.vendorLinkerConfigPath !== undefined) { + blocks.push(`PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS += ${mk.vendorLinkerConfigPath}`) + } + if (mk.props != undefined) { for (let [partition, props] of mk.props.entries()) { if (props.size == 0) { diff --git a/src/commands/generate-all.ts b/src/commands/generate-all.ts index ef203cb..b8369f8 100644 --- a/src/commands/generate-all.ts +++ b/src/commands/generate-all.ts @@ -146,6 +146,14 @@ const doDevice = ( ) } + let vendorLinkerConfig = config.platform.vendor_linker_config + let vendorLinkerConfigPath: string | null = null + if (Object.keys(vendorLinkerConfig).length > 0) { + let json = JSON.stringify(vendorLinkerConfig, null, 4) + vendorLinkerConfigPath = path.join(dirs.proprietary, 'linker-config-adevtool.json') + await fs.writeFile(vendorLinkerConfigPath, json) + } + // 11. Build files await withSpinner('Generating build files', () => generateBuildFiles( @@ -156,6 +164,7 @@ const doDevice = ( propResults, fwPaths, vintfManifestPaths, + vendorLinkerConfigPath, sepolicyResolutions, stockSrc, ), diff --git a/src/commands/generate-prep.ts b/src/commands/generate-prep.ts index 6b14415..6661b6f 100644 --- a/src/commands/generate-prep.ts +++ b/src/commands/generate-prep.ts @@ -67,7 +67,7 @@ const doDevice = ( // 4. Build files await withSpinner('Generating build files', () => - generateBuildFiles(config, dirs, entries, [], propResults, null, null, null, stockSrc, false, true), + generateBuildFiles(config, dirs, entries, [], propResults, null, null, null, null, stockSrc, false, true), ) await writeEnvsetupCommands(config, dirs) diff --git a/src/config/device.ts b/src/config/device.ts index 9c1ae17..c2e31cc 100644 --- a/src/config/device.ts +++ b/src/config/device.ts @@ -40,6 +40,7 @@ export interface DeviceConfig { product_makefile: string // required // not included in makefile for state collection build (generate-prep) extra_product_makefiles: string[] + vendor_linker_config: object } generate: { @@ -102,6 +103,7 @@ const DEFAULT_CONFIG_BASE = { namespaces: [], sepolicy_dirs: [], extra_product_makefiles: [], + vendor_linker_config: {}, }, generate: { overrides: true, diff --git a/src/frontend/generate.ts b/src/frontend/generate.ts index b2008fc..d36fc9e 100644 --- a/src/frontend/generate.ts +++ b/src/frontend/generate.ts @@ -295,6 +295,7 @@ export async function generateBuildFiles( propResults: PropResults | null, fwPaths: string[] | null, vintfManifestPaths: Map | null, + vendorLinkerConfigPath: string | null, sepolicyResolutions: SelinuxPartResolutions | null, stockSrc: string, addAbOtaParts = true, @@ -306,6 +307,10 @@ export async function generateBuildFiles( build.deviceMakefile!.packages!.push(...buildPkgs) build.deviceMakefile!.packages!.sort((a, b) => a.localeCompare(b)) + if (vendorLinkerConfigPath !== null) { + build.deviceMakefile!.vendorLinkerConfigPath = vendorLinkerConfigPath + } + // Add device parts build.deviceMakefile = { props: propResults?.missingProps,