Open piegamesde opened 2 years ago
My build.rs
looks something like this:
fn main() {
output_dir();
gen();
match std::env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() {
"linux" | "macos" => { /* Nothing to do here */ }
// If building *FOR* Windows
"windows" => {
generate_manifest();
generate_rc();
let mut rc = winres::WindowsResource::new();
rc.set_manifest_file(&(String::from(env!("CARGO_MANIFEST_DIR")) + "/" + MANIFEST_OUT));
rc.set_resource_file(&(String::from(env!("CARGO_MANIFEST_DIR")) + "/" + RC_OUT));
#[cfg(not(target_os = "windows"))]
{
rc.set_ar_path("x86_64-w64-mingw32-gcc-ar");
rc.set_windres_path("x86_64-w64-mingw32-windres");
}
rc.compile().unwrap()
}
_ => panic!("Target not supported"),
}
}
It works fine on Linux. If you're using Rust 1.61 or greater, you'll have to use this fork.
Cross-compilation should now work out of the box in v0.1.13 of my fork. I updated the README as well, it had some buggy instructions (target_os
is the host OS when you compile build.rs
).
Hi, what's the current state of cross compilation from Windows? The README says:
What actions would be necessary to get this to work on Linux? If this is not easily possible, can at least some safeguards please be added?