-
-
Notifications
You must be signed in to change notification settings - Fork 759
feat(binding-builder): add binding-builder cli #10876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8148048
34de589
75d483a
750e9c1
9da9600
4a924a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ runs: | |
shell: bash | ||
run: | | ||
cd ./crates/node_binding | ||
pnpm install --ignore-workspace --no-lockfile | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably install the binding builder cli as a dependency (not from the current workspace) after the first release, then we can revert the workflow back. |
||
pnpm install --frozen-lockfile | ||
cd ../../ | ||
|
||
- name: Save pnpm cache | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022-present Bytedance, Inc. and its affiliates. | ||
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
if (positionals.length > 0) { | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<picture> | ||
<img alt="Rspack Banner" src="https://assets.rspack.rs/rspack/rspack-banner.png"> | ||
</picture> | ||
|
||
# @rspack/binding-builder-cli | ||
|
||
Binding builder cli for rspack custom binding users. | ||
|
||
## Rationale | ||
|
||
This package is designed to provide a command-line interface for building custom bindings for rspack. | ||
|
||
Rspack internally performs post-processing modifications on the generated TypeScript definition (`.d.ts`) files from NAPI-RS bindings. The `@rspack/binding-builder-cli` synchronizes these modifications, ensuring that the generated `.d.ts` files are complete and provide access to all type information available in `@rspack/binding`. | ||
|
||
## Installation | ||
|
||
```bash | ||
# Install as a dependency | ||
npm install @rspack/binding-builder-cli | ||
``` | ||
|
||
## Usage | ||
|
||
### Basic Usage | ||
|
||
```bash | ||
# Basic build | ||
rspack-builder | ||
|
||
# Release build | ||
rspack-builder --release | ||
|
||
# Build with specific profile | ||
rspack-builder --profile release-debug | ||
|
||
# Watch mode for development | ||
rspack-builder --watch | ||
``` | ||
|
||
### Advanced Options | ||
|
||
#### Build Target and Paths | ||
|
||
```bash | ||
# Specify build target | ||
rspack-builder --target x86_64-unknown-linux-musl | ||
|
||
# Set working directory | ||
rspack-builder --cwd /path/to/project | ||
|
||
# Custom Cargo.toml path | ||
rspack-builder --manifest-path /path/to/Cargo.toml | ||
|
||
# Custom package.json path | ||
rspack-builder --package-json-path /path/to/package.json | ||
``` | ||
|
||
#### TypeScript Definition Options | ||
|
||
```bash | ||
# Custom .d.ts output path | ||
rspack-builder --dts custom-binding.d.ts | ||
|
||
# Custom header for .d.ts file | ||
rspack-builder --dts-header /path/to/header.d.ts | ||
|
||
# Disable default .d.ts header | ||
rspack-builder --no-dts-header | ||
|
||
# Disable .d.ts cache | ||
rspack-builder --no-dts-cache | ||
``` | ||
|
||
#### Feature Management | ||
|
||
```bash | ||
# Enable specific features | ||
rspack-builder --features plugin,serde | ||
|
||
# Enable all features | ||
rspack-builder --all-features | ||
|
||
# Disable default features | ||
rspack-builder --no-default-features | ||
|
||
# Combine options | ||
rspack-builder --no-default-features --features plugin | ||
``` | ||
|
||
#### Platform and Output Options | ||
|
||
```bash | ||
# Enable platform-specific naming | ||
rspack-builder --platform | ||
|
||
# Disable JS binding generation | ||
rspack-builder --no-js | ||
|
||
# Generate ESM format | ||
rspack-builder --esm | ||
|
||
# Strip binary for minimum size | ||
rspack-builder --strip | ||
``` | ||
|
||
### Help | ||
|
||
View all available options: | ||
|
||
```bash | ||
rspack-builder --help | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env node | ||
require("./scripts/build"); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bad part is we have to link
binding-builder-cli
tocrates/node_binding
. This requires the binding to fallback to workspace install instead of plain package install. cc @stormslowly