feat(cli): add --strip
option for removing symbols
This commit is contained in:
parent
1768cf69ee
commit
887bdb9d29
1 changed files with 13 additions and 2 deletions
|
@ -162,6 +162,10 @@ export class BuildCommand extends Command {
|
||||||
)} ${chalk.green('--zig-abi-suffix=2.17')}`,
|
)} ${chalk.green('--zig-abi-suffix=2.17')}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
isStrip = Option.Boolean(`--strip`, false, {
|
||||||
|
description: `${chalk.green('Strip')} the library for minimum file size`,
|
||||||
|
})
|
||||||
|
|
||||||
async execute() {
|
async execute() {
|
||||||
const cwd = this.cargoCwd
|
const cwd = this.cargoCwd
|
||||||
? join(process.cwd(), this.cargoCwd)
|
? join(process.cwd(), this.cargoCwd)
|
||||||
|
@ -207,14 +211,21 @@ export class BuildCommand extends Command {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rustflags = process.env.RUSTFLAGS ?? ''
|
||||||
if (triple.raw.includes('musl')) {
|
if (triple.raw.includes('musl')) {
|
||||||
let rustflags = process.env.RUSTFLAGS ?? ''
|
|
||||||
if (!rustflags.includes('target-feature=-crt-static')) {
|
if (!rustflags.includes('target-feature=-crt-static')) {
|
||||||
rustflags += '-C target-feature=-crt-static'
|
rustflags += '-C target-feature=-crt-static'
|
||||||
additionalEnv['RUSTFLAGS'] = rustflags
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isStrip && !rustflags.includes('-C link-arg=-s')) {
|
||||||
|
rustflags += '-C link-arg=-s'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rustflags.length > 0) {
|
||||||
|
additionalEnv['RUSTFLAGS'] = rustflags
|
||||||
|
}
|
||||||
|
|
||||||
if (this.useZig) {
|
if (this.useZig) {
|
||||||
const zigTarget = `${ZIG_PLATFORM_TARGET_MAP[triple.raw]}${
|
const zigTarget = `${ZIG_PLATFORM_TARGET_MAP[triple.raw]}${
|
||||||
this.zigABIVersion ? `.${this.zigABIVersion}` : ''
|
this.zigABIVersion ? `.${this.zigABIVersion}` : ''
|
||||||
|
|
Loading…
Reference in a new issue