Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build AFL in a temporary directory in OUT_DIR #254

Merged
merged 1 commit into from Sep 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 11 additions & 13 deletions build.rs
Expand Up @@ -15,16 +15,14 @@ mod common;

fn main() {
let (work_dir, base) = if env::var("DOCS_RS").is_ok() {
let tempdir = tempfile::tempdir().unwrap();
let status = Command::new("git")
let out_dir = env::var("OUT_DIR").unwrap();
let tempdir = tempfile::tempdir_in(&out_dir).unwrap();
let output = Command::new("git")
.args(["clone", AFL_SRC_PATH, &*tempdir.path().to_string_lossy()])
.status()
.output()
.expect("could not run 'git'");
assert!(status.success());
(
tempdir.into_path(),
Some(PathBuf::from(env::var("OUT_DIR").unwrap())),
)
assert!(output.status.success(), "{:#?}", output);
(tempdir.into_path(), Some(PathBuf::from(out_dir)))
} else {
(PathBuf::from(AFL_SRC_PATH), None)
};
Expand All @@ -46,8 +44,8 @@ fn build_afl(work_dir: &Path, base: Option<&Path>) {
if std::env::var("DEBUG").as_deref() == Ok("false") {
command.env_remove("DEBUG");
}
let status = command.status().expect("could not run 'make'");
assert!(status.success());
let output = command.output().expect("could not run 'make'");
assert!(output.status.success(), "{:#?}", output);
}

fn build_afl_llvm_runtime(work_dir: &Path, base: Option<&Path>) {
Expand All @@ -57,11 +55,11 @@ fn build_afl_llvm_runtime(work_dir: &Path, base: Option<&Path>) {
)
.expect("Couldn't copy object file");

let status = Command::new(AR_CMD)
let output = Command::new(AR_CMD)
.arg("r")
.arg(common::archive_file_path(base))
.arg(common::object_file_path(base))
.status()
.output()
.expect("could not run 'ar'");
assert!(status.success());
assert!(output.status.success(), "{:#?}", output);
}