forked from veeenu/hudhook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
34 lines (27 loc) · 965 Bytes
/
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
extern crate cc;
use std::env;
use std::path::Path;
fn main() {
let root_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let target = env::var("TARGET").unwrap();
let parts = target.splitn(4, '-').collect::<Vec<_>>();
let arch = parts[0];
let sys = parts[2];
if sys != "windows" {
panic!("Platform '{sys}' not supported.");
}
let hde = match arch {
"i686" => "hde/hde32.c",
"x86_64" => "hde/hde64.c",
_ => panic!("Architecture '{arch}' not supported."),
};
let mh_src_dir = Path::new(&root_dir).join("vendor/minhook/src");
cc::Build::new()
.file(mh_src_dir.join("buffer.c"))
.file(mh_src_dir.join("hook.c"))
.file(mh_src_dir.join("trampoline.c"))
.file(mh_src_dir.join(hde))
.compile("libminhook.a");
println!("cargo:rerun-if-changed=vendor/minhook/src");
println!("cargo:rustc-link-search=native={}", env::var("OUT_DIR").unwrap());
}