How to Package the Brush Project for Deployment: Desktop, Web, and Android
To package the Brush project for deployment, build the desktop binary with cargo build --release, the web bundle with npm run build from apps/brush-js/web, or the Android APK with cargo-ndk followed by Gradle commands.
The Brush repository by ArthurBrussee is a multi-crate Rust workspace that targets desktop, web, and Android platforms. Because each platform uses a different entry point and build toolchain, packaging the project for deployment requires platform-specific commands. This guide covers the exact steps to produce release binaries, WASM bundles, and Android APKs based on the current source code.
Workspace Layout
The root Cargo.toml defines a workspace containing executables in apps/* and libraries in crates/*. The three deployment targets correspond to distinct workspace members:
apps/brush-cli→ Desktop CLI binaryapps/brush-js/web→ Web front-end with WASMcrates/brush-app→ Android native library
Packaging for Desktop
For macOS, Windows, and Linux, the brush-cli crate produces an optimized binary via standard Cargo commands. In apps/brush-cli/src/main.rs, the application entry point initializes the CLI interface that processes commands like brush --help.
Build the release binary with:
cargo build --release
The resulting binary appears at ./target/release/brush (or ./target/release/brush.exe on Windows). This artifact is self-contained and ready for distribution on the host platform.
Packaging for Web (WASM)
The web deployment requires compiling Rust to WebAssembly using wasm-pack. The apps/brush-js/web directory contains a Vite-based front-end configured in vite.config.ts to load the compiled WASM module.
First, install the required tooling:
cargo install wasm-pack
For development, start the hot-reload server:
npm run dev # serves on http://localhost:3000
To create a production bundle for deployment:
npm run build
This generates a static dist directory containing the compiled WASM, JavaScript wrapper, and assets, suitable for any static web hosting provider.
Packaging for Android
Android deployment requires the NDK toolchain and cargo-ndk to cross-compile the Rust code into a native shared library (libbrush.so). The crates/brush-app crate contains the Rust code, while the Gradle project in the same directory loads the library via System.loadLibrary as configured in crates/brush-app/app/build.gradle.kts.
First, set up the environment and tooling:
export ANDROID_NDK_HOME=$HOME/Android/Sdk/ndk/$(ndk-version)
export ANDROID_HOME=$HOME/Android/Sdk
rustup target add aarch64-linux-android
cargo install cargo-ndk
Build the native library for the arm64-v8a ABI:
cargo ndk -t arm64-v8a -o crates/brush-app/app/src/main/jniLibs/ build --release
Package and install the APK using Gradle:
cd crates/brush-app
./gradlew assembleDebug # produces the APK
./gradlew installDebug # installs on a connected device
Summary
- Desktop builds use
cargo build --releasetargetingapps/brush-clito produce a binary intarget/release/ - Web builds require
wasm-packandnpm run buildfromapps/brush-js/webto generate a staticdistfolder - Android builds need
cargo-ndkto generatelibbrush.soincrates/brush-app/app/src/main/jniLibs/before Gradle packages the APK - Each platform uses distinct workspace members defined in the root
Cargo.toml
Frequently Asked Questions
What Rust version is required to package the Brush project?
The workspace requires Rust 1.88 or later to support the workspace dependencies and burn backend features used across the crates.
Can I deploy the web build to a static hosting provider?
Yes, running npm run build in apps/brush-js/web generates a static dist directory containing the WASM module and JavaScript wrapper, compatible with any static web host or CDN.
Why does the Android build require cargo-ndk instead of standard cargo?
Android requires architecture-specific native libraries (.so files) stored in jniLibs. The cargo-ndk tool automates the NDK toolchain invocation and places the compiled libbrush.so in the correct directory structure for Gradle to package into the APK, which standard Cargo cannot do alone.
Where is the desktop binary located after building?
After running cargo build --release, the optimized binary is located at target/release/brush (or target/release/brush.exe on Windows), ready for distribution without additional runtime dependencies.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →