diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..4adca20 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,49 @@ +# Development + +## Contributing + +See [`CONTRIBUTING.md`](CONTRIBUTING.md). + +## Development setup + +To build `libdatadog-nodejs` locally (for example, to run tests or try out changes), you need Node.js, Yarn, and Rust. + +**Rust (required for native and WASM builds)** + +The project compiles Rust for both native Node.js addons and WebAssembly. Use [rustup](https://rustup.rs/) (the recommended and supported method): + +1. **Install rustup and Rust** (see https://rustup.rs/ for more options): + + ```bash + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh + ``` + +2. **Ensure Rust is on `PATH`** — the rustup installer prints the command for your shell; run it or open a new terminal. + +3. **Add the WebAssembly target** (required for the full build): + + ```bash + rustup target add wasm32-unknown-unknown + ``` + +4. **On macOS only** — the WASM build requires LLVM from Homebrew (Apple's Clang has compatibility issues with some crates). Install it before building: + + ```bash + brew install llvm + ``` + +5. **Install dependencies:** + + ```bash + yarn install + ``` + +## Building + +* `yarn build`: Build the default workspaces in debug mode. +* `yarn build-release`: Build the default workspaces in release mode. +* `yarn build-all`: Build all workspaces in debug mode. This is useful when working on a workspace that is not a default member yet. + +## Run tests + +* `yarn test`: Run the JavaScript test suite diff --git a/README.md b/README.md index 5b32d98..69caebc 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,3 @@ Node.js bindings for [libdatadog](https://github.com/DataDog/libdatadog). This project is currently meant to be used only by [dd-trace-js](https://github.com/DataDog/dd-trace-js) and installing it directly is not supported at the moment. - -## Building - -* `yarn build`: Build the default workspaces in debug mode. -* `yarn build-release`: Build the default workspaces in release mode. -* `yarn build-all`: Build all workspaces in debug mode. This is useful when working on a workspace that is not a default member yet. diff --git a/scripts/build-wasm.js b/scripts/build-wasm.js index ae5bcdd..51e692e 100644 --- a/scripts/build-wasm.js +++ b/scripts/build-wasm.js @@ -37,6 +37,11 @@ if (isMacOS) { // Add LLVM to PATH if not already included env.PATH = `${llvmBinDir}:${env.PATH}`; } + + // Force C/C++ code (e.g. zstd-sys) to use Homebrew's clang for wasm32. Otherwise a global + // CC (e.g. ccache cc) can point at Apple Clang, which does not support wasm32-unknown-unknown. + env.CC_wasm32_unknown_unknown = `${llvmBinDir}/clang`; + env.CXX_wasm32_unknown_unknown = `${llvmBinDir}/clang++`; } childProcess.execSync(