-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild.rs
More file actions
60 lines (53 loc) · 1.95 KB
/
build.rs
File metadata and controls
60 lines (53 loc) · 1.95 KB
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
51
52
53
54
55
56
57
58
59
60
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)
.manifest_required()
.unwrap();
}
#[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 major = qbuild.version().major;
if major != 5 && major != 6 {
panic!("Unsupported Qt version: {major}");
}
println!("cargo::rustc-check-cfg=cfg(qtver, values(\"5\", \"6\"))");
println!("cargo::rustc-cfg=qtver=\"{major}\"");
let sources = [
"src/runtime/qt",
"src/ui/qt/common",
"src/ui/qt/widget",
"src/ui/qt/monitor",
"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",
"src/ui/qt/list_box",
];
for s in sources {
println!("cargo:rerun-if-changed={s}.rs");
println!("cargo:rerun-if-changed={s}.cpp");
println!("cargo:rerun-if-changed={s}.hpp");
}
let inc = qbuild.include_paths();
let mut build = cxx_build::bridges(sources.map(|s| format!("{s}.rs")));
build
.std("c++17")
.files(sources.map(|s| format!("{s}.cpp")))
.includes(inc)
.cpp(true);
qbuild.cargo_link_libraries(&mut build);
build.compile("winio");
}
}