-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrun.sh
executable file
·52 lines (48 loc) · 1.02 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -e
GRAPHICS=-nographic
for i in "$@"
do
case $i in
--kvm)
KVM="--enable-kvm -cpu host"
shift # past argument with no value
;;
--vga)
GRAPHICS="-vga std"
shift # past argument with no value
;;
--sanitize)
OPTION="sanitize"
shift # past argument with no value
;;
--clean)
rm -rf $BUILD_DIR/
exit 0
;;
*)
# unknown option
echo "--kvm, --vga, --sanitize, --clean"
;;
esac
done
MACHINE=machines/${1-default}
BUILD_DIR=$MACHINE/build
pushd $MACHINE
mkdir -p build
pushd build
cmake ..
make -j4 $OPTION
BINARY=$BUILD_DIR/`cat binary.txt`
popd
popd
# NOTE: if building with -march=native, make sure to enable KVM,
# as emulated qemu only supports up to SSE3 instructions
CLASS=`od -An -t x1 -j 4 -N 1 $BINARY`
if [ $CLASS == "02" ]; then
echo "Starting 64-bit kernel: $BINARY"
qemu-system-x86_64 $KVM -kernel tools/chainloader -initrd $BINARY $GRAPHICS
else
echo "Starting 32-bit kernel: $BINARY"
qemu-system-x86_64 $KVM -kernel $BINARY $GRAPHICS
fi