-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
61 lines (61 loc) · 1.91 KB
/
build.rs
File metadata and controls
61 lines (61 loc) · 1.91 KB
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
use build_target::Arch;
use build_target::Os;
use cc::Build;
use std::env;
use std::path::Path;
use std::process::Command;
fn main() {
if Os::target().unwrap() == Os::Windows {
let output_dir = env::var("OUT_DIR").unwrap();
Command::new("midl")
.arg("/server")
.arg("none")
.arg("/prefix")
.arg("all")
.arg("nvdaController_")
.arg(match Arch::target().unwrap() {
Arch::X86_64 => "/x64",
Arch::AARCH64 => "/arm64",
_ => panic!("Unsupported CPU archetecture"),
})
.arg("/out")
.arg(&output_dir)
.arg("/acf")
.arg("nvda_controller\\nvdaController.acf")
.arg("nvda_controller\\nvdaController.idl")
.status()
.unwrap();
Build::new()
.file(Path::new(&output_dir).join("nvdaController_c.c"))
.file(Path::new("nvda_controller").join("winIPCUtils.cpp"))
.file(Path::new("nvda_controller").join("client.cpp"))
.cpp(true)
.compile("nvda_controller");
println!("cargo::rustc-link-search=native={}", output_dir);
println!("cargo::rustc-link-lib=static=nvda_controller");
println!("cargo::rustc-link-lib=rpcrt4");
let nvda_bindings = bindgen::Builder::default()
.header(
Path::new("nvda_controller")
.join("nvdaController.h")
.display()
.to_string(),
)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.allowlist_function("nvdaController_.+")
.prepend_enum_name(false)
.must_use_type("error_status_t")
.generate()
.unwrap();
nvda_bindings
.write_to_file(Path::new(&output_dir).join("nvda_bindings.rs"))
.unwrap();
}
// let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
// cbindgen::Builder::new()
// .with_crate(&crate_dir)
// .with_config(cbindgen::Config::from_root_or_default(&crate_dir))
// .generate()
// .unwrap()
// .write_to_file("whisprs.h");
}