Refactor(build.rs): extract common code between branches (#1950)

This commit is contained in:
Stefan Zabka 2024-03-17 21:31:30 +01:00 committed by GitHub
parent 44a37da680
commit fbd0d497d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -146,7 +146,6 @@ pub fn build(
.arg("distclean") .arg("distclean")
.status(), .status(),
);*/ );*/
if is_usermode && !custom_qemu_no_configure {
let mut cmd = Command::new("./configure"); let mut cmd = Command::new("./configure");
cmd.current_dir(&qemu_path) cmd.current_dir(&qemu_path)
//.arg("--as-static-lib") //.arg("--as-static-lib")
@ -162,35 +161,19 @@ pub fn build(
qemu_path.join("linker_interceptor++.py").display() qemu_path.join("linker_interceptor++.py").display()
)) ))
.arg("--as-shared-lib") .arg("--as-shared-lib")
.arg(&format!("--target-list={cpu_target}-{target_suffix}")) .arg(&format!("--target-list={cpu_target}-{target_suffix}"));
.args([ if cfg!(feature = "debug_assertions") {
cmd.arg("--enable-debug");
}
if is_usermode && !custom_qemu_no_configure {
cmd.args([
"--disable-bsd-user", "--disable-bsd-user",
"--disable-fdt", "--disable-fdt",
"--disable-system", "--disable-system",
"--disable-capstone", "--disable-capstone",
]); ]);
if cfg!(feature = "debug_assertions") {
cmd.arg("--enable-debug");
}
cmd.status().expect("Configure failed");
} else if !custom_qemu_no_configure { } else if !custom_qemu_no_configure {
let mut cmd = Command::new("./configure"); cmd.arg(if cfg!(feature = "slirp") {
cmd.current_dir(&qemu_path)
//.arg("--as-static-lib")
.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(&format!(
"--cc={}",
qemu_path.join("linker_interceptor.py").display()
))
.arg(&format!(
"--cxx={}",
qemu_path.join("linker_interceptor++.py").display()
))
.arg("--as-shared-lib")
.arg(&format!("--target-list={cpu_target}-{target_suffix}"))
.arg(if cfg!(feature = "slirp") {
"--enable-slirp" "--enable-slirp"
} else { } else {
"--disable-slirp" "--disable-slirp"
@ -304,11 +287,9 @@ pub fn build(
.arg("--disable-xkbcommon") .arg("--disable-xkbcommon")
.arg("--disable-zstd") .arg("--disable-zstd")
.arg("--disable-tests"); .arg("--disable-tests");
if cfg!(feature = "debug_assertions") {
cmd.arg("--enable-debug");
} }
cmd.status().expect("Configure failed"); cmd.status().expect("Configure failed");
}
if let Some(j) = jobs { if let Some(j) = jobs {
Command::new("make") Command::new("make")
.current_dir(&build_dir) .current_dir(&build_dir)