build/qemu-wrap
author Phil Ringnalda <philringnalda@gmail.com>
Wed, 28 Oct 2015 22:57:43 -0700
changeset 303546 b4c323832f317d650acd4bd7066d9432f3c1768c
parent 121379 1a53df18c076a7388496b9d78cceb855ce793735
permissions -rwxr-xr-x
Back out 8 changesets (bug 1207355) for OS X 10.10 reftest failures in generated-content/ CLOSED TREE Backed out changeset aafd6db2fbb4 (bug 1207355) Backed out changeset 9dd950b837fb (bug 1207355) Backed out changeset e941e0e106a1 (bug 1207355) Backed out changeset ecebca101fcb (bug 1207355) Backed out changeset 08f2017137e1 (bug 1207355) Backed out changeset 3dc69e37c9b4 (bug 1207355) Backed out changeset bcdf51edb121 (bug 1207355) Backed out changeset 1d4c00dbf49a (bug 1207355)

#!/bin/bash
# this script creates a wrapper shell script for an executable.  The idea is the actual executable cannot be
# executed natively (it was cross compiled), but we want to run tests natively.  Running this script
# as part of the compilation process will move the non-native executable to a new location, and replace it
# with a script that will run it under qemu.
while [[ -n $1 ]]; do
    case $1 in
        --qemu) QEMU="$2"; shift 2;;
        --libdir) LIBDIR="$2"; shift 2;;
        --ld) LD="$2"; shift 2;;
        *) exe="$1"; shift;;
    esac
done
if [[ -z $LIBDIR ]]; then
    echo "You need to specify a directory for the cross libraries when you configure the shell"
    echo "You can do this with --with-cross-lib="
    exit 1
fi
LD=${LD:-$LIBDIR/ld-linux.so.3}
mv $exe $exe.target
# Just hardcode the path to the executable.  It'll be pretty obvious if it is doing the wrong thing.

echo $'#!/bin/bash\n' $QEMU -E LD_LIBRARY_PATH="${LIBDIR}" "$LD" "$(readlink -f "$exe.target")" '"$@"' >"$exe"
chmod +x $exe