From bc41c9778f152aba9663b105f8259c3a3bb692a2 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 19 Dec 2022 23:05:18 +0800 Subject: [PATCH] feat(cli): add --zig-link-only option (#1400) --- cli/src/build.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index d043cd82..4bb814d8 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -191,6 +191,10 @@ export class BuildCommand extends Command { )} ${chalk.green('--zig-abi-suffix=2.17')}`, }) + zigLinkOnly = Option.Boolean(`--zig-link-only`, false, { + description: `Only link the library with ${chalk.green('zig')}`, + }) + isStrip = Option.Boolean(`--strip`, false, { description: `${chalk.green('Strip')} the library for minimum file size`, }) @@ -402,12 +406,14 @@ export class BuildCommand extends Command { }, ) const envTarget = triple.raw.replaceAll('-', '_').toUpperCase() - Object.assign(additionalEnv, { - CC: CCWrapperShell, - CXX: CXXWrapperShell, - TARGET_CC: CCWrapperShell, - TARGET_CXX: CXXWrapperShell, - }) + if (!this.zigLinkOnly) { + Object.assign(additionalEnv, { + CC: CCWrapperShell, + CXX: CXXWrapperShell, + TARGET_CC: CCWrapperShell, + TARGET_CXX: CXXWrapperShell, + }) + } additionalEnv[`CARGO_TARGET_${envTarget}_LINKER`] = linkerWrapperShell } debug(`Platform: ${JSON.stringify(triple, null, 2)}`)