-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.rs
44 lines (35 loc) · 1.12 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
extern crate cc;
extern crate pkg_config;
use std::env;
fn main() {
let mut build = cc::Build::new();
build.flag_if_supported("-std=c11");
build.file("library/webview.c");
if env::var("DEBUG").is_err() {
build.define("NDEBUG", None);
} else {
build.define("DEBUG", None);
}
let target = env::var("TARGET").unwrap();
if target.contains("windows") {
build.define("WEBVIEW_WINAPI", None);
} else if target.contains("linux") || target.contains("bsd") {
let webkit = pkg_config::Config::new()
.atleast_version("2.8")
.probe("webkit2gtk-4.0")
.unwrap();
for path in webkit.include_paths {
build.include(path);
}
build.define("WEBVIEW_GTK", None);
} else if target.contains("apple") {
println!("cargo:rustc-link-lib=framework=Cocoa");
println!("cargo:rustc-link-lib=framework=WebKit");
build.define("WEBVIEW_COCOA", None);
build.flag("-x");
build.flag("objective-c");
} else {
panic!("unsupported target");
}
build.compile("libwebview.a");
}