Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions libafl_qemu/libafl_qemu_build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,38 @@ pub fn build(
if !qemu_path.is_dir() {
println!("cargo:warning=Qemu not found, cloning with git ({QEMU_REVISION})...");
fs::create_dir_all(&qemu_path).unwrap();
Command::new("git")
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("init")
.status()
.unwrap();
Command::new("git")
.unwrap()
.success());
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("remote")
.arg("add")
.arg("origin")
.arg(QEMU_URL)
.status()
.unwrap();
Command::new("git")
.unwrap()
.success());
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("fetch")
.arg("--depth")
.arg("1")
.arg("origin")
.arg(QEMU_REVISION)
.status()
.unwrap();
Command::new("git")
.unwrap()
.success());
assert!(Command::new("git")
.current_dir(&qemu_path)
.arg("checkout")
.arg("FETCH_HEAD")
.status()
.unwrap();
.unwrap()
.success());
fs::write(&qemu_rev, QEMU_REVISION).unwrap();
}

Expand Down Expand Up @@ -290,22 +294,24 @@ pub fn build(
.arg("--disable-tests");
}

cmd.status().expect("Configure failed");
assert!(
cmd.status().expect("Invoking Configure failed").success(),
"Configure didn't finish successfully"
);
let mut cmd = Command::new("make");
cmd.current_dir(&build_dir)
.env("__LIBAFL_QEMU_BUILD_OUT", build_dir.join("linkinfo.json"))
.env("__LIBAFL_QEMU_BUILD_CC", cc_compiler.path())
.env("__LIBAFL_QEMU_BUILD_CXX", cpp_compiler.path())
.arg("-j");

if let Some(j) = jobs {
Command::new("make")
.current_dir(&build_dir)
.arg("-j")
.arg(&format!("{j}"))
.env("V", "1")
.status()
.expect("Make failed");
} else {
Command::new("make")
.current_dir(&build_dir)
.arg("-j")
.status()
.expect("Make failed");
cmd.arg(&format!("{j}")).env("V", "1");
}
assert!(
cmd.status().expect("Invoking Make Failed").success(),
"Make didn't finish successfully"
);
}

/*
Expand Down