Fix build script deadlock in release mode
This commit is contained in:
parent
e2d9fadcc8
commit
50a6339ee4
26
build.rs
26
build.rs
@ -4,16 +4,21 @@ use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=client");
|
||||
build_client();
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let client_bin = build_client(&out_dir);
|
||||
|
||||
setup_nyx(&out_dir);
|
||||
|
||||
create_nyx_workdir(&out_dir);
|
||||
create_nyx_workdir(&out_dir, &client_bin);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
fn shell(cwd: impl AsRef<Path>, command_string: &str) {
|
||||
println!(
|
||||
"cargo:warning=Running ({}) {command_string}",
|
||||
cwd.as_ref().display()
|
||||
);
|
||||
|
||||
let cwd = cwd.as_ref();
|
||||
let mut parts = command_string.split(" ");
|
||||
let command_name = parts.next().unwrap();
|
||||
@ -34,8 +39,14 @@ fn shell(cwd: impl AsRef<Path>, command_string: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_client() {
|
||||
shell("client", "cargo build --release");
|
||||
/// Builds the client and returns the path to its binary
|
||||
fn build_client(out_dir: &str) -> String {
|
||||
// Change the target dir to avoid a cargo target dir deadlock
|
||||
shell(
|
||||
"client",
|
||||
&format!("cargo build --release --target-dir {out_dir}/client_target"),
|
||||
);
|
||||
format!("{out_dir}/client_target/release/client")
|
||||
}
|
||||
|
||||
/// Downloads and compiles qemu-nyx and packer and compiles them for the current architecture
|
||||
@ -71,13 +82,12 @@ fn setup_nyx(out_dir: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
fn create_nyx_workdir(out_dir: &str) {
|
||||
fn create_nyx_workdir(out_dir: &str, client_bin: &str) {
|
||||
// Create the directory and move required binaries to it
|
||||
let repository_root = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
shell(
|
||||
out_dir,
|
||||
&format!(
|
||||
"python3 packer/packer/nyx_packer.py {repository_root}/target/release/client build afl processor_trace --fast_reload_mode --purge"
|
||||
"python3 packer/packer/nyx_packer.py {client_bin} build afl processor_trace --fast_reload_mode --purge"
|
||||
),
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user