fix(cli): cleanup zig behaviors (#1432)
This commit is contained in:
parent
38390dbef9
commit
84921fc0a3
1 changed files with 8 additions and 7 deletions
|
@ -309,11 +309,12 @@ export class BuildCommand extends Command {
|
||||||
if (rustflags.length > 0) {
|
if (rustflags.length > 0) {
|
||||||
additionalEnv['RUSTFLAGS'] = rustflags.join(' ')
|
additionalEnv['RUSTFLAGS'] = rustflags.join(' ')
|
||||||
}
|
}
|
||||||
let isZigExisted = false
|
|
||||||
if (isCrossForLinux || isCrossForMacOS) {
|
let useZig = false
|
||||||
|
if (this.useZig || isCrossForLinux || isCrossForMacOS) {
|
||||||
try {
|
try {
|
||||||
execSync('zig version')
|
execSync('zig version')
|
||||||
isZigExisted = true
|
useZig = true
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this.useZig) {
|
if (this.useZig) {
|
||||||
throw new TypeError(
|
throw new TypeError(
|
||||||
|
@ -329,15 +330,15 @@ export class BuildCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.useZig || isCrossForLinux || isCrossForMacOS) && isZigExisted) {
|
if (useZig) {
|
||||||
const zigABIVersion =
|
const zigABIVersion =
|
||||||
this.zigABIVersion ?? (isCrossForLinux && triple.abi === 'gnu')
|
this.zigABIVersion ??
|
||||||
? DEFAULT_GLIBC_TARGET
|
(isCrossForLinux && triple.abi === 'gnu' ? DEFAULT_GLIBC_TARGET : null)
|
||||||
: null
|
|
||||||
const mappedZigTarget = ZIG_PLATFORM_TARGET_MAP[triple.raw]
|
const mappedZigTarget = ZIG_PLATFORM_TARGET_MAP[triple.raw]
|
||||||
const zigTarget = `${mappedZigTarget}${
|
const zigTarget = `${mappedZigTarget}${
|
||||||
zigABIVersion ? `.${zigABIVersion}` : ''
|
zigABIVersion ? `.${zigABIVersion}` : ''
|
||||||
}`
|
}`
|
||||||
|
debug(`Using Zig with target ${chalk.green(zigTarget)}`)
|
||||||
if (!mappedZigTarget) {
|
if (!mappedZigTarget) {
|
||||||
throw new Error(`${triple.raw} can not be cross compiled by zig`)
|
throw new Error(`${triple.raw} can not be cross compiled by zig`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue