Skip to content

Latest commit

 

History

History
164 lines (106 loc) · 3.07 KB

File metadata and controls

164 lines (106 loc) · 3.07 KB

Setup Guide

This guide walks you through setting up your development environment for HydroChess WASM.

← Back to README | Contributing Guide | Roadmap


Tools You'll Need

The following tools are required to build and test the engine. If you don't have them yet, follow the installation steps in the next section.

  • Git - For version control
  • Rust - The programming language
  • wasm-pack - Tool for building Rust to WebAssembly

1. Install Rust (If not installed)

Windows

Download and run the installer from rustup.rs:

# Or use winget:
winget install Rustlang.Rustup

macOS / Linux

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

After installation, restart your terminal and verify:

rustc --version
cargo --version

2. Add WebAssembly Target

rustup target add wasm32-unknown-unknown

3. Install wasm-pack (If not installed)

cargo install wasm-pack

Verify installation:

wasm-pack --version

4. Clone and Build

# Clone the repository
git clone <repository-url>
cd <repository-directory>

# Build for browser
wasm-pack build --target web

The built WASM package will be in the pkg/ directory.


Running Tests

# Run all unit tests
cargo test --lib

# Run tests with output
cargo test --lib -- --nocapture

# Run a specific test
cargo test test_name --lib

Code Coverage

# Install llvm-cov
cargo install cargo-llvm-cov

# Run coverage report
cargo llvm-cov --lib

5. Multi-threaded Build

The engine supports parallel search in WebAssembly. This requires a nightly Rust toolchain and specific compilation flags to enable shared memory and atomics.

Setup for Multithreading

  1. Install Nightly Rust:

    rustup toolchain install nightly
    rustup component add rust-src --toolchain nightly
  2. Build with Helper Script: Use the provided build_mt.js script to build the engine with the correct flags and feature set:

    node build_mt.js

This script handles the complex configuration required for WASM threads and uses wasm-pack to generate the correct JS/WASM bindings in the pkg/ directory.


IDE Setup

VS Code

Recommended extensions:

  1. rust-analyzer - Rust language support

Settings (.vscode/settings.json):

{
    "rust-analyzer.check.command": "clippy"
}

IntelliJ / CLion

Install the Rust plugin from JetBrains Marketplace.


Next Steps


Useful Links