Fix cross compilation

cfg!()/env!() are applied on the host platform during the build script's
build, the environment of the build script's execution is the proper way
to determine eg target_os
This commit is contained in:
Jake Shadle 2020-03-18 20:06:55 +01:00
parent 4de7deb568
commit 9e389b9a5f

View File

@ -1,12 +1,8 @@
fn main() {
#[cfg(target_os = "windows")]
{
use cmake::Config;
let project_name = "exception_handling";
let dst = Config::new(project_name).build();
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=static={}", project_name);
if std::env::var("CARGO_CFG_TARGET_OS").expect("TARGET_OS not specified") != "windows" {
return;
}
cc::Build::new()
.include("exception_handling")
.file("exception_handling/exception_handling.c")