forked from Whitecat18/Rust-for-Malware-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
28 lines (25 loc) · 998 Bytes
/
build.rs
File metadata and controls
28 lines (25 loc) · 998 Bytes
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
use std::env;
fn main() {
let target = env::var("TARGET").expect("Missing TARGET environment variable");
if !target.contains("x86_64") {
panic!("This build script only supports x86_64 targets.");
}
if target.contains("msvc") {
cc::Build::new()
.file("src/trampolin_msvc.asm")
.compile("recycledgate");
} else if target.contains("gnu") {
let sources = ["src/trampolin_nasm.asm"];
if let Err(e) = nasm_rs::compile_library("recycledgate", &sources) {
panic!("Failed to compile with NASM [recycledgate]: {}", e);
}
for source in &sources {
println!("cargo:rerun-if-changed={}", source);
}
let out_dir = env::var("OUT_DIR").expect("Missing OUT_DIR environment variable");
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=recycledgate");
} else {
panic!("Unsupported target: {}", target);
}
}