-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
50 lines (44 loc) · 1.64 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
46
47
48
49
50
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let target_os = std::env::var("CARGO_CFG_TARGET_OS");
if target_os.as_deref() == Ok("windows") {
println!("cargo:rerun-if-changed=app.manifest");
println!("cargo:rerun-if-changed=manifest.rc");
embed_resource::compile("manifest.rc", embed_resource::NONE);
}
#[cfg(feature = "qt")]
if target_os.as_deref() != Ok("windows") && target_os.as_deref() != Ok("macos") {
let qbuild =
qt_build_utils::QtBuild::new(vec!["Core".into(), "Gui".into(), "Widgets".into()])
.unwrap();
let sources = [
"src/runtime/qt",
"src/ui/qt/widget",
"src/ui/qt/msgbox",
"src/ui/qt/filebox",
"src/ui/qt/window",
"src/ui/qt/button",
"src/ui/qt/canvas",
"src/ui/qt/edit",
"src/ui/qt/label",
"src/ui/qt/progress",
"src/ui/qt/combo_box",
];
for s in sources {
println!("cargo:rerun-if-changed={}.rs", s);
println!("cargo:rerun-if-changed={}.cpp", s);
println!("cargo:rerun-if-changed={}.hpp", s);
}
let inc = qbuild.include_paths();
let mut build = cxx_build::bridges(sources.map(|s| format!("{}.rs", s)));
build
.std("c++17")
.files(sources.map(|s| format!("{}.cpp", s)))
.includes(inc);
if std::env::var("PROFILE").as_deref() == Ok("release") {
build.flag("-flto").compiler("clang++");
}
qbuild.cargo_link_libraries(&mut build);
build.compile("winio");
}
}