This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.rs
99 lines (83 loc) · 2.9 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
97
98
99
use std::{
env,
process::{exit, Command},
};
use cmake::Config;
fn main() {
// First we generate .cc and .h files from ffi.rs
if !cfg!(windows) {
println!("cargo:warning=No MacOS support yet.");
exit(0);
}
let cwd = env::current_dir().unwrap().to_string_lossy().to_string();
let tinyinst = format!("{}/TinyInst", &cwd);
println!("cargo:warning=Pulling TinyInst from github");
println!("cargo:warning=Generating Bridge files.");
// Get tinyinst from git
Command::new("cmd")
.args(&["/C", format!("{}/build.bat", &cwd).as_str()])
.status()
.unwrap();
// source
Command::new("cxxbridge")
.args(&["src/tinyinst.rs", "-o"])
.arg(&format!("{}/bridge.cc", &tinyinst))
.status()
.unwrap();
// header
Command::new("cxxbridge")
.args(&["src/tinyinst.rs", "--header", "-o"])
.arg(&format!("{}/bridge.h", &tinyinst))
.status()
.unwrap();
// cxx
Command::new("cxxbridge")
.args(&["--header", "-o"])
.arg(&format!("{}/cxx.h", &tinyinst))
.status()
.unwrap();
// shim
std::fs::copy("./src/shim.cc", "./Tinyinst/shim.cc").unwrap();
std::fs::copy("./src/shim.h", "./Tinyinst/shim.h").unwrap();
// runresult
std::fs::copy("./src/runresult.h", "./Tinyinst/runresult.h").unwrap();
// instrumentation
std::fs::copy(
"./src/instrumentation.cpp",
"./Tinyinst/instrumentation.cpp",
)
.unwrap();
std::fs::copy("./src/instrumentation.h", "./Tinyinst/instrumentation.h").unwrap();
// tinyinstinstrumentation
std::fs::copy(
"./src/tinyinstinstrumentation.cpp",
"./Tinyinst/tinyinstinstrumentation.cpp",
)
.unwrap();
std::fs::copy(
"./src/tinyinstinstrumentation.h",
"./Tinyinst/tinyinstinstrumentation.h",
)
.unwrap();
// aflcov
std::fs::copy("./src/aflcov.cpp", "./Tinyinst/aflcov.cpp").unwrap();
std::fs::copy("./src/aflcov.h", "./Tinyinst/aflcov.h").unwrap();
let dst = Config::new("TinyInst")
.generator("Visual Studio 17 2022") // make this configurable from env variable
.build_target("tinyinst")
.profile("Release") // without this, it goes into RelWithDbInfo folder??
.build();
println!("cargo:warning={}", dst.display());
println!("cargo:rustc-link-search={}\\build\\Release", dst.display()); // debug build?
println!(
"cargo:rustc-link-search={}\\build\\third_party\\obj\\wkit\\lib",
dst.display()
); //xed
println!("cargo:rustc-link-lib=static=tinyinst");
println!("cargo:rustc-link-lib=static=xed");
println!("cargo:rustc-link-lib=dylib=dbghelp");
println!("cargo:rerun-if-changed=src/");
println!("cargo:rerun-if-changed=src/tinyinst.rs");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=Tinyinst/litecov.cpp");
}