Skip to content

Commit

Permalink
Make Platform detection work with cross compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
RinLovesYou committed Nov 21, 2023
1 parent ef7ec6a commit bdf810c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Rust/MelonProxy/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#[cfg(windows)]
use std::env;

fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS");

match target_os.as_ref().map(|x| &**x) {
Ok("linux") | Ok("android") => {},
Ok("freebsd") | Ok("dragonfly") => {},
Ok("openbsd") | Ok("bitrig") | Ok("netbsd") | Ok("macos") | Ok("ios") => {}

Ok("windows") => link_exports(),

tos => panic!("unknown target os {:?}!", tos)
}
}

fn link_exports() {
println!("cargo:warning=Linking Exports File..");
use std::path::Path;
let lib_path = Path::new("deps").join("Exports.def");
Expand All @@ -8,9 +23,4 @@ fn main() {
"cargo:rustc-cdylib-link-arg=/DEF:{}",
absolute_path.display()
);
}

#[cfg(not(windows))]
fn main() {

}

0 comments on commit bdf810c

Please sign in to comment.