Merge pull request #3388 from horizon-rust/fix/native-mods-mixins-cargo

🤖 Agent: verify green; launcher-only, one function. pr_ready green (launcher tests 228/228). Parity --changed: nothing selected (lan_integration is nightly-only, and the launcher is not in the LAN suite). Proof end to end with no system Rust: the launcher's toolchain built zoom on macOS (546 s) and Linux (729 s, launcher from this branch's dry-run 40767814775), and zoom's offscreen proof passed on both launcher-built games. Before the fix both stopped at E_METADATA.
This commit is contained in:
Ludovic Marie authored and GitHub committed 2026-10-28 22:58:12 +01:00
commit 77fa9fb89f
1 file changed
+50 -4
+50 -4
View File
@@ -492,6 +492,16 @@ fn tool(rust: &Toolchain, rev: &str) -> Result<PathBuf, String> {
Ok(bin)
}
/// `horizon-mixins apply`: the mods in `mods` applied to `source`, into `out`. It runs
/// `cargo metadata`, so it gets the launcher's toolchain like a build does: on a computer with no
/// Rust of its own, a plain command found no cargo (E_METADATA).
fn apply(rust: &Toolchain, tool: &Path, source: &Path, mods: &Path, out: &Path) -> Command {
let mut cmd = rust.command(tool);
cmd.arg("apply").arg("--workspace").arg(source);
cmd.arg("--mods").arg(mods).arg("--out").arg(out);
cmd
}
/// Horizon's source at commit `revision`: GitHub's archive of it, unpacked once, with the commit in
/// `.horizon-revision` (bundles pin it). A Nightly's commit stays downloadable after the Nightly
/// is gone: its `nightly-source/…` tag keeps it (docs/release-flow.md). Links are left out:
@@ -614,10 +624,11 @@ pub fn build(
let real = plain(root().canonicalize().map_err(|e| e.to_string())?);
let fresh = real.join("stage.new");
let _ = fs::remove_dir_all(&fresh);
let mut apply = Command::new(&tool);
apply.arg("apply").arg("--workspace").arg(&source);
apply.arg("--mods").arg(&incoming).arg("--out").arg(&fresh);
run(apply, "horizon-mixins", |_| {})?;
run(
apply(&rust, &tool, &source, &incoming, &fresh),
"horizon-mixins",
|_| {},
)?;
let stage = root().join("stage");
sync(&fresh, &stage)?;
let _ = fs::remove_dir_all(&fresh);
@@ -839,6 +850,41 @@ mod tests {
);
}
#[test]
fn horizon_mixins_finds_the_launchers_cargo() {
let rust = Toolchain {
dir: PathBuf::from("/rust/1.99.1-x"),
};
let cmd = apply(
&rust,
Path::new("/tools/horizon-mixins"),
Path::new("/src"),
Path::new("/mods"),
Path::new("/out"),
);
let path = cmd
.get_envs()
.find(|(k, _)| *k == "PATH")
.and_then(|(_, v)| v)
.unwrap();
assert_eq!(
std::env::split_paths(path).next(),
Some(rust.dir.join("bin"))
);
assert_eq!(
cmd.get_args().collect::<Vec<_>>(),
[
"apply",
"--workspace",
"/src",
"--mods",
"/mods",
"--out",
"/out"
]
);
}
#[test]
fn a_folder_is_one_bundle_or_a_folder_of_them() {
let one = dir("one");