ruffle/desktop/build.rs

51 lines
1.6 KiB
Rust
Raw Normal View History

2020-07-21 03:50:53 +00:00
use std::env;
use std::error::Error;
use vergen::EmitBuilder;
2020-07-21 03:50:53 +00:00
fn main() -> Result<(), Box<dyn Error>> {
// Emit version info, and "rerun-if-changed" for relevant files, including build.rs
EmitBuilder::builder()
.build_timestamp()
.cargo_features()
.git_sha(false)
.git_commit_timestamp()
.git_commit_date()
.emit()?;
2020-07-21 03:50:53 +00:00
// Embed resource file w/ icon on windows
// To allow for cross-compilation, this must not be behind cfg(windows)!
println!("cargo:rerun-if-changed=assets/ruffle_desktop.rc");
embed_resource::compile("assets/ruffle_desktop.rc", embed_resource::NONE);
2020-07-21 03:50:53 +00:00
println!("cargo:rerun-if-env-changed=CFG_RELEASE_CHANNEL");
let channel = channel();
if channel == "nightly" || channel == "dev" {
2020-07-21 03:50:53 +00:00
println!("cargo:rustc-cfg=nightly");
}
println!("cargo:rustc-env=CFG_RELEASE_CHANNEL={channel}");
2020-07-21 03:50:53 +00:00
// Some SWFS have a large amount of recursion (particularly
// around `goto`s). Increase the stack size on Windows
// accommodate this (the default on Linux is high enough). We
// do the same thing for wasm in web/build.rs.
if std::env::var("TARGET").unwrap().contains("windows") {
if std::env::var("TARGET").unwrap().contains("msvc") {
println!("cargo:rustc-link-arg=/STACK:4000000");
2023-06-27 08:42:14 +00:00
} else {
println!("cargo:rustc-link-arg=-Xlinker");
println!("cargo:rustc-link-arg=--stack");
println!("cargo:rustc-link-arg=4000000");
}
}
Ok(())
2020-07-21 03:50:53 +00:00
}
fn channel() -> String {
if let Ok(channel) = env::var("CFG_RELEASE_CHANNEL") {
channel
} else {
"nightly".to_owned()
}
}