diff --git a/crates/cargo-horizon-mod/Cargo.toml b/crates/cargo-horizon-mod/Cargo.toml index 34eefe227..21b8a9221 100644 --- a/crates/cargo-horizon-mod/Cargo.toml +++ b/crates/cargo-horizon-mod/Cargo.toml @@ -6,8 +6,14 @@ license.workspace = true rust-version = "1.86" description = "cargo horizon-mod new/build/run/check: make Horizon mods in Rust (docs/mods.md)" +[features] +default = ["full"] +# The trial runs (`check`, `test`) and the registry's CI need wasmtime. Without this feature the +# tool is new, build and run only, and builds in a fraction of the time (CI that only packs mods). +full = ["horizon-mods/runtime", "horizon-mods/index"] + [dependencies] -horizon-mods = { path = "../horizon-mods", default-features = false, features = ["pack", "runtime", "index"] } +horizon-mods = { path = "../horizon-mods", default-features = false, features = ["pack"] } serde_json = "1.0.151" [lints] diff --git a/crates/cargo-horizon-mod/src/main.rs b/crates/cargo-horizon-mod/src/main.rs index 95d0a9eb3..ff4ab663b 100644 --- a/crates/cargo-horizon-mod/src/main.rs +++ b/crates/cargo-horizon-mod/src/main.rs @@ -11,12 +11,15 @@ //! - `check [--json]`: what the registry checks of a submission //! (`.hmod`, `.hpack`, resource pack `.zip`), with a trial run for a mod. //! - `registry build|review|check|list`: the registry repository's CI. +#[cfg(feature = "full")] +use horizon_mods::testing::{Script, TestGame}; use horizon_mods::{ Capability, Content, Manifest, Package, manifest::{MANIFEST, component_imports, componentize}, - testing::{Script, TestGame}, }; +#[cfg(feature = "full")] mod check; +#[cfg(feature = "full")] mod registry; use std::{ @@ -39,9 +42,16 @@ fn main() -> ExitCode { println!("Built {}", p.display()); }), Some("run") => run(&args[1..]), + #[cfg(feature = "full")] Some("test") => test(&args[1..]), + #[cfg(feature = "full")] Some("check") => check(&args[1..]), + #[cfg(feature = "full")] Some("registry") => registry::main(&args[1..]), + #[cfg(not(feature = "full"))] + Some("test" | "check" | "registry") => { + Err("this cargo-horizon-mod was built without trial runs (feature `full`)".into()) + } _ => Err("usage: cargo horizon-mod new [--template code|content] | build [--debug] | run [--game ] [-- ] | test [--debug] [--hmod ] [] | check [--kind ] [--key --signature ] [--json] | registry build|review|check|list".into()), }; match result { @@ -249,6 +259,7 @@ fn compile(root: &Path, release: bool) -> Result<(Vec, PathBuf), String> { /// `check `: the registry's checks of a submission, printed; fails /// when one does. +#[cfg(feature = "full")] fn check(args: &[String]) -> Result<(), String> { let file = args .first() @@ -280,6 +291,7 @@ fn check(args: &[String]) -> Result<(), String> { /// `test`: every `tests/*.toml` script (those whose name holds ``) /// against the built mod, or the `.hmod` given with `--hmod`. +#[cfg(feature = "full")] fn test(args: &[String]) -> Result<(), String> { let hmod = match flag(args, "--hmod") { Some(p) => PathBuf::from(p), @@ -360,7 +372,7 @@ fn run(args: &[String]) -> Result<(), String> { .ok_or_else(|| format!("the game exited with {status}")) } -#[cfg(test)] +#[cfg(all(test, feature = "full"))] mod tests { use super::*;