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;
use anyhow::Result;
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=build.rs");
let target = env::var("TARGET").expect("no TARGET found");
match target.as_str() {
"x86_64-pc-windows-msvc" => build_x64_windows_msvc(),
_ => panic!("unsupported target: {}", target),
}
}
fn build_x64_windows_msvc() -> Result<()> {
let wx = vcpkg::find_package("wxwidgets").unwrap();
cxx_build::bridge("src/lib.rs")
.file("src/wx-sys.cpp")
.includes(wx.include_paths)
.flag_if_supported("-Wno-invalid-token-paste")
.define("__WXMSW__", None)
.define("wxMSVC_VERSION_AUTO", None)
.define("wxMSVC_VERSION_ABI_COMPAT", None)
.define("_UNICODE", None)
.define("WXUSINGDLL", None)
.flag_if_supported("-std=c++14")
.flag_if_supported("/std:c++14")
.compile("shit-wx-sys");
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=src/wx-sys.h");
println!("cargo:rerun-if-changed=src/wx-sys.cpp");
let win32_libs = [
"kernel32", "user32", "gdi32", "comdlg32", "winspool", "shell32", "shlwapi", "ole32",
"oleaut32", "uuid", "advapi32", "version", "comctl32", "rpcrt4", "wsock32", "wininet",
"winmm",
];
for lib in win32_libs {
// TODO dylib or static
println!("cargo:rustc-link-lib={}", lib);
}
Ok(())
}
|