@napi-rs/cli
Version:
Cli tools for napi-rs
59 lines (50 loc) • 16.8 kB
Markdown
# Build
> This file is generated by cli/codegen. Do not edit this file manually.
Build the NAPI-RS project
## Usage
```sh
# CLI
napi build [--options]
```
```typescript
// Programatically
import { NapiCli } from '@napi-rs/cli'
new NapiCli().build({
// options
})
```
## Options
| Options | CLI Options | type | required | default | description |
| ----------------- | --------------------- | -------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | --help,-h | | | | get help |
| target | --target,-t | string | false | | Build for the target triple, bypassed to `cargo build --target` |
| cwd | --cwd | string | false | | The working directory of where napi command will be executed in, all other paths options are relative to this path |
| manifestPath | --manifest-path | string | false | | Path to `Cargo.toml` |
| configPath | --config-path,-c | string | false | | Path to `napi` config json file |
| packageJsonPath | --package-json-path | string | false | | Path to `package.json` |
| targetDir | --target-dir | string | false | | Directory for all crate generated artifacts, see `cargo build --target-dir` |
| outputDir | --output-dir,-o | string | false | | Path to where all the built files would be put. Default to the crate folder |
| platform | --platform | boolean | false | | Add platform triple to the generated nodejs binding file, eg: `[name].linux-x64-gnu.node` |
| jsPackageName | --js-package-name | string | false | | Package name in generated js binding file. Only works with `--platform` flag |
| constEnum | --const-enum | boolean | false | | Whether generate const enum for typescript bindings |
| runtimeStringEnum | --runtime-string-enum | boolean | false | | Emit `#[napi(string_enum)]` enums as runtime enums (`export declare enum`) under `--no-const-enum`. Default: type-only union. |
| jsBinding | --js | string | false | | Path and filename of generated JS binding file. Only works with `--platform` flag. Relative to `--output-dir`. |
| noJsBinding | --no-js | boolean | false | | Whether to disable the generation JS binding file. Only works with `--platform` flag. |
| dts | --dts | string | false | | Path and filename of generated type def file. Relative to `--output-dir` |
| dtsHeader | --dts-header | string | false | | Custom file header for generated type def file. Only works when `typedef` feature enabled. |
| noDtsHeader | --no-dts-header | boolean | false | | Whether to disable the default file header for generated type def file. Only works when `typedef` feature enabled. |
| dtsCache | --dts-cache | boolean | false | true | Whether to enable the dts cache, default to true |
| esm | --esm | boolean | false | | Whether to emit an ESM JS binding file instead of CJS format. Only works with `--platform` flag. |
| strip | --strip,-s | boolean | false | | Whether strip the library to achieve the minimum file size |
| release | --release,-r | boolean | false | | Build in release mode |
| verbose | --verbose,-v | boolean | false | | Verbosely log build command trace |
| bin | --bin | string | false | | Build only the specified binary |
| package | --package,-p | string | false | | Build the specified library or the one at cwd |
| profile | --profile | string | false | | Build artifacts with the specified profile |
| crossCompile | --cross-compile,-x | boolean | false | | [experimental] cross compile by replacing the cargo subcommand: Windows MSVC targets from a non-Windows host build with `cargo-xwin` (`windows-gnu` targets are rejected, `cargo-xwin` cannot handle them), non-Windows targets build with `cargo-zigbuild` (requires `zig` on PATH). The selected subcommand is auto-installed on first use. Cannot be combined with `--use-cross`, `--use-napi-cross` or `--watch` |
| useCross | --use-cross | boolean | false | | [experimental] not recommended, prefer `--cross-compile` or `--use-napi-cross`: build in a Docker or Podman container with [cross](https://github.com/cross-rs/cross), which must be installed manually and needs a running container engine. Cannot be combined with `--cross-compile`, `--use-napi-cross` or `--watch` |
| useNapiCross | --use-napi-cross | boolean | false | | [experimental] download a prebuilt gcc cross toolchain from `@napi-rs/cross-toolchain` (glibc 2.17) and set linker and C compiler environment variables. Linux glibc targets only (x64, arm64, armv7, ppc64le, s390x) on a Linux x64 or arm64 host, any other target or host errors. Cannot be combined with `--cross-compile` or `--use-cross` |
| watch | --watch,-w | boolean | false | | watch the crate changes and build continuously with `cargo-watch` crates |
| features | --features,-F | string[] | false | | Space-separated list of features to activate |
| allFeatures | --all-features | boolean | false | | Activate all available features |
| noDefaultFeatures | --no-default-features | boolean | false | | Do not activate the `default` feature |