-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# napi / Build | ||
|
||
The [napi-build](https://crates.io/crates/napi-build) crate is used for the build part. | ||
|
||
A `build.rs` file is in the crate/package where you want to generate bindings from `src/lib.rs`. | ||
|
||
The `build.rs` will only contain this kind of code: | ||
|
||
```rust | ||
extern crate napi_build; | ||
|
||
fn main() { | ||
napi_build::setup(); | ||
} | ||
``` | ||
|
||
Then, you will call something like: | ||
|
||
```sh | ||
napi build --platform --release | ||
``` | ||
|
||
Which will generate: | ||
|
||
- the binaries for the targeted platforms | ||
- the bindings: | ||
- `.d.ts` TypeScript decleration files | ||
- `.js` glue code to load and bind the binary to JavaScript runtime | ||
|
||
When running it from a task in a `package.json`, a configuration can be passed to a [`napi` field](https://napi.rs/docs/cli/napi-config.en#schema) | ||
|
||
<https://napi.rs/docs/introduction/simple-package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# oxc / Bundling (js) | ||
|
||
First, read [napi / Build](../napi/build.md). | ||
|