|
1 | 1 | extern crate gcc;
|
2 | 2 |
|
3 | 3 | fn main() {
|
4 |
| - let sources = ::std::fs::read_dir("llvm/lib/Fuzzer") |
5 |
| - .expect("listable source directory") |
6 |
| - .map(|de| de.expect("file in directory").path()) |
7 |
| - .filter(|p| p.extension().map(|ext| ext == "cpp") == Some(true)) |
8 |
| - .collect::<Vec<_>>(); |
9 |
| - let mut config = gcc::Config::new(); |
10 |
| - for source in sources.iter() { |
11 |
| - config.file(source.to_str().unwrap()); |
| 4 | + if let Ok(custom) = ::std::env::var("CUSTOM_LIBFUZZER_PATH") { |
| 5 | + let custom_lib_dir = ::std::path::PathBuf::from(&custom); |
| 6 | + let custom_lib_dir = custom_lib_dir.parent().unwrap().to_string_lossy(); |
| 7 | + |
| 8 | + let custom_lib_name = ::std::path::PathBuf::from(&custom); |
| 9 | + let custom_lib_name = custom_lib_name.file_stem().unwrap().to_string_lossy(); |
| 10 | + let custom_lib_name = &custom_lib_name[3..]; |
| 11 | + |
| 12 | + println!("cargo:rustc-link-search=native={}", custom_lib_dir); |
| 13 | + println!("cargo:rustc-link-lib=static={}", custom_lib_name); |
| 14 | + println!("cargo:rustc-link-lib=stdc++"); |
| 15 | + } else { |
| 16 | + let mut config = gcc::Config::new(); |
| 17 | + let sources = ::std::fs::read_dir("llvm/lib/Fuzzer") |
| 18 | + .expect("listable source directory") |
| 19 | + .map(|de| de.expect("file in directory").path()) |
| 20 | + .filter(|p| p.extension().map(|ext| ext == "cpp") == Some(true)) |
| 21 | + .collect::<Vec<_>>(); |
| 22 | + for source in sources.iter() { |
| 23 | + config.file(source.to_str().unwrap()); |
| 24 | + } |
| 25 | + config.flag("-std=c++11"); |
| 26 | + config.flag("-fno-omit-frame-pointer"); |
| 27 | + config.cpp(true); |
| 28 | + config.compile("libfuzzer.a"); |
12 | 29 | }
|
13 |
| - config.flag("-std=c++11"); |
14 |
| - config.flag("-fno-omit-frame-pointer"); |
15 |
| - config.cpp(true); |
16 |
| - config.compile("libfuzzer.a"); |
17 | 30 | }
|
0 commit comments