forked from linebender/resvg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
64 lines (50 loc) · 1.96 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#[cfg(target_os = "linux")]
fn main() {
let mut build = cc::Build::new();
build.cpp(true);
build.flag("-std=c++11");
build.file("cpp/qt_capi.cpp").include("cpp");
let lib = pkg_config::find_library("Qt5Gui").expect("Unable to find Qt5Gui");
for path in lib.include_paths {
build.include(path.to_str().expect("Failed to convert include path to str"));
}
build.compile("libqtc.a");
}
#[cfg(target_os = "windows")]
fn main() {
let qt_dir = std::env::var("QT_DIR").expect("QT_DIR is not set");
let qt_path = std::path::Path::new(&qt_dir);
let mut build = cc::Build::new();
let tool = build.get_compiler();
build.cpp(true);
build.file("cpp/qt_capi.cpp").include("cpp");
build.include(qt_path.join("include"));
build.include(qt_path.join("include").join("QtCore"));
build.include(qt_path.join("include").join("QtGui"));
if tool.is_like_msvc() {
build.compile("libqtc.lib");
} else {
build.flag("-std=c++11");
build.compile("libqtc.a");
}
println!("cargo:rustc-link-search={}", qt_path.join("bin").display()); // for MinGW
println!("cargo:rustc-link-search={}", qt_path.join("lib").display()); // for MSVC
println!("cargo:rustc-link-lib=Qt5Core");
println!("cargo:rustc-link-lib=Qt5Gui");
}
#[cfg(target_os = "macos")]
fn main() {
let qt_dir = std::env::var("QT_DIR").expect("QT_DIR is not set");
let qt_path = std::path::Path::new(&qt_dir);
let mut build = cc::Build::new();
build.cpp(true);
build.flag("-std=c++11");
build.flag(&format!("-F{}/lib", qt_dir));
build.file("cpp/qt_capi.cpp").include("cpp");
build.include(qt_path.join("lib/QtGui.framework/Headers"));
build.include(qt_path.join("lib/QtCore.framework/Headers"));
build.compile("libqtc.a");
println!("cargo:rustc-link-search=framework={}/lib", qt_dir);
println!("cargo:rustc-link-lib=framework=QtCore");
println!("cargo:rustc-link-lib=framework=QtGui");
}