mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Simplify bun run build:local to auto-build JSC (#26645)
## Summary - `bun run build:local` now handles everything: configuring JSC, building JSC, and building Bun in a single command on all platforms (macOS, Linux, Windows). Previously required manually running `bun run jsc:build:debug`, deleting a duplicate `InspectorProtocolObjects.h` header, and then running the Bun build separately. - Incremental JSC rebuilds: JSC is built via `add_custom_target` that delegates to JSC's inner Ninja, which tracks WebKit source file changes and only rebuilds what changed. `ninja -Cbuild/debug-local` also works after the first build. - Cross-platform support: - macOS: Uses system ICU automatically - Linux: Uses system ICU via find_package instead of requiring bundled static libs - Windows: Builds ICU from source automatically (only when libs don't already exist), sets up static CRT and ICU naming conventions ### Changes - cmake/tools/SetupWebKit.cmake: Replace the old WEBKIT_LOCAL block (which just set include paths and assumed JSC was pre-built) with full JSC configure + build integration for all platforms - cmake/targets/BuildBun.cmake: Add jsc as a build dependency, use system ICU on Linux for local builds, handle bmalloc linking for local builds - CONTRIBUTING.md / docs/project/contributing.mdx: Simplify "Building WebKit locally" docs from ~15 lines of manual steps to 3 lines ## Test plan - [x] macOS arm64: clean build, incremental rebuild, WebKit source change rebuild - [x] Windows x64: clean build with ICU, incremental rebuild with ICU skip - [x] Linux x64: build with system ICU via find_package - [x] No duplicate InspectorProtocolObjects.h errors - [x] build/debug-local/bun-debug --version works Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -266,18 +266,13 @@ git clone https://github.com/oven-sh/WebKit vendor/WebKit
|
||||
# Check out the commit hash specified in `set(WEBKIT_VERSION <commit_hash>)` in cmake/tools/SetupWebKit.cmake
|
||||
git -C vendor/WebKit checkout <commit_hash>
|
||||
|
||||
# Make a debug build of JSC. This will output build artifacts in ./vendor/WebKit/WebKitBuild/Debug
|
||||
# Optionally, you can use `bun run jsc:build` for a release build
|
||||
bun run jsc:build:debug && rm vendor/WebKit/WebKitBuild/Debug/JavaScriptCore/DerivedSources/inspector/InspectorProtocolObjects.h
|
||||
|
||||
# After an initial run of `make jsc-debug`, you can rebuild JSC with:
|
||||
cmake --build vendor/WebKit/WebKitBuild/Debug --target jsc && rm vendor/WebKit/WebKitBuild/Debug/JavaScriptCore/DerivedSources/inspector/InspectorProtocolObjects.h
|
||||
|
||||
# Build bun with the local JSC build
|
||||
# Build bun with the local JSC build — this automatically configures and builds JSC
|
||||
bun run build:local
|
||||
```
|
||||
|
||||
Using `bun run build:local` will build Bun in the `./build/debug-local` directory (instead of `./build/debug`), you'll have to change a couple of places to use this new directory:
|
||||
`bun run build:local` handles everything: configuring JSC, building JSC, and building Bun. On subsequent runs, JSC will incrementally rebuild if any WebKit sources changed. `ninja -Cbuild/debug-local` also works after the first build, and will build Bun+JSC.
|
||||
|
||||
The build output goes to `./build/debug-local` (instead of `./build/debug`), so you'll need to update a couple of places:
|
||||
|
||||
- The first line in `src/js/builtins.d.ts`
|
||||
- The `CompilationDatabase` line in `.clangd` config should be `CompilationDatabase: build/debug-local`
|
||||
@@ -288,7 +283,7 @@ Note that the WebKit folder, including build artifacts, is 8GB+ in size.
|
||||
|
||||
If you are using a JSC debug build and using VScode, make sure to run the `C/C++: Select a Configuration` command to configure intellisense to find the debug headers.
|
||||
|
||||
Note that if you change make changes to our [WebKit fork](https://github.com/oven-sh/WebKit), you will also have to change `SetupWebKit.cmake` to point to the commit hash.
|
||||
Note that if you make changes to our [WebKit fork](https://github.com/oven-sh/WebKit), you will also have to change `SetupWebKit.cmake` to point to the commit hash.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
||||
Reference in New Issue
Block a user