快速开始
克隆仓库
bash
git clone -c core.longpaths=true git@github.com:oxc-project/oxc.git配置项目
安装 Rust
若尚未安装 Rust,请遵循官方文档安装。
随后在仓库根目录执行:
bash
rustup showrustup show 会读取 ./rust-toolchain.toml 并为当前项目安装正确的工具链与组件。
cargo binstall
开发 OXC 时需要部分 Cargo 工具,推荐使用 cargo binstall,用较低复杂度安装 Rust 二进制,通常比每次都 cargo install 从源码构建更快:
bash
cargo install cargo-binstall也可以下载预编译二进制并放到 ~/.cargo/bin。
just
OXC 使用 just 统一管理项目脚本:
bash
cargo binstall just -y安装 CMake
可通过 CMake 官网 下载安装。
Homebrew 亦可:
bash
brew install cmake安装 pnpm
按 pnpm 官网 指南安装 Node 包管理器 pnpm。
依赖安装
在项目根目录的 justfile 中执行:
bash
just init直接运行 just 可列出可用命令。
可执行 just ready(简写 just r)确认整个工程能否正确构建并运行。
macOS:加快编译速度
macOS 的 XProtect 会在首次运行可执行文件时进行恶意软件扫描,会明显拖慢 Rust 构建(尤其 build script、测试二进制)。可把终端应用加到「开发者工具」(系统设置 › 隐私与安全性 › Developer Tools),以提速:
- 打开上述设置页的 Developer Tools
- 添加你使用的终端(Terminal、iTerm 等)
- 重启终端应用
注意:这会弱化一项系统安全特性,请自行权衡利弊。
延伸阅读:https://nnethercote.github.io/2025/09/04/faster-rust-builds-on-mac.html