This repository was archived by the owner on Jan 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.rs
More file actions
30 lines (28 loc) · 1.3 KB
/
build.rs
File metadata and controls
30 lines (28 loc) · 1.3 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
fn main() {
if let Ok(custom) = ::std::env::var("CUSTOM_LIBFUZZER_PATH") {
let custom_lib_path = ::std::path::PathBuf::from(&custom);
let custom_lib_dir = custom_lib_path.parent().unwrap().to_string_lossy();
let custom_lib_name = custom_lib_path.file_stem().unwrap().to_string_lossy();
let custom_lib_name = custom_lib_name.trim_start_matches("lib");
println!("cargo:rustc-link-search=native={}", custom_lib_dir);
println!("cargo:rustc-link-lib=static={}", custom_lib_name);
/* FIXME: this is assuming a C++ fuzzer, but should be customizable */
println!("cargo:rustc-link-lib=stdc++");
} else {
let mut build = cc::Build::new();
let sources = ::std::fs::read_dir("libfuzzer")
.expect("listable source directory")
.map(|de| de.expect("file in directory").path())
.filter(|p| p.extension().map(|ext| ext == "cpp") == Some(true))
.collect::<Vec<_>>();
for source in sources.iter() {
println!("cargo:rerun-if-changed={}", source.display());
build.file(source.to_str().unwrap());
}
build.flag("-std=c++11");
build.flag("-fno-omit-frame-pointer");
build.flag("-w");
build.cpp(true);
build.compile("libfuzzer.a");
}
}