Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions crates/libafl_nyx/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use std::process::Command;

use std::{env, path::PathBuf, process::Command};
fn main() {
if cfg!(target_os = "linux") && cfg!(target_arch = "x86_64") && !cfg!(doc) {
let target_dir = PathBuf::from(env::var("OUT_DIR").unwrap())
.ancestors()
.nth(3)
.unwrap()
.to_path_buf();
println!("cargo:rerun-if-changed=build.rs");
// let output = Command::new("./build_nyx_support.sh").output().expect("can't run ./build_nyx_support.sh");
let status = Command::new("./build_nyx_support.sh")
.arg(target_dir)
.status()
.expect("can't run ./build_nyx_support.sh");
if status.success() {
Expand Down
12 changes: 10 additions & 2 deletions crates/libafl_nyx/build_nyx_support.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Usage: $0 <target-directory>"
exit 1
fi

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

TARGET_DIR="$1"
mkdir -p "$TARGET_DIR"
cd "$TARGET_DIR" || exit 1

echo "================================================="
echo " Nyx build script"
echo "================================================="
Expand Down Expand Up @@ -44,8 +53,7 @@ echo "[*] Checking QEMU-Nyx ..."
if [ ! -f "QEMU-Nyx/x86_64-softmmu/qemu-system-x86_64" ]; then
cd QEMU-Nyx/ || return
# We need to copy our custom `Makefile.libxdc` after `git submodule update`, otherwise we get a git error.
sed -i "s,git submodule update libxdc$,git submodule update libxdc \&\& cp ../Makefile.libxdc ./libxdc/Makefile || exit 1," compile_qemu_nyx.sh
./compile_qemu_nyx.sh lto || exit 1
sed -i "s,git submodule update libxdc$,git submodule update libxdc \&\& cp "$SCRIPT_DIR"/Makefile.libxdc ./libxdc/Makefile || exit 1," compile_qemu_nyx.sh
cd ..
fi

Expand Down
Loading