From 148c26ee55abd0e631498d4f6d82753dac4280c8 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Wed, 11 Jan 2023 02:41:43 -0500 Subject: [PATCH] Clean up zig behaviors --- cli/src/build.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index fe8059f417..036ed979dd 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -309,11 +309,12 @@ export class BuildCommand extends Command { if (rustflags.length > 0) { additionalEnv['RUSTFLAGS'] = rustflags.join(' ') } - let isZigExisted = false - if (isCrossForLinux || isCrossForMacOS) { + + let useZig = false + if (this.useZig || isCrossForLinux || isCrossForMacOS) { try { execSync('zig version') - isZigExisted = true + useZig = true } catch (e) { if (this.useZig) { throw new TypeError( @@ -329,15 +330,15 @@ export class BuildCommand extends Command { } } - if ((this.useZig || isCrossForLinux || isCrossForMacOS) && isZigExisted) { + if (useZig) { const zigABIVersion = - this.zigABIVersion ?? (isCrossForLinux && triple.abi === 'gnu') - ? DEFAULT_GLIBC_TARGET - : null + this.zigABIVersion ?? + (isCrossForLinux && triple.abi === 'gnu' ? DEFAULT_GLIBC_TARGET : null) const mappedZigTarget = ZIG_PLATFORM_TARGET_MAP[triple.raw] const zigTarget = `${mappedZigTarget}${ zigABIVersion ? `.${zigABIVersion}` : '' }` + debug(`Using Zig with target ${chalk.green(zigTarget)}`) if (!mappedZigTarget) { throw new Error(`${triple.raw} can not be cross compiled by zig`) }