
* Rust 2024 edition * gen = generalized * Fixes * more fix * More fix * even more fix * fix libfuzzer * ignore clippy lint * even more * fix docs? * more? * More pub more better * win * docs * more * More * doc stuff? * counter_maps->counters_maps * libafl qemu fixes for rust 2024 * fix? * fmt * unsafe lint * final fixes * fmt * working? * not working * unused import * win? * update libafl qemu hash * fmt * fix * unused imports * fix * fix * more foix * less edition * fix --------- Co-authored-by: Romain Malmain <romain.malmain@pm.me>
62 lines
1.6 KiB
Rust
62 lines
1.6 KiB
Rust
use std::{
|
|
env,
|
|
path::Path,
|
|
process::{Command, exit},
|
|
};
|
|
|
|
const AFL_URL: &str = "https://github.com/AFLplusplus/AFLplusplus";
|
|
|
|
fn main() {
|
|
if cfg!(windows) {
|
|
println!("cargo:warning=No support for windows yet.");
|
|
exit(0);
|
|
}
|
|
|
|
unsafe {
|
|
env::remove_var("DEBUG");
|
|
}
|
|
let cwd = env::current_dir().unwrap().to_string_lossy().to_string();
|
|
|
|
let afl = format!("{}/AFLplusplus", &cwd);
|
|
let afl_cc = format!("{}/AFLplusplus/afl-cc", &cwd);
|
|
|
|
let afl_path = Path::new(&afl);
|
|
let afl_cc_path = Path::new(&afl_cc);
|
|
|
|
if !afl_path.is_dir() {
|
|
println!("cargo:warning=AFL++ not found, downloading...");
|
|
Command::new("git")
|
|
.arg("clone")
|
|
.arg(AFL_URL)
|
|
.status()
|
|
.unwrap();
|
|
}
|
|
|
|
if !afl_cc_path.is_file() {
|
|
let mut afl_cc_make = Command::new("make");
|
|
afl_cc_make.arg("all").current_dir(afl_path);
|
|
if let Ok(llvm_config) = env::var("LLVM_CONFIG") {
|
|
if !llvm_config.is_empty() {
|
|
afl_cc_make.env("LLVM_CONFIG", llvm_config);
|
|
}
|
|
}
|
|
afl_cc_make.status().unwrap();
|
|
}
|
|
|
|
let mut compile_command = Command::new(afl_cc_path);
|
|
compile_command
|
|
.args(["src/program.c", "-o"])
|
|
.arg(format!("{cwd}/target/release/program"));
|
|
|
|
if let Ok(llvm_config) = env::var("LLVM_CONFIG") {
|
|
if !llvm_config.is_empty() {
|
|
compile_command.env("LLVM_CONFIG", llvm_config);
|
|
}
|
|
}
|
|
|
|
compile_command.status().unwrap();
|
|
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-changed=src/");
|
|
}
|