2015-11-23 04:55:38 +11:00
|
|
|
use std::env;
|
2018-05-19 05:58:55 +10:00
|
|
|
extern crate cc;
|
2015-11-23 04:55:38 +11:00
|
|
|
|
2022-04-03 02:00:48 +11:00
|
|
|
//cargo build --target=wasm32-unknown-unknown --verbose --no-default-features --features web
|
|
|
|
|
2015-11-23 04:55:38 +11:00
|
|
|
fn main() {
|
2022-04-03 02:00:48 +11:00
|
|
|
/*
|
|
|
|
println!("Environment configuration:");
|
|
|
|
for (key, value) in env::vars() {
|
|
|
|
if key.starts_with("CARGO_CFG_") {
|
|
|
|
println!("{}: {:?}", key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
println!("OS: {:?}", env::var("OS").unwrap_or("".to_string()));
|
|
|
|
println!("FAMILY: {:?}", env::var("FAMILY").unwrap_or("".to_string()));
|
|
|
|
println!("ARCH: {:?}", env::var("ARCH").unwrap_or("".to_string()));
|
|
|
|
println!("TARGET: {:?}", env::var("TARGET").unwrap_or("".to_string()));
|
|
|
|
*/
|
|
|
|
// target_arch is not working? OS FAMILY and ARCH variables were empty too
|
|
|
|
// I think the cross-compilation is broken. We could take these from the environment,
|
|
|
|
// since the build script seems to have a different target_arch than the destination.
|
|
|
|
let target = env::var("TARGET").unwrap_or("".to_string());
|
|
|
|
if target != "wasm32-unknown-unknown"
|
|
|
|
&& cfg!(not(any(
|
|
|
|
target_os = "macos",
|
|
|
|
target_os = "windows",
|
|
|
|
target_os = "redox",
|
|
|
|
target_arch = "wasm32", // this is ignored. Why?
|
|
|
|
)))
|
|
|
|
&& cfg!(not(any(feature = "wayland", feature = "x11")))
|
2020-04-05 14:49:25 +10:00
|
|
|
{
|
|
|
|
panic!("At least one of the x11 or wayland features must be enabled");
|
|
|
|
}
|
|
|
|
|
2015-11-23 04:55:38 +11:00
|
|
|
let env = env::var("TARGET").unwrap();
|
|
|
|
if env.contains("darwin") {
|
2018-05-19 05:58:55 +10:00
|
|
|
cc::Build::new()
|
2018-10-24 05:51:50 +11:00
|
|
|
.flag("-mmacosx-version-min=10.10")
|
2018-05-19 05:58:55 +10:00
|
|
|
.file("src/native/macosx/MacMiniFB.m")
|
|
|
|
.file("src/native/macosx/OSXWindow.m")
|
|
|
|
.file("src/native/macosx/OSXWindowFrameView.m")
|
|
|
|
.compile("libminifb_native.a");
|
2018-10-24 05:51:50 +11:00
|
|
|
println!("cargo:rustc-link-lib=framework=Metal");
|
|
|
|
println!("cargo:rustc-link-lib=framework=MetalKit");
|
2022-04-03 02:00:48 +11:00
|
|
|
} else if !env.contains("windows") && !env.contains("wasm32") {
|
2019-12-16 18:24:48 +11:00
|
|
|
// build scalar on non-windows and non-mac
|
|
|
|
cc::Build::new()
|
2020-07-09 18:21:18 +10:00
|
|
|
.file("src/native/posix/scalar.cpp")
|
2019-12-16 18:24:48 +11:00
|
|
|
.opt_level(3) // always build with opts for scaler so it's fast in debug also
|
|
|
|
.compile("libscalar.a")
|
2015-11-23 04:55:38 +11:00
|
|
|
}
|
|
|
|
}
|