Expand description
“Build Game” — packs the project’s assets and stages a runnable binary.
Two strategies, picked deterministically from the project’s contents:
-
Runtime stamp (default, project has no
Cargo.toml):khora_io::PackBuilderproducesindex.bin+data.packfrom<project>/assets/.- The pre-built
khora-runtimebinary for the chosen target is copied into the output directory and renamed to the project name. - A
runtime.jsoncompanion file is written so the runtime knows which scene to auto-load.
This path is cross-platform trivial — the runtime binary already exists for every target (built by
release.yml), so building Linux from a Windows host is just a file copy. -
Cargo build (project has
Cargo.toml— opted in via the hub’s “Add Native Code” button):- Same
PackBuilderstep. cargo build --release --manifest-path <project>/Cargo.tomlcompiles the user’s binary (which depends onkhora-sdkand registers their custom components / agents / lanes).- The compiled binary is copied into the output directory.
- Same
runtime.jsoncompanion is written.
This path is host-only in v1 because Rust cross-compilation needs per-target toolchains; running the editor on each target is the simplest workaround. Future work can integrate
crossfor Docker-based cross-compilation. - Same
Output layout (identical between the two strategies):
<project>/dist/<target>/
├── <project_name>{.exe} # renamed runtime OR compiled user binary
├── data.pack # asset blobs
├── index.bin # asset metadata (UUIDs → packed offsets)
└── runtime.json # project name + default scene rel pathThe user can therefore start data-only, ship cross-platform via the
stamp strategy, and “graduate” to native Rust without changing how
Build Game is invoked — the editor switches strategies automatically
based on Cargo.toml’s presence.
Structs§
- Build
Outcome - Result of a successful build, returned to the caller (the editor’s menu dispatcher logs + banners off these fields).
- Runtime
Config 🔒 - What we write next to the staged runtime so it knows which scene to
auto-load. Mirrors the schema
khora_runtime::RuntimeConfigreads.
Enums§
- Build
Preset - Build profile selecting compression / manifest / runtime-validation trade-offs in one place. Callers pick the preset; the build pipeline reads the resolved settings off it.
- Build
Strategy - Which build strategy was used to produce a
BuildOutcome. - Build
Target - One of the platforms the editor knows how to stage a build for.
Functions§
- build_
for_ host - Stages a build for the host OS using the Release preset by default. Convenience wrapper for the menu’s “Build Game…” entry.
- build_
for_ target - Stages a build for any target with an explicit preset. v1 only
invokes this with the host; non-host targets fail at the
runtime-binary lookup (or, for the cargo path, are explicitly
refused — see
stage_with_cargo_build) until cross-compile lands. - dirs_
home 🔒 - engine_
cache_ 🔒dir - Returns
~/.khora/engines/if accessible. The hub manages this directory; the editor reads from it. - find_
compiled_ 🔒binary - Walks
target/release/for the first regular file with the host’s executable suffix, ignoring cargo metadata files (.d,.rlib, etc). - find_
file_ 🔒recursive - Recursive file search. Returns
Some(path)for the first hit. - locate_
runtime_ 🔒binary - Looks for the
khora-runtimebinary fortargetin: - sanitize_
binary_ 🔒name - Replaces filesystem-unsafe characters in the project name with underscores so we can use it as a binary filename.
- set_
executable_ 🔒bit - stage_
with_ 🔒cargo_ build - Invokes
cargo build --releaseagainst<project>/Cargo.toml, streams stdout+stderr into the editor log, and copies the resulting binary intooutput_dirrenamed to the project name. - stage_
with_ 🔒runtime_ stamp - Stamps the pre-built
khora-runtimeintooutput_dir, renamed to the project name. Returns the absolute path of the staged binary. - workspace_
root_ 🔒from_ target_ dir - Returns the workspace root if
target_diris atarget/<profile>/subdirectory of one. Detection: parent must be namedtarget, and the grandparent must contain aCargo.toml. - write_
runtime_ 🔒config