aboutsummaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs75
1 files changed, 19 insertions, 56 deletions
diff --git a/build.rs b/build.rs
index f22e64f..adc18c6 100644
--- a/build.rs
+++ b/build.rs
@@ -96,67 +96,31 @@ fn build_x64_windows_msvc() -> Result<()> {
let out_dir = out_dir();
// TODO consider actually parsing wxwidgets.props at build time instead of doing it manually
- // TODO bindgen ahead of time
- // TODO can we really get away with this to do static linking
- let wx_using_lib = true;
- if wx_using_lib {
- let dll_folder = out_dir.join("lib/vc14x_x64_dll");
- let lib_folder = out_dir.join("lib/vc14x_x64_lib");
- if dll_folder.exists() && !lib_folder.exists() {
- fs::rename(dll_folder, lib_folder)?;
- }
- }
- let libs_folder = out_dir.join(if wx_using_lib {
- "lib/vc14x_x64_lib"
- } else {
- "lib/vc14x_x64_dll"
- });
- let wx_using_dll = !wx_using_lib;
+ // TODO find a static build instead bc fuck DLLs
+ let libs_folder = out_dir.join("lib/vc14x_x64_dll");
let debug = env::var("PROFILE")? == "release";
let wx_suffix = if debug { "u" } else { "ud" };
- let mut defines = vec![
- "__WXMSW__",
- "wxMSVC_VERSION_AUTO",
- "wxMSVC_VERSION_ABI_COMPAT",
- "_UNICODE",
- ];
- if debug {
- defines.push("_DEBUG");
- }
- if wx_using_dll {
- defines.push("WXUSINGDLL");
- }
let mut include_dirs = vec![out_dir.join("include/msvc"), out_dir.join("include")];
// TODO this is only in ResourceCompile in wxwidgets.props, is that bad
include_dirs.push(libs_folder.join(format!("msw{}", wx_suffix)));
- let bindings = bindgen::Builder::default()
- .header("wrapper.hpp")
- // pain
- .clang_arg("-Wno-invalid-token-paste")
- .clang_args(defines.iter().map(|x| format!("-D{}", x)))
- // TODO don't .display()
- .clang_args(include_dirs.iter().map(|x| format!("-I{}", x.display())))
- .opaque_type("std::.*")
- // pain 2: the sequel to pain
- .blocklist_type("CharType")
- .blocklist_type("value_type")
- .blocklist_type("const_reference")
- // pain 3: the shriequel to pain
- .blocklist_type("wxBaseArray_CMPFUNC")
- .blocklist_type("wxBaseObjectArray")
- .blocklist_type("wxBaseObjectArray_base")
- .blocklist_type("pointer")
- .blocklist_type("const_pointer")
- .blocklist_type("wxBaseObjectArrayForwxDateTimeArray")
- .blocklist_type("wxBaseObjectArrayForwxIconArray")
- .blocklist_type("wxBaseObjectArrayForwxStatusBarPaneArray")
- .opaque_type("_IMAGE_TLS_DIRECTORY64")
- // that's enough pain? maybe?
- .generate()
- .map_err(|_| anyhow!("failed to generate bindings"))?;
- let out_path = out_dir.join("bindings.rs");
- bindings.write_to_file(&out_path)?;
+
+ cxx_build::bridge("src/lib.rs")
+ .file("src/wx-sys.cpp")
+ .includes(include_dirs)
+ .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",
@@ -171,7 +135,6 @@ fn build_x64_windows_msvc() -> Result<()> {
println!("cargo:rustc-link-search=native={}", libs_folder.display());
// TODO which libs do we actually want to link
- println!("cargo:rustc-link-lib=static=wxbase31{}", wx_suffix);
println!("cargo:rustc-link-lib=static=wxmsw31{}_core", wx_suffix);
Ok(())
}