Skip to content

Building

BlackCat edited this page Nov 29, 2026 · 1 revision

Building from source

TwilightMC targets stable Rust (edition 2024) and Node.js 22 for the Svelte frontend. The GUI embeds the frontend at compile time, so the frontend build must run before cargo build.

Prerequisites

Platform Packages
All stable Rust toolchain, Node.js 22 + npm, 7z on PATH
Windows Visual Studio Build Tools (MSVC) or MinGW-w64; WebView2 Runtime
macOS Xcode Command Line Tools
Linux libwebkit2gtk-4.1-dev, build-essential, curl, wget, file, libxdo-dev, libssl-dev, libayatana-appindicator3-dev, librsvg2-dev

On Debian/Ubuntu:

sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file \
  libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev

7z is only needed when the launch pipeline extracts natives; the CLI still builds without it.

Frontend + workspace

cd crates/twilight-ui/ui
npm ci
npm run build          # writes ui/dist, embedded by tauri::generate_context!
cd ../../..

cargo build --release --locked
cargo test --workspace

The release binaries land in target/release/:

  • twilight — CLI
  • twilight-ui — desktop GUI

Quality gates

Every contribution must pass the same gates CI runs:

cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

The frontend has its own gates:

npm --prefix crates/twilight-ui/ui run check:locales
npm --prefix crates/twilight-ui/ui run build

Zero warnings are tolerated. clippy runs with -D warnings, and the locale checker fails on missing or duplicate Fluent keys.

The build helper

build.py wraps the common flows on Windows and Unix:

py build.py            # frontend + cargo build (debug)
py build.py release    # frontend + cargo build --release
py build.py gates      # fmt --check / clippy -D warnings / test
py build.py pack       # release + CI-style zip under dist/ (exe + docs + sha256)
py build.py all        # gates + release + pack

Add --workspace to build every workspace member instead of the default binaries.

Tauri installers

The release workflows build .deb, .rpm, .AppImage, .dmg, .msi and NSIS .exe bundles. Locally:

cargo install tauri-cli --version '^2' --locked
cargo tauri build -c crates/twilight-ui/tauri.conf.json --bundles deb,rpm

Bundling needs the platform tooling (for example dpkg-deb/rpmbuild on Linux). The portable archives are produced by the release workflow, not by cargo build alone.

Tests and fixtures

cargo test --workspace

Network paths use loopback HTTP servers; JSON fixtures are inline; DEFLATE fixtures are committed hex blobs. Platform-specific tests are #[cfg]-gated, so the full union only runs in CI's multi-platform matrix.

Troubleshooting

Symptom Fix
failed to open icon .../icons/icon.png during generate_context! regenerate the Tauri icon set from ui/public/logo.png (cargo tauri icon)
frontendDist missing / blank window run npm run build in crates/twilight-ui/ui before cargo build
webkit2gtk-4.1 not found on Linux install libwebkit2gtk-4.1-dev
linker 'cc' not found on Linux install build-essential
7z not found at launch time install p7zip-full / 7zip, or skip natives-heavy versions
clippy passes locally but fails in CI run the exact gate: cargo clippy --workspace --all-targets -- -D warnings

Where to go next

Clone this wiki locally