From d84cbe88bdcaadbc0b57c6b49b9d84e22020cf34 Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 13 Jan 2022 21:34:59 +0800 Subject: [PATCH] fix(cli): properly handle RUSTFLAGS env var --- cli/src/build.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index eadf8a05..c2bbc5ed 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -211,19 +211,21 @@ export class BuildCommand extends Command { }) } - let rustflags = process.env.RUSTFLAGS ?? '' + const rustflags = process.env.RUSTFLAGS + ? process.env.RUSTFLAGS.split(' ') + : [] if (triple.raw.includes('musl')) { if (!rustflags.includes('target-feature=-crt-static')) { - rustflags += '-C target-feature=-crt-static' + rustflags.push('-C target-feature=-crt-static') } } if (this.isStrip && !rustflags.includes('-C link-arg=-s')) { - rustflags += '-C link-arg=-s' + rustflags.push('-C link-arg=-s') } if (rustflags.length > 0) { - additionalEnv['RUSTFLAGS'] = rustflags + additionalEnv['RUSTFLAGS'] = rustflags.join(' ') } if (this.useZig) {