This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
96 lines (91 loc) · 4.01 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
extern crate bindgen;
use std::env;
use std::path::Path;
use std::path::PathBuf;
fn main() {
let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
println!(
"cargo:rustc-link-search={}",
Path::new(&dir).join("SDK/Libraries/Win").display()
);
println!("cargo:rustc-link-lib=XPLM_64");
println!("cargo:rustc-link-lib=XPWidgets_64");
// Tell cargo to invalidate the built crate whenever the wrapper changes
println!("cargo:rerun-if-changed=wrapper.h");
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
// the resulting bindings.
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header("wrapper.h")
//.clang_arg("-v")
.clang_arg(format!(
"-I{}",
Path::new(&dir).join("SDK/CHeaders/XPLM").display()
))
.clang_arg(format!(
"-I{}",
Path::new(&dir).join("SDK/CHeaders/Widgets").display()
))
.blacklist_type("LPMONITORINFOEXA?W?")
.blacklist_type("LPTOP_LEVEL_EXCEPTION_FILTER")
.blacklist_type("MONITORINFOEXA?W?")
.blacklist_type("PEXCEPTION_FILTER")
.blacklist_type("PEXCEPTION_ROUTINE")
.blacklist_type("PSLIST_HEADER")
.blacklist_type("PTOP_LEVEL_EXCEPTION_FILTER")
.blacklist_type("PVECTORED_EXCEPTION_HANDLER")
.blacklist_type("_?L?P?CONTEXT")
.blacklist_type("_?L?P?EXCEPTION_POINTERS")
.blacklist_type("_?P?DISPATCHER_CONTEXT")
.blacklist_type("_?P?EXCEPTION_REGISTRATION_RECORD")
.blacklist_type("_?P?IMAGE_TLS_DIRECTORY.*")
.blacklist_type("_?P?NT_TIB")
.blacklist_type("tagMONITORINFOEXA")
.blacklist_type("tagMONITORINFOEXW")
.blacklist_function("AddVectoredContinueHandler")
.blacklist_function("AddVectoredExceptionHandler")
.blacklist_function("CopyContext")
.blacklist_function("GetThreadContext")
.blacklist_function("GetXStateFeaturesMask")
.blacklist_function("InitializeContext")
.blacklist_function("InitializeContext2")
.blacklist_function("InitializeSListHead")
.blacklist_function("InterlockedFlushSList")
.blacklist_function("InterlockedPopEntrySList")
.blacklist_function("InterlockedPushEntrySList")
.blacklist_function("InterlockedPushListSListEx")
.blacklist_function("LocateXStateFeature")
.blacklist_function("QueryDepthSList")
.blacklist_function("RaiseFailFastException")
.blacklist_function("RtlCaptureContext")
.blacklist_function("RtlCaptureContext2")
.blacklist_function("RtlFirstEntrySList")
.blacklist_function("RtlInitializeSListHead")
.blacklist_function("RtlInterlockedFlushSList")
.blacklist_function("RtlInterlockedPopEntrySList")
.blacklist_function("RtlInterlockedPushEntrySList")
.blacklist_function("RtlInterlockedPushListSListEx")
.blacklist_function("RtlQueryDepthSList")
.blacklist_function("RtlRestoreContext")
.blacklist_function("RtlUnwindEx")
.blacklist_function("RtlVirtualUnwind")
.blacklist_function("SetThreadContext")
.blacklist_function("SetUnhandledExceptionFilter")
.blacklist_function("SetXStateFeaturesMask")
.blacklist_function("UnhandledExceptionFilter")
.blacklist_function("__C_specific_handler")
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}