crorust & ruxt — Cross-Platform Native Apps with Rust
Welcome to crorust.com. This platform fulfills three core roles in the Rust ecosystem:
- The crorust Tool: Zero-config hermetic multi-host cross-compilation platform and pure-Rust native app packaging suite for Android, iOS, macOS, Windows, Linux, and Web.
- The ruxt Starter Template: An open-source, production-grade application template released under a permissive dual-license (MIT OR Apache-2.0) for anyone to fork and build cross-platform GUI software.
- Interactive Showcase & Architectural Tutorial: A live demonstration and 7-layer engineering manual covering the crates used (winit 0.30, egui 0.36, wgpu 24.0, epaint, and egui_kittest).
Why crorust: Breaking the Cross-Compilation Wall
Traditionally, compiling Rust applications for multiple operating systems required siloed workstation hardware: Android required 15GB of Android Studio and Gradle caches; Windows required Visual Studio MSVC tools; iOS demanded a physical Mac with Xcode. crorust breaks down these walls by driving LLVM directly and implementing pure-Rust binary packagers for all operating systems.
- Multi-Host Development: Linux, macOS, and Windows engineers build on the exact same codebase with identical CLI commands.
- Cross-Target Deployment: Compile Android APKs, Windows MSIX, macOS DMGs, iOS apps, and Linux AppImages from any host OS.
- Hermetic Toolchains: Platform SDKs (NDK, Adoptium JDK 17, D8, Apple and Windows SDK headers) are downloaded once, verified with streaming SHA-256 digests, and cached locally in project-scoped directories.
- Pure-Rust Packaging: In-tree crates (crorust-android, crorust-apple, crorust-windows, crorust-linux, crorust-mvn) build and cryptographically sign packages with zero external IDE dependencies.
Quickstart: Build Your First Cross-Platform Native App
# 1. Install crorust CLI
cargo install crorust
# 2. Stage hermetic toolchains
crorust i
# 3. Initialize a cross-platform project from the ruxt template
crorust template init my_app
cd my_app
# 4. Build native packages for any platform:
crorust build -p android --release # Builds v2-signed APK with zero Gradle
crorust build -p windows --release # Builds signed MSIX package with OPC & PRI
crorust build -p macos --format dmg # Builds signed DMG via pure-Rust apple-codesign
crorust build -p linux --release # Builds AppImage Type-2 with pure-Rust squashfs
crorust build -p web # Builds WebAssembly PWA distribution
Role 1: crorust CLI Commands Reference Manual
Complete reference manual for all crorust CLI commands, parameters, options, and build targets.
crorust i — Initialize & Verify Hermetic Toolchains
Launches the interactive installer or runs headlessly to verify and download minimal LLVM/Clang headers, Android NDK platforms, Java JDK 17, and Windows/Apple sysroots into ~/.cache/crorust/ (or project-scoped .cache/crorust/).
crorust i --non-interactive
--non-interactive- Run without curses TUI (ideal for CI/CD automation and headless runners).
--check- Verify existing sysroots and integrity checksums without downloading missing packages.
crorust build — Cross-Compile & Package Native Artifacts
Drives Cargo with synthesized target flags and invokes in-tree packagers to construct production-ready release artifacts for Android, Windows, macOS, Linux, and Web.
crorust build --platform android --apk --release
crorust build --platform windows --msix --release
crorust build --platform macos --format dmg
crorust build --platform linux --release
crorust build --platform web
--platform <android|apple|windows|linux|web>- Target operating system.
--arch <aarch64|x86_64>- Target CPU architecture.
--apk- Build signed Android APK package without Gradle.
--aab- Build Android App Bundle for Google Play Store publication.
--dmg- Build signed macOS DMG installer with Apple notarization support.
--msix- Build Windows MSIX bundle with Authenticode digital signatures.
--appimage- Build Linux Type 2 AppImage with embedded SquashFS and runtime stubs.
--release- Optimize with LTO, strip debug symbols, and apply release keystore signatures.
crorust run — Deploy, Launch & Stream Hardware Logs
Compiles the target binary, deploys it to a physical device or emulator, launches the application, and streams stdout/logcat output directly back to your workstation terminal.
crorust run --device adb:emulator-5554
crorust devices — List Connected Hardware & Emulators
Discovers all attached Android devices via ADB, Apple devices/simulators via CoreSimulator bridge, and local desktop display servers.
crorust devices
crorust cert — Zero-Config Cryptographic Certificates
Generates self-signed developer certificates, PKCS#12 keystores for Android v2 signing, and Authenticode keys for Windows packaging without OpenSSL CLI commands.
crorust cert generate --output debug.p12
crorust cache — Manage Hermetic Toolchain Cache
Inspects disk usage of ~/.cache/crorust/ (sysroots, Maven AARs, SDK headers) and allows selective cache pruning.
crorust cache --stats
crorust cache --clean
crorust template init — Scaffold Multi-Platform Application
Extracts the crorust.ruxt reference boilerplate into a new project directory with ready-to-build desktop, mobile, and web targets.
crorust template init my_awesome_app
cd my_awesome_app
crorust run
Role 1: crorust Workspace Crates Architecture
Pure-Rust, host-agnostic member crates that assemble and cryptographically sign distribution packages on any workstation.
crorust — CLI Orchestrator & Toolchain Synthesizer
The root command-line tool, configuration parser, and Cargo flag synthesizer. Available on crates.io/crates/crorust with official documentation on docs.rs/crorust and full source code on GitHub. crorust parses manifest.toml, resolves target hardware devices (via ADB and Xcode simulators), manages the hermetic toolchain cache in ~/.cache/crorust/, and synthesizes RUSTFLAGS, CFLAGS, and linker flags.
crorust build --platform android --apk
crorust run --device adb:emulator-5554
crorust-android — Pure-Rust Android APK & AAB Packaging Engine
Builds and signs Android APK and AAB packages in pure Rust without Gradle or Android Studio. Encodes AndroidManifest.xml into Android Binary XML (AXML) with string pools and resource maps. Generates binary ARSC resource tables. Implements Android APK Signature Scheme v2 by computing 1MB Merkle tree chunk hashes and embedding the signing block directly before the ZIP Central Directory. Enforces 16KB and 4KB page alignment for zero-copy memory mapping (mmap).
// Synthesize and sign APK in pure Rust
let apk = ApkBuilder::new(manifest)
.add_dex(dex_bytes)
.add_native_lib(TargetArch::Arm64, lib_bytes)
.sign_v2(&keypair)?;
crorust-apple — Apple macOS & iOS Packaging Engine (No Xcode)
Packages macOS .app bundles, DMG disk images, and iOS .app/.ipa packages on any host. Parses Mach-O 64-bit binary headers, allocates LC_CODE_SIGNATURE load commands, and constructs Apple CMS/PKCS#7 signature blobs with SHA-256 CodeDirectory slots. Synthesizes binary Info.plist files and packages read-only HFS+/APFS DMG images without invoking hdiutil.
// Ad-hoc or developer codesigning of Mach-O binary without macOS
let signed_macho = apple_engine::sign_macho(&macho_bytes, &code_identity)?;
crorust-windows — Windows MSIX & Authenticode Engine
Builds Windows MSIX Open Packaging Conventions (OPC) containers and Authenticode signatures. Generates AppxManifest.xml, Package Resource Index (PRI) resources, and AppxBlockMap.xml containing 64KB block SHA-256 hashes. Signs the container with X.509 Authenticode certificates.
// Package and sign MSIX OPC bundle
let msix = MsixPackage::builder()
.manifest(appx_manifest)
.binary("app.exe", exe_bytes)
.sign(&cert, &key)?;
crorust-linux — Linux AppDir & Type 2 AppImage Engine
Constructs portable Linux AppImages using pure-Rust SquashFS compression. Synthesizes standard Linux AppDir directories (desktop entries, icons, MIME types, dynamic loader paths) and compresses them into standalone Type 2 AppImages using the backhand SquashFS library.
// Build Type 2 AppImage
let appimage = AppImageBuilder::new(appdir)
.compress_squashfs()
.emit_standalone_binary()?;
crorust-mvn — Pure-Rust Maven Solver with PubGrub
Hermetic Maven POM dependency solver for Android AAR/JAR dependencies without Gradle. Parses Maven POM XML files, evaluates version ranges, and computes optimal dependency closures using the PubGrub algorithm. Downloads and verifies SHA-256 hashes into ~/.cache/crorust/mvn/.
// Solve transitive Android dependencies
let solver = MvnSolver::new(repo_url);
let resolved_aars = solver.resolve(&["androidx.appcompat:appcompat:1.6.1"])?;
crorust-common — Shared Foundations, Crypto & Memory Alignment
Shared primitives for cryptographic signing, byte alignment, and ZIP container handling. Provides SHA-256, RSA-2048, and ECDSA P-256 signing operations; 4KB memory page alignment helpers; and high-performance streaming ZIP readers and writers.
// Compute 4KB memory alignment for mmap binary execution
let aligned_offset = crorust_common::align_up(current_pos, 4096);
crorust-runtime-stub — Minimal Runtime Linker Stubs
Lightweight runtime stubs satisfying platform C runtime linker requirements when linking Rust binaries against bare-metal or minimal sysroots.
// Minimal platform entry stub
#[no_mangle]
pub extern "C" fn _crorust_runtime_init() {}
Role 3: Ruxt Framework Technical Manual: The 7 Architectural Layers
The definitive engineering manual for cross-platform Rust graphical application development with winit, egui, and wgpu.
Chapter 1: The Platform Foundation — OS RunLoops & winit
Every cross-platform graphical application rests upon a hardware abstraction layer that bridges the operating system's asynchronous interrupt queues to user space. winit 0.30 normalizes window servers, enforces the Thread 0 GUI constraint, manages mobile surface lifetimes, and coordinates cross-thread execution via EventLoopProxy.
1. OS Window Servers & The Main-Thread GUI Constraint
Operating system windowing systems (Win32 HWND message pumps via GetMessageW/DispatchMessageW, macOS Cocoa NSRunLoop, Wayland wl_event_queue_dispatch, Android ALooper, and iOS UIApplicationMain) require that UI windows and event loops remain bound strictly to Thread 0 (the initial main process thread). Dispatching UI draw calls or polling windows from secondary worker threads triggers thread affinity panics or fatal X11/Cocoa errors.
2. winit 0.30 ApplicationHandler Lifecycle
In winit 0.30, the event loop implements the stateful ApplicationHandler trait instead of a closure-based pump:
resumed(&mut event_loop): Invoked when the OS grants an active drawing surface (essential on Android and iOS when resuming from background).window_event(&mut window, id, event): Dispatches input events (touch, mouse, keyboard, resize).user_event(&mut event_loop, event): Receives custom application messages dispatched from background Tokio worker threads.about_to_wait(&mut event_loop): Invoked when all pending OS events are drained, allowing the app to request redraw or sleep.
3. Cross-Thread Wakeups via EventLoopProxy
To communicate from async worker threads (e.g. Tokio network tasks or disk I/O) to the main thread without race conditions, winit provides EventLoopProxy<UserEvent>. It is Send + Sync and triggers a low-level OS wake signal (eventfd on Linux, PostMessageW on Windows, and CFRunLoopSourceSignal on macOS).
// Cross-thread event wakeup pattern
let proxy = event_loop.create_proxy();
tokio::spawn(async move {
let result = fetch_remote_data().await;
proxy.send_event(UserEvent::DataLoaded(result)).ok();
});
Chapter 2: The Bridge — Translating Window Events to GUI Input
The core egui library is completely decoupled from operating system APIs, windowing systems, and graphics runtimes. The egui-winit crate serves as an essential bidirectional adapter: it translates raw OS window events into logical RawInput structs and channels egui's PlatformOutput back to OS window-mutating commands.
1. The Adapter Pattern
egui does not link against winit or OS libraries directly. Instead, egui_winit::State maintains a pure abstraction barrier, transforming native window events into egui-consumable inputs.
2. High-DPI Scaling & Physical-to-Logical Coordinates
Operating systems deliver mouse coordinates and window sizes in physical pixels (scaled by display density, e.g. 200% on Retina/4K displays). egui operates entirely in logical points. The bridge computes:
let logical_pos = physical_pos.to_logical(pixels_per_point);
3. The PlatformOutput Feedback Loop
After rendering a frame, egui produces a PlatformOutput struct containing:
- Cursor Icon Mutations: Changing the OS mouse cursor (e.g. Pointer, Text, Grab, ResizeHorizontal).
- System Clipboard: Copying text to the OS pasteboard.
- IME Composition Rect: Positioning the native Input Method Editor candidate box directly under the active text cursor.
- Open URL Commands: Launching system default browsers.
Chapter 3: The Immediate-Mode GUI (IMGUI) Architecture
Understanding the immediate-mode paradigm versus traditional retained-mode GUI frameworks. In retained mode (DOM, Qt, WPF), developers construct and mutate a long-lived tree of widget objects. In immediate mode, the UI is reconstructed from scratch every frame as a pure projection of application state: f(State) -> UI.
1. Retained vs. Immediate Mental Model
There are no widget handles, no event listener callbacks, and no two-way synchronization bugs. If a boolean is true, the button is rendered; if false, it is simply not drawn.
2. The 64-bit egui::Id Hashing Mechanism
Because widgets are ephemeral and do not persist in memory, egui uses a 64-bit Murmur64 hash to identify widgets across frames for interactions like scroll positions, text selection, and animations. When creating widgets inside dynamic loops, developers use ui.push_id(item_id, |ui| { ... }) to guarantee unique hashing and prevent ID collisions.
3. The egui::Memory Cache
State that outlives a single frame (window positions, collapsed tree headers, text cursor blinks) is stored in a centralized Memory struct keyed by Id, which automatically garbage-collects unused widget state.
Chapter 4: The Engine Core — Deep Dive into egui::Context
The egui::Context is the central coordinator of the entire immediate-mode engine. It holds the input state, output commands, style sheets, font glyph atlases, and repaint request queues.
1. Interior Mutability & Thread Safety
Context wraps an Arc<ContextImpl> with internal read-write locks (RwLock). It is cheap to clone (pointer-sized copy) and can be passed freely across threads.
2. Repaint Scheduling & Frame Pacing
To avoid draining battery life and consuming 100% CPU on static screens, egui does not render at a continuous 60 FPS by default. It sleeps until an input event occurs or a widget calls:
ctx.request_repaint(): Requests immediate repaint on the next frame (e.g. on mouse hover or button press).ctx.request_repaint_after(duration): Schedules a delayed repaint for animations or timers.
3. Glyph Atlasing & Fontdue Rasterization
egui embeds pure-Rust font rasterization (via fontdue/ab_glyph). Text glyphs are dynamically rendered into a single-channel alpha texture atlas, uploaded to GPU VRAM, and reused across all text rendering operations.
Chapter 5: UI Geometry, Layout Engine & Custom Widgets
How egui arranges widgets in 2D space without CSS or constraint solvers, and how to implement custom interactive controls using the Widget trait.
1. 2D Coordinate Algebra: Pos2, Vec2, and Rect
All layout calculations in egui operate on 2D vectors (Vec2), points (Pos2), and bounding boxes (Rect). A Rect is defined by min (top-left) and max (bottom-right) coordinates.
2. Cursor Advancement & Bounding Box Allocation
As widgets are added to a Ui, egui advances an internal 2D cursor. When a widget requests space, it calls ui.allocate_exact_size(size, sense), which reserves a Rect and advances the cursor downward or rightward.
3. Implementing the egui::Widget Trait
pub struct CustomDial { pub value: f32 }
impl egui::Widget for CustomDial {
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
let (rect, response) = ui.allocate_exact_size(egui::vec2(60.0, 60.0), egui::Sense::click_and_drag());
if ui.is_rect_visible(rect) {
let painter = ui.painter();
painter.circle_filled(rect.center(), 28.0, egui::Color32::from_rgb(30, 41, 59));
}
response
}
}
Chapter 6: The Rendering Pipeline — From Shapes to Hardware Pixels
The complete journey from high-level paint declarations down to GPU draw calls executing on Vulkan, Metal, DirectX 12, or WebGPU.
1. Intermediate Paint Shapes
Widgets do not emit draw calls directly. They emit abstract vector geometry into Vec<Shape> (lines, circles, bezier curves, quads, and text glyphs).
2. Tessellation & Anti-Aliased Feathering
The epaint tessellator converts abstract shapes into triangle meshes (vertices and indices). It generates smooth sub-pixel anti-aliasing by adding transparent 1.0-pixel border fringes to polygon boundaries without requiring expensive multi-sample anti-aliasing (MSAA).
3. The 20-Byte Vertex Stride
epaint generates tightly packed, cache-coherent vertices with a compact 20-byte stride:
pos: [f32; 2](8 bytes: X and Y coordinates in logical points)uv: [f32; 2](8 bytes: U and V texture coordinates in the font atlas)color: [u8; 4](4 bytes: RGBA 8-bit vertex color with premultiplied alpha)
4. egui-wgpu Hardware Execution
The egui-wgpu backend binds the vertex buffer, index buffer, uniform projection matrix, and texture bind groups, executing indexed draw calls inside a standard wgpu::RenderPass.
Chapter 7: Integration in Ruxt — Multi-Platform Architecture & Testing
Synthesizing the entire architecture: compiling across desktop, mobile, and web targets with declarative configuration in manifest.toml, and verifying UI logic headlessly with egui_kittest.
1. The 9-Stage Ruxt Execution Pipeline
From OS window interrupts, winit event translation, egui frame execution, layout algebra, shape gathering, epaint tessellation, wgpu buffer upload, GPU rasterization, to hardware scanout.
2. Mobile & Web Nuances
Ruxt normalizes mobile 48dp minimum touch target boundaries, touch scroll inertia, and WebAssembly async event loops without platform-specific code branching.
3. Automated Headless Testing with egui_kittest
Ruxt applications can be verified in headless CI/CD environments without requiring a physical monitor or GPU display server using egui_kittest:
#[test]
fn test_ruxt_application_headless() {
let mut harness = egui_kittest::Harness::new(|ctx| {
egui::CentralPanel::default().show(ctx, |ui| {
ui.label("Hello Headless World");
});
});
harness.run();
}
Role 2: The ruxt Production Starter Template (Open Source MIT / Apache-2.0)
crorust.com is not only a documentation site; it is a live deployment of ruxt, the official, production-ready cross-platform application starter template. ruxt is released under a permissive dual-license (MIT OR Apache-2.0), allowing individuals, open-source contributors, and commercial enterprises to freely fork, modify, and build production applications with zero licensing fees or restrictive copyleft obligations.
Scaffold Your Application in Seconds
Initialize a new cross-platform Rust GUI project using the crorust CLI:
# 1. Install crorust and stage minimal toolchains
cargo install crorust && crorust i
# 2. Scaffold a new application from the ruxt template
crorust template init my_app
cd my_app
# 3. Launch live on your desktop workstation
crorust run
# 4. Cross-compile for production release
crorust build -p android --apk --release # Pure-Rust signed APK
crorust build -p windows --msix --release # Pure-Rust signed MSIX
crorust build -p macos --format dmg # Pure-Rust signed DMG
crorust build -p linux --release # Pure-Rust Type-2 AppImage
crorust build -p web # WebAssembly PWA distribution
Pre-Configured Architecture & Production Features
The ruxt template eliminates weeks of boilerplate setup by providing pre-wired foundations:
- Graphics Acceleration via wgpu: Hardware-accelerated rendering powered by WebGPU, Vulkan, Metal, and DirectX 12, with automatic fallback to OpenGL (
glow). - Immediate-Mode UI via egui: Declarative, responsive UI powered by
egui 0.36, including custom widgets, data tables, and dynamic visual themes (Dark & Light modes). - Declarative Multi-Platform Manifest (
manifest.toml): Configure application package names, deep links, intent filters, Android permissions, Windows capabilities, and Apple entitlements in a single unified configuration file. - Universal File Import: Native file loading supporting image viewing (PNG, JPEG, WebP) and markdown document rendering working identically across Desktop (native
rfddialogs), Android (SAF content URIs), and WebAssembly (browserFileReaderAPI). - Mobile Ergonomics & Touch Bounds: Responsive single-column layouts on smartphones with automatic 48dp minimum touch bounds, smooth inertial touch scrolling, and safe area insets.
- State Persistence: Serializes and restores window dimensions, active navigation tabs, theme preferences, and user workspace states via
eframe::persistenceandserde. - Automated Headless Testing: Integrated with
egui_kittestto enable fast, headless UI test execution in CI/CD environments without requiring a physical monitor or GPU display server.
Permissive Open-Source Dual License
The ruxt application template is dual-licensed under both:
- The MIT License: Permissive, allowing commercial usage, distribution, modification, and private sublicensing.
- The Apache License, Version 2.0: Provides explicit copyright and patent grants for enterprise and commercial safety.
Full source code and license terms are maintained in the official repository on GitHub (adi1ahmad/crorust) under LICENSE-MIT and LICENSE-APACHE.