Export System
This page is about how an export is built: what the Export window decides, what it runs, and why it is shaped that way. To export a game from the editor, read Exporting instead.
All of it lives in crates/renzora_export. The editor side (the dialog) is in src/dialog/. The rest are plain modules:
| Module | Job |
|---|---|
overlay.rs | ExportOverlayState, the export worker, and the per-platform packaging |
build.rs | The lean build: workspace sync, manifest patching, static plugins and scripts, cargo |
capabilities.rs | The capability table and the project scan that preselects it |
templates.rs, download.rs | Finding and downloading export templates (see Export Templates) |
docker.rs, toolchain.rs | Where a lean build runs, and the Rust toolchain it runs with |
wasm.rs | wasm-bindgen, wasm-opt and the web page for a lean web build |
bundle.rs, sign_macos.rs, apk_signer.rs | AppImage and .app wrapping, macOS signing, APK signing |
upx.rs, glibc.rs, icon.rs | Executable packing, the glibc check, icon encoding |
remote.rs, console.rs | Running the export in the companion, and cargo in its own terminal |
presets.rs | Saved export settings per project |
One binary, two roles
There is one executable, renzora (package renzora_app). It looks for the editor image (renzora_editor.dll, .so or .dylib) beside itself at startup: present, it is the editor; absent, it is the game. An export never ships the editor image, so the same binary runs as the game. See Architecture.
The game finds its content through the virtual file system in crates/renzora_engine/src/vfs.rs. On desktop, Vfs::detect tries, in order:
--rpak <path>on the command line.- An rpak appended to the running executable (the footer check, see Asset Packing).
<exe-stem>.rpakbeside the executable.- The plain file system.
Android reads the APK's assets, iOS reads game.rpak from the app bundle, and the web build is handed the archive's bytes by JavaScript before it starts. The three export modes below differ only in where the binary comes from and which of those slots the archive fills.
The three modes
ExportOverlayState::packaging_mode is one of:
| Mode | Binary | Archive | Plugins |
|---|---|---|---|
SeparateFiles (default) | The template, copied | <binary>.rpak beside it | Shipped as files |
SingleBinary | The template, copied | Appended to the binary | Shipped as files |
LeanSingleBinary | Compiled for this project | Appended to the binary | Compiled in |
The two copy modes are fast and need no compiler: they copy a prebuilt runtime from an export template and pack the project beside it. The shared libraries the template was built with go with it (files beside the template matching _dylib, std-, libstd- or openxr_loader), because the default runtime is dynamically linked. Inside a macOS .app the archive is always written beside the executable, whatever the mode: codesign refuses a Mach-O with data appended, so a bundle built that way could never be signed. The bundle is already the single unit the mode promises.
The lean mode compiles the engine again with only the features the project uses, statically linked, into one file. It takes minutes, and it is the only mode that strips anything.
Whether plugins are compiled in is decided by the mode, not chosen separately: link_plugins_in is true exactly for LeanSingleBinary. A lean binary is built without dynamic_linking, so it has no plugin loader (NativePluginLoader exists only under that feature) and cannot load a plugin from a file. The copy modes keep the loader, so they ship plugins as files. (PluginLinkMode is still a field on the state; nothing reads it to decide this any more.)
The export worker
The Export button starts a thread that runs these steps in order. Each reports a progress line to the window.
- Virtual geometry. If the project enables
rendering.virtual_geometryand the export keeps that capability, models are converted first (ensure_virtual_geometry), so the archive picks up the.rvgfiles. - Pack. If the Files tab was used (
included_filesisSome), exactly those files are packed (pack_selected_with_progress). Otherwise the project is crawled from its entry points (pack_project_with_progress). - Strip.
strip_for_runtimeremoves editor-only components from scenes. - Plugin files marked to go into the archive are added.
- Meshes. Optional simplification, quantization and LOD generation through
renzora_import::optimize_glb. - project.toml is rewritten: window settings, console logging, the profiling key, and
editor_last_sceneandeditor_open_tabscleared. - Icon. Re-encoded to a 256 px PNG at
assets/icon.png. - Package for the platform (next section), into
<output_dir>/<project_name>/. - Beside the binary: shared libraries, DLSS libraries when Solari is on, native plugins, and UPX on the libraries.
- Wrap:
bundle::wrapmakes the.AppDir/ AppImage on Linux and the.appon macOS (bundle identifierorg.renzora.<slug>). - Server, if Include server is on.
- Seal: macOS signing runs last, because anything written into the bundle after it invalidates the signature.
Per-platform packaging
| Target | What is written |
|---|---|
| Windows, Linux, macOS | The binary plus <binary>.rpak (separate files), or the archive appended (single and lean) |
| Web (lean) | wasm-bindgen, wasm-opt, then <name>-web.zip with the bundle, game.rpak and index.html |
| Web (template) | <name>-web.zip from the template zip, plus the archive |
| Android | The template APK copied, assets/game.rpak added uncompressed, resources.arsc and native libraries stored with 16 KiB alignment, then signed |
| iOS | The template zip, with <app>/game.rpak injected, written as <name>.ipa |
The Android signer (apk_signer.rs) writes an APK Signature Scheme v2 block with a debug ECDSA P-256 key. That is enough to sideload and test; a store build needs the developer's own key.
UPX
upx.rs packs with --best --lzma, from RENZORA_UPX or PATH, and only for Windows x64 and Linux x64. The executable is packed on a temporary copy before the archive is appended, because UPX would treat the appended bytes as part of the image. A missing UPX skips the step with a note; it never fails the export.
Dedicated server
Include server is offered for desktop targets only. It packs a second archive with pack_project_filtered over the server extensions (scenes, toml and json config, and script sources; no meshes, textures or audio), runs strip_for_server on it, and writes server.rpak beside the game. A launcher passes it explicitly:
# server.bat, written for Windows x64
"%~dp0<exe>" --server --rpak "%~dp0server.rpak" %*
server.sh does the same for Linux x64 and both macOS targets. The server is the same binary: --server boots it headless. Turning Include server on does not change any capability; if the export stripped networking, the server boots as an ordinary client and logs that it was exported without networking. See Networking Internals.
macOS signing
sign_macos::seal signs ad hoc by default. With RENZORA_CODESIGN_IDENTITY set it signs with that Developer ID, and with RENZORA_NOTARY_KEY, RENZORA_NOTARY_KEY_ID and RENZORA_NOTARY_ISSUER also set it notarizes. All of it needs a Mac, because the tools exist only there.
Capabilities
A capability is one switch in the Features tab that maps to Cargo features:
pub struct Capability {
pub id: &'static str,
pub label: &'static str,
pub help: &'static str,
pub bevy_features: &'static [&'static str],
pub runtime_features: &'static [&'static str],
pub default_on: bool,
/// Parent capability: a child is a strict subset and goes off with it.
pub group: Option<&'static str>,
/// Which Features-tab section it is listed under. Presentation only.
pub section: &'static str,
}
Turning one off adds its bevy_features and runtime_features to the lists the lean build strips. Capabilities only matter to a lean export; the copy modes use a template that was built with everything.
A child must go off with its parent even when the saved state says otherwise (is_on checks the parent): leaving one Bevy feature of a subsystem on would pull the rest of the subsystem back in through cargo, and the build would grow again or fail.
SECTIONS lists the Features tab's headings in order: 3D rendering, 2D rendering, Post-processing, Sky & environment, Simulation, Systems & gameplay, Interface, Assets, and Build & diagnostics. A few capabilities to know about:
| Id | What turning it off removes |
|---|---|
render_3d, render_2d | The 3D or 2D pipeline. With render_3d off, everything that depends on it (terrain, the sky set, post-processing, decals, planar reflections, Solari) goes off too |
solari, virtual_geometry | Ray-traced GI, and the .rvg model path |
physics_3d, physics_2d | The physics engine for that dimension |
networking | The whole multiplayer stack |
scripting | Script support (Rust scripts are compiled in separately, below) |
ui, game_ui | The UI framework and the game UI runtime |
panic_unwind, loop_vectorization, parallel_codegen | Build knobs, not features (see below) |
Autodetection
scan_project walks the project once (skipping dot-directories, and files over 16 MiB) and collects two things: the file list the Files tab shows, and evidence for each capability. The evidence comes from two tables:
detection_extensions: a file of this kind means the capability is used. For exampleanimandanimsmfor animation,mp3,ogg,wavandflacfor audio,rvgandglbfor virtual geometry,materialfor the shader graph,htmlfor the UI.detection_types: substrings searched for in the text of scenes, scripts and other text assets (bsn,ron,rs,html,material,particle,anim,animsm). These are type paths as a scene writes them (bevy_pbr::,renzora_terrain::,Camera3d) and API names as a script calls them. Networking, for instance, is detected fromrenzora_network::,Networked,ScriptHook::Rpcandrenzora::network, and picking fromPointer<andOn<Pointer.
Searching text instead of loading scenes is deliberate: it is fast, needs no type registry, and a Rust script that calls renzora::network::is_server is as much evidence as a scene that holds a Networked component.
defaults_from_scan turns the evidence into the initial switches, with a few rules where evidence would mislead:
- A project with no scene at all gets every capability's
default_on, because there is nothing to judge from. - If world content exists but neither pipeline was detected, both 3D and 2D stay on. Physics follows whichever pipeline is on.
- With no world content, camera effects start off.
- Localization is also on when the project has a
languages/folder or a default language other thanen.
enforce_dependencies then switches off whatever depends on something that is off. Both of its rules only ever switch things off: turning on a dependent never silently turns its parent back on.
Plugins are preselected the same way: a plugin is ticked when the scan finds its crate name followed by :: in the project.
Build knobs
Three capabilities change the lean profile rather than the feature set. patch_lean_profile writes them into the export copy's [profile.dist-lean], and removes them again when turned back on (the copy persists between exports, so a stale setting would otherwise apply to the next build):
| Capability off | Profile change |
|---|---|
panic_unwind | panic = "abort": smaller, but a panic in any system ends the game |
loop_vectorization | opt-level = "z" instead of 2 |
parallel_codegen | codegen-units = 1: smaller, much slower to build |
opt-level = "s" is never used: a lean game built with it crashed in the shadow pass.
Leaving Allow profiling off also strips the runtime features remote_profiler and system_names, and Bevy's trace.
The lean build
build::build_lean compiles the runtime for one project and one platform.
The export workspace
It never builds in the engine checkout. sync_export_workspace mirrors the engine source into <engine>/target/export-src/, copying a file only when its size or modification time differs and pruning files that were removed. It skips the directories a build does not need (target, .git, docs, docker, templates, plugins and so on) and any cdylib crate. The copy has its own target/, so exports are incremental between runs and never touch the development build's cache or locks.
Every step below edits the copy, which is why it can patch manifests freely without restoring them:
patch_cross_cargo_config(container builds only): drops theprefer-dynamiclines from the copy's.cargo/config.toml.stage_branding: writes the executable's multi-sizeicon.icoand its version strings (export-branding.txt).strip_bevy_features: removes the disabled Bevy features from the workspace'sbevydependency, including the per-target tables.strip_runtime_features: editsrenzora_runtime's default features.strip_sdk_layers: drops SDK layers whose Bevy feature is gone (text meshes needbevy_text).patch_lean_profile: the build knobs above.stage_static_plugins, thenstage_static_scripts.
The features are stripped by editing the manifests because cargo cannot turn a feature off once a dependency turns it on. This is also why the root wasm feature forwards no bevy/* feature: anything it forwarded could not be stripped.
The cargo command
cargo build --profile dist-lean --bin renzora \
--no-default-features --features runtime[,static_plugins][,static_scripts][,dlss]
The web uses --features wasm instead of runtime. [profile.dist-lean] inherits dist with thin LTO, opt-level = 2 and stripped symbols.
For a native build the exporter sets CARGO_ENCODED_RUSTFLAGS, which replaces the rustflags from .cargo/config.toml. That is how -C prefer-dynamic is dropped: without it the standard library is linked statically and the result needs no std-*.dll beside it. On Windows x64 it also adds -C target-feature=+crt-static, so the game needs no Visual C++ runtime installed.
Where it runs
| Target | Runs |
|---|---|
| The host's own platform | Native cargo |
| Web | Native cargo with --target wasm32-unknown-unknown |
| Another desktop OS | The toolchain container for that OS |
| Android, iOS | No lean build |
Running in a container and passing --target are separate decisions (docker::needs_container and the target triple): the web needs a target but no container, since rustc ships its own wasm linker. Container builds use ghcr.io/renzora/<linux|windows|macos>, tagged by a hash of the Dockerfiles, with the export workspace mounted. See Cross-Compiling.
For a native build, toolchain.rs finds cargo on PATH, then a toolchain it provisioned before, then installs one with rustup into ~/.renzora/toolchain (its own CARGO_HOME and RUSTUP_HOME, without touching PATH). A container build carries its own compiler and provisions nothing.
Where the engine source comes from
resolve_engine_source prefers a checkout: it walks up from the editor's directory looking for Cargo.toml, crates/ and src/main.rs together. An installed editor has no checkout, so it uses ~/.renzora/src/<ENGINE_VERSION>/, downloaded from the release's engine-source.zip and stamped with a template.json whose tag must match the editor's release tag. A source tree from another release is not used.
With Build console on (the default), cargo runs in a terminal window of its own so its full output is visible (cmd.exe on Windows, Terminal on macOS, $TERMINAL or a known emulator on Linux). Where no terminal can be opened it falls back to the window's log.
DLSS
export_has_dlss decides. The export must keep Solari, and the DLSS runtime libraries (dlss_files: the NGX libraries for Windows and Linux) must be found beside the template or in the editor's DLSS install. A copy-mode export then ships them beside the binary. A lean export compiles DLSS in only when the build is native (not in a container) and both DLSS_SDK (with its include folder) and VULKAN_SDK point at real directories, because without them the build fails in a build script instead of falling back. See DLSS.
glibc
A lean Linux build links against the build machine's glibc. glibc::newest_in reads the newest GLIBC_x.y symbol version the built file asks for (from the file, not the host: a binary built on a new glibc that uses no new function still runs on older systems), and the export reports it, since that version is the oldest a player's system can have. Editor releases are built on AlmaLinux 8 (glibc 2.28) for the same reason.
Static plugins
A lean binary cannot load plugins, so plugins are compiled into it as ordinary crates.
resolve_static_plugins sorts the plugins the user ticked into a StaticPluginPlan:
| Bucket | Meaning |
|---|---|
linked | Will be compiled in |
no_source | Only a built library exists, so there is nothing to compile |
unsupported | The manifest lists this target in unsupported-targets |
editor_only | An Editor-scope plugin; never compiled into a game |
A plugin qualifies only when its manifest declares a dylib crate type and its src/lib.rs has plugin!(SomeType, ...) with a plain type name, because that is the expression the generated code calls. A target is excluded by a substring of its triple:
[package.metadata.renzora]
unsupported-targets = ["wasm32"]
Before compiling, editor_code_outside_editor_module checks each plugin: editor-contract names may appear only in src/editor.rs or src/editor/, and lib.rs must not declare mod editor itself (the plugin! macro does, behind the right gate). Code inside editor! { } blocks is ignored. A plugin that breaks this fails the export with the file named, instead of failing deep inside the compiler.
stage_static_plugins then:
- Copies each plugin into
<workspace>/plugins/<dir>. - Patches its manifest: the crate type becomes
rlib, any[workspace]and[profile]tables are dropped, and itsbevyandrenzoradependencies are pointed at the workspace's own crates, so there is one Bevy. - Rewrites
crates/renzora_static_pluginsin the export workspace.
The checked-in crates/renzora_static_plugins is a stub whose native_plugins does nothing. The generated one looks like:
pub fn native_plugins(app: &mut bevy::app::App) {
app.add_plugins(my_plugin::MyPlugin);
// one line per linked plugin
}
Its manifest depends on each plugin by path and enables renzora_platform_api's static_plugins feature, under which plugin! emits no exported constructor. src/main.rs calls renzora_static_plugins::native_plugins(app) after the engine's own plugins, when the static_plugins feature is on. Editing the checked-in stub changes nothing about an export: it is regenerated every time.
Static scripts
Rust scripts are native plugins in the editor (see Rust Scripts); a lean binary cannot load those either. stage_static_scripts compiles them in:
- Every
.rsscript in the project is found byrenzora_rust_script::collect_project_scriptsand copied tocrates/renzora_static_scripts/src/script_<n>.rs. - The generated
lib.rsincludes each with#[path] mod script_<n>;and exports two tables:scripts(), a list of(name, fn(&mut World, Entity)), andhooks()for scripts whosescript!declares hooks. - Each script is listed under its project-relative path, and also under its file name when no other script shares that name. Two scripts with the same file name are reached by path only, and the build log says so.
- The generated manifest depends on
renzora_sdk(under the namerenzora) with itsstatic_scriptsfeature, plusuiwhen the export keeps the Interface capability. Understatic_scripts,script!emits no#[no_mangle]symbol, because every script exports the same symbol name and two of them in one binary would fail to link.
renzora_rust_script reads those tables when the static_scripts feature is on, and dispatches exactly as it does for loaded scripts. The feature is never enabled in the development tree: cargo unifies features across the workspace, and turning it on anywhere would turn it on for the editor too.
In the copy modes nothing is compiled. On the host platform, stage_prebuilt_scripts copies each script's newest built library from <project>/.renzora/scripts/<stem>/ into scripts/ beside the game, with an index file (renzora_rust_script::PREBUILT_MANIFEST) mapping each script's path and name to its file. stage_runtime_native_plugins does the same for Runtime-scope plugins, skipping disabled ones and any built for a different engine, and writes the engine stamp beside them. Other platforms need the lean mode for scripts.
Modding
Enable modding ships the plugin SDK beside the game (sdk.tar.zst if one exists, else the sdk/ folder) and an empty plugins/ folder, so players can build and load plugins against the exact engine the game shipped with. It adds about 1.5 GB, and is staged only by the copy modes on the host platform, which keep the loader.
The web build
A lean web build adds three steps after cargo (wasm.rs):
- wasm-bindgen. The CLI version must match the
wasm-bindgencrate exactly, so the version is read fromCargo.lockandcargo install wasm-bindgen-cli --version <v> --lockedruns when the installed one differs. - wasm-opt
-Ozwith the post-MVP features the runtime uses enabled. It comes fromPATH, or from a binaryen release downloaded into~/.renzora/tools. If neither works the bundle ships unoptimized rather than failing. - index.html. A page with
<canvas id="bevy">that streams the module with a progress bar, fetchesgame.rpak, hands it to the runtime withset_rpak, and only then callsstart().
The order is fixed by src/main.rs: on wasm the #[wasm_bindgen] set_rpak export stores the bytes for Vfs::detect, and start() builds the app. Starting first would boot with an empty file system.
Networking does nothing on the web (a browser cannot open a UDP socket), and Rust scripts are compiled in through static scripts since the web has no dynamic loading.
Remote export
An export packs and compresses every asset and, for a lean build, runs cargo for minutes. remote.rs serializes it as an ExportJob and runs it in the companion process (job kind export) through CompanionRemote::run_cancellable. The companion runs at a lower priority, so the editor's frame goes first. Progress notes come back to the same window, and Cancel cancels the job, which stops cargo. With no companion connected the export runs on a thread in the editor, as it would anyway. See Companion.
Presets
presets.rs saves the window's settings per project in ~/.renzora/export_presets.toml, keyed by the project's directory, so the next export of the same project starts where the last one left off.
Getting help
Export problems are easiest to diagnose with the full build log. Bring it to the Discord server: https://discord.gg/9UHUGUyDJv