Skip to content

Commit

Permalink
feat(cli): support --profile flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed May 27, 2023
1 parent 7c4dc2a commit dfbe464
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ exclude = ["./testing"]

[profile.release]
lto = true

[profile.napi-rs-custom]
inherits = "dev"
lto = false
codegen-units = 1024
opt-level = 0
8 changes: 7 additions & 1 deletion cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export class BuildCommand extends Command {
description: `Bypass to ${chalk.green('cargo -p')}`,
})

profile = Option.String('--profile', {
description: `Bypass to ${chalk.green('cargo --profile')}`,
})

cargoFlags = Option.String('--cargo-flags', '', {
description: `All the others flag passed to ${chalk.yellow('cargo build')}`,
})
Expand Down Expand Up @@ -267,12 +271,14 @@ export class BuildCommand extends Command {
: getHostTargetTriple()
debug(`Current triple is: ${chalk.green(triple.raw)}`)
const pFlag = this.project ? `-p ${this.project}` : ''
const profileFlag = this.profile ? `--profile ${this.profile}` : ''
const externalFlags = [
releaseFlag,
targetFlag,
featuresFlag,
binFlag,
pFlag,
profileFlag,
this.cargoFlags,
]
.filter((flag) => Boolean(flag))
Expand Down Expand Up @@ -582,7 +588,7 @@ export class BuildCommand extends Command {

const targetDir = join(
this.targetTripleDir,
this.isRelease ? 'release' : 'debug',
this.profile ?? this.isRelease ? 'release' : 'debug',
)

const platformName = this.appendPlatformToFilename
Expand Down

0 comments on commit dfbe464

Please sign in to comment.