Developer Setup & Rules
This guide outlines how to set up your local development environment, build the project, and contribute new features or documentation to our codebase. Please follow these instructions carefully to ensure compatibility across our multi-platform workspace.
1. Prerequisites & Toolchain Setup
To develop and build both the frontend and backend, you will need the following tools installed on your local machine:
- Rust Toolchain:
- Install Rust stable using rustup.
- TODO: write that our project uses WebAssembly and therefore needs the
wasm32-unknown-unknowntarget
- Just Runner: We use
justas a command runner for project actions.cargo install just
- WebAssembly Pack (
wasm-pack): Needed to compile our Rust frontend into WebAssembly.cargo install wasm-pack
- Optional dependencies for the Website:
- Install NodeJS. Node, npm, and bun are only used for the website. If these are installed, you can view a live preview of the changes you make before publishing them.
2. Compiling WebAssembly (WASM)
Our frontend is a WebAssembly application built with Rust and egui/eframe.
The Build Pipeline
- Compilation:
wasm-packcompiles ourfrontendcrate, creating highly optimized WebAssembly files and JS bindings. - Artifact Directory: The compiled outputs are saved under the workspace root folder
/pkg/. - Asset Serving: The native backend server (
native_mcg) automatically serves the HTML wrapper and all files inside/pkg/to the browser.
Key Just Recipes
We use just recipes to automate compile loops. Run these from your root workspace:
- Build Frontend (Release):shell
just build release - Run Developer Server (Frontend + Native Backend):shellThis command automatically builds the frontend in development mode and launches the native backend server (serving on port 3000+).
just start dev
3. Local Code Documentation (Cargo Docs)
We maintain extensive internal architecture documentation, API contracts, and crate-level comments inside our Rust codebase.
To build and browse this documentation locally open a terminal in the root mcg workspace directory and run the following command:
cargo doc --workspace --no-deps --openThis will compile all module-level docstrings and open a browser window displaying the workspace's fully cross-linked rustdoc site.
Crate-level responsibilities and system boundaries are documented using module-level comments //! at the top of each crate's main entry file (e.g., frontend/src/lib.rs, native_mcg/src/lib.rs, shared/src/lib.rs).
4. Coding & Contribution Rules
To maintain codebase health and ease peer code reviews, all contributions must respect the following rules:
- Strict Code Formatting: Run
cargo fmt --allbefore staging changes. Unformatted code will trigger a failure in the CI pipeline. - Compiler Warnings as Errors: Your code must compile without clippy warnings. Run:shell
cargo clippy --workspace --all-targets -- -D warnings - Verify Tests: Ensure all unit and integration tests succeed:shell
cargo test --workspace - Branch-Based Workflow: Direct commits to
mainare strictly forbidden. Changes can only be integrated intomainvia a pull request (PR) that must be reviewed and approved by a supervisor. PRs are only accepted once all quality requirements are fully met, including strict code formatting, zero compiler warnings, passing test suites, and completed documentation. For active development, students should create a dedicated branch for their project/thesis named with their abbreviation (e.g.,dev/jancc). Under this personal branch, you are free to use sub-feature branches to organize your work (e.g.,dev/jancc/feature/my-addition). - Documentation Commitment: When creating new components or changing interfaces, updates to relevant modules docs are required. This includes files of this Website.
5. Windows Specific Setup & Gotchas
Developing systems-level Rust applications on Windows can occasionally lead to toolchain path or security blocks. Follow these two workarounds if you encounter compiler errors:
A. MSVC Toolchain Setup & PATH Adjustments
- Visual Studio Build Tools: You must install the MSVC C++ build tools. Download the Visual Studio Installer and select "Desktop Development with C++" during setup.
NOTE
Ensure you install the standalone Visual Studio Build Tools (or Visual Studio Community), which are distinct desktop applications and separate from the VS Code editor.
- PATH Variable Adjustment: Some crates (like
cc) require compilers such ascl.exeto be directly present in your system'sPATHvariables.- Locating
cl.exe: This binary typically resides in:C:\Program Files\Microsoft Visual Studio\<Year>\Community\VC\Tools\MSVC\<Version>\bin\Hostx64\x64 - Add this path to your user environment variables if you get compilation failures stating
cl.exe could not be found.
- Locating
B. Smart App Control Code Signing Workaround
Windows Smart App Control may block cargo.exe, rustup.exe, or locally compiled binaries because they are untrusted and unsigned. To fix this without lowering your system security:
- We have provided a PowerShell script at the root of the
mcgrepository:sign_rust_binaries.ps1. - This script creates a trusted local self-signed code-signing certificate, adds it securely to your local certificate stores, and signs the Rust toolchain binaries in your
.cargo/binfolder. - Open PowerShell as an Administrator and execute:powershell
.\sign_rust_binaries.ps1 - To sign a newly compiled game binary that gets blocked:powershell
.\sign_rust_binaries.ps1 .\target\debug\native_mcg.exe