-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
45 lines (37 loc) · 1.26 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::{env, path::PathBuf, process::Command};
fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let cargo_home = PathBuf::from(env::var("CARGO_HOME").unwrap());
let target = env::var("TARGET").unwrap();
println!("cargo:rerun-if-changed=build.rs");
Command::new("git")
.args([
"clone",
"https://github.com/fltk/fltk",
"--depth=1",
])
.current_dir(&out_dir)
.status()
.ok();
let mut dst = cmake::Config::new(out_dir.join("fltk"));
dst.profile("Release")
.define("FLTK_BUILD_EXAMPLES", "OFF")
.define("FLTK_BUILD_TEST", "OFF")
.define("FLTK_BUILD_GL", "OFF")
.define("FLTK_BUILD_HTML_DOCS", "OFF")
.define("FLTK_BUILD_PDF_DOCS", "OFF");
if !target.contains("windows") && !target.contains("apple") {
dst.define("FLTK_GRAPHICS_CAIRO", "ON");
}
dst.build();
let mut inp = out_dir.join("bin/fluid");
let mut out = cargo_home.join("bin/fluid");
if target.contains("windows") {
inp.set_extension("exe");
out.set_extension("exe");
}
if !target.contains("msvc") {
Command::new("strip").arg(&inp).status().unwrap();
}
std::fs::copy(&inp, &out).unwrap();
}