Skip to content

Commit 289af2b

Browse files
committed
build libafl_nyx in target
1 parent cd402f7 commit 289af2b

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

crates/libafl_nyx/build.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
use std::process::Command;
2-
1+
use std::{env, path::PathBuf, process::Command};
32
fn main() {
43
if cfg!(target_os = "linux") && cfg!(target_arch = "x86_64") && !cfg!(doc) {
4+
let target_dir = PathBuf::from(env::var("OUT_DIR").unwrap())
5+
.ancestors()
6+
.nth(3)
7+
.unwrap()
8+
.to_path_buf();
59
println!("cargo:rerun-if-changed=build.rs");
610
// let output = Command::new("./build_nyx_support.sh").output().expect("can't run ./build_nyx_support.sh");
711
let status = Command::new("./build_nyx_support.sh")
12+
.arg(target_dir)
813
.status()
914
.expect("can't run ./build_nyx_support.sh");
1015
if status.success() {

crates/libafl_nyx/build_nyx_support.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#!/bin/bash
22

3+
if [ -z "$1" ]; then
4+
echo "Usage: $0 <target-directory>"
5+
exit 1
6+
fi
7+
38
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
49

10+
TARGET_DIR="$1"
11+
mkdir -p "$TARGET_DIR"
12+
cd "$TARGET_DIR" || exit 1
13+
514
echo "================================================="
615
echo " Nyx build script"
716
echo "================================================="
@@ -44,8 +53,7 @@ echo "[*] Checking QEMU-Nyx ..."
4453
if [ ! -f "QEMU-Nyx/x86_64-softmmu/qemu-system-x86_64" ]; then
4554
cd QEMU-Nyx/ || return
4655
# We need to copy our custom `Makefile.libxdc` after `git submodule update`, otherwise we get a git error.
47-
sed -i "s,git submodule update libxdc$,git submodule update libxdc \&\& cp ../Makefile.libxdc ./libxdc/Makefile || exit 1," compile_qemu_nyx.sh
48-
./compile_qemu_nyx.sh lto || exit 1
56+
sed -i "s,git submodule update libxdc$,git submodule update libxdc \&\& cp "$SCRIPT_DIR"/Makefile.libxdc ./libxdc/Makefile || exit 1," compile_qemu_nyx.sh
4957
cd ..
5058
fi
5159

0 commit comments

Comments
 (0)