Skip to content

Commit

Permalink
improve commands
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Mar 11, 2024
1 parent e89e4a1 commit aa99b39
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Expand Up @@ -104,8 +104,8 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Build
run: yarn build:node
- name: Build Rolldown
run: yarn build

- name: Type Check
run: yarn type-check
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/release.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
include:
- os: macos-latest
target: x86_64-apple-darwin
build: yarn build:binding:release
build: yarn build-binding:release

- os: macos-latest
target: aarch64-apple-darwin
Expand All @@ -26,36 +26,36 @@ jobs:
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
export CARGO_BUILD_TARGET=aarch64-apple-darwin
yarn build:binding:release
yarn build-binding:release
- os: windows-latest
target: x86_64-pc-windows-msvc
build: yarn build:binding:release
build: yarn build-binding:release

- os: windows-latest
target: i686-pc-windows-msvc
build: |
export CARGO_BUILD_TARGET=i686-pc-windows-msvc
yarn build:binding:release
yarn build-binding:release
- os: windows-latest
target: aarch64-pc-windows-msvc
build: |
export CARGO_BUILD_TARGET=aarch64-pc-windows-msvc
yarn build:binding:release
yarn build-binding:release
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: |-
set -e &&
export CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu &&
yarn build:binding:release
yarn build-binding:release
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: yarn build:binding:release
build: yarn build-binding:release

- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
Expand All @@ -64,27 +64,27 @@ jobs:
set -e &&
export CARGO_BUILD_TARGET=aarch64-unknown-linux-gnu &&
rustup target add aarch64-unknown-linux-gnu &&
yarn build:binding:release
yarn build-binding:release
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
build: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf -y
export CARGO_BUILD_TARGET=armv7-unknown-linux-gnueabihf
yarn build:binding:release --zig --zig-link-only
yarn build-binding:release --zig --zig-link-only
- os: ubuntu-latest
target: aarch64-linux-android
build: |
export CARGO_BUILD_TARGET=aarch64-linux-android
yarn build:binding:release
yarn build-binding:release
- os: ubuntu-latest
target: armv7-linux-androideabi
build: |
export CARGO_BUILD_TARGET=armv7-linux-androideabi
yarn build:binding:release
yarn build-binding:release
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
Expand All @@ -94,7 +94,7 @@ jobs:
rustup target add aarch64-unknown-linux-musl &&
export CARGO_BUILD_TARGET=aarch64-unknown-linux-musl &&
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc &&
yarn build:binding:release
yarn build-binding:release
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
run: yarn install

- name: Build Wasm
run: yarn build:wasm:release
run: yarn build-wasm:release

- name: Upload Wasm Artifact
uses: actions/upload-artifact@v4
Expand Down
10 changes: 5 additions & 5 deletions crates/rolldown_binding_wasm/package.json
Expand Up @@ -11,10 +11,10 @@
"access": "public"
},
"scripts": {
"build": "npm-run-all -s build:wasm clean-wasm-build",
"build:release": "npm-run-all -s build:wasm:release clean-wasm-build",
"build:wasm": "wasm-pack build --dev --target web -d ./dist",
"build:wasm:release": "wasm-pack build --release --target web -d ./dist",
"build": "npm-run-all -s build-wasm clean-wasm-build",
"build:release": "npm-run-all -s build-wasm:release clean-wasm-build",
"build-wasm": "wasm-pack build --dev --target web -d ./dist",
"build-wasm:release": "wasm-pack build --release --target web -d ./dist",
"clean-wasm-build": "rm ./dist/.gitignore"
},
"files": [
Expand All @@ -33,4 +33,4 @@
"npm-run-all": "^4.1.5",
"wasm-pack": "^0.12.1"
}
}
}
13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -17,13 +17,12 @@
"scripts": {
"lint-code": "oxlint --ignore-path=./.oxlintignore --import-plugin --deny-warnings",
"lint-filename": "ls-lint",
"watch": "yarn run build --watch",
"build": "DEBUG='rolldown:*' node ./scripts/build-node-binding.js",
"build:node": "yarn workspaces foreach -R --topological-dev --from 'rolldown' run build",
"build:binding": "yarn workspace @rolldown/node-binding run build",
"build:binding:release": "yarn workspace @rolldown/node-binding run build:release",
"build:wasm": "yarn workspace @rolldown/wasm-binding run build",
"build:wasm:release": "yarn workspace @rolldown/wasm-binding run build:release",
"build": "yarn workspace rolldown run build",
"build:release": "yarn workspace rolldown run build:release",
"build-binding": "yarn workspace rolldown run build-binding",
"build-binding:release": "yarn workspace rolldown run build-binding-release",
"build-wasm": "yarn workspace @rolldown/wasm-binding run build",
"build-wasm:release": "yarn workspace @rolldown/wasm-binding run build:release",
"test": "yarn workspaces foreach --all --parallel run test",
"test:update": "yarn workspaces foreach --all --parallel run test:update",
"test:update-rolldown": "yarn workspace node run test:update",
Expand Down
15 changes: 0 additions & 15 deletions scripts/build-binding.js

This file was deleted.

File renamed without changes.
40 changes: 5 additions & 35 deletions web/docs/contrib-guide/build.md
Expand Up @@ -4,41 +4,11 @@ Rolldown is built on Rust and Node.js, so and building process includes building

Luckily, NAPI-RS has encapsulated the process of building the glue part, we don't need to worry about the details.

Typically, rolldown has two main packages:
## `rolldown`

- `rolldown`, which is the final npm package that users will install directly.
- `@rolldown/node-binding`, which is the glue part that binds Rust and Node.js together.
To build the `rolldown` package, there are two commands:

## Incremental Build
- `yarn build`
- `yarn build:release` (**important if running benchmarks**)

For the NAPI-RS based Node packages to work, and for their tests and benchmarks to run, they must be built first. This is done by running `yarn build` in the root directory. This will spin up a process that builds the Node/WASM binding crates (with Cargo), and then builds the rolldown npm package.

The `yarn build` script is also smart enough to only re-build if it detects changes since the last time it was run.

`yarn build` accepts two flags:

- `--no-wasm`
- `--release` (**important if running benchmarks**)

In addition, the `yarn watch` script can be used to watch the file system for changes, and re-build the bindings and npm package when changes are detected (using the same process as `yarn build`). This is useful for development when you're constantly making changes and re-running tests.

## Fresh Build

If you want to force a fresh build on `rolldown`, you can run `yarn build:node`. It will topologically run the `build` command in `rolldown` and `@rolldown/node-binding` package.

To build some specific package only:

For `rolldown`, you could run:

- `yarn workspace rolldown build`.

For `@rolldown/node-binding`, you could run:

- `yarn workspace @rolldown/node-binding build`
- `yarn workspace @rolldown/node-binding build:release` (**important if running benchmarks**)

:::warning

Due to the boundary between Rust and Node.js, once you changed the Rust code, you need to rebuild the `@rolldown/node-binding` package to see the changes while executing in Node.js.

:::
They will automatically build the Rust crates and the Node.js package. So no matter what changes you made, you can always run these commands to build the latest `rolldown` package.

0 comments on commit aa99b39

Please sign in to comment.