-
Notifications
You must be signed in to change notification settings - Fork 1
/
start
executable file
·56 lines (47 loc) · 1.28 KB
/
start
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
53
54
55
56
#!/bin/sh
# --gdb Runs Haruhi in GDB.
# --valgrind Runs Haruhi in Valgrind.
o_run_in_gdb=0
o_run_in_valgrind=0
o_target=$(uname -m)
for arg in "$@"; do
case "$arg" in
"-h"|"--help")
echo "Usage ./start [options] <target>"
echo "-g --gdb Run in GDB"
echo "-v --valgrind Run in Valgrind"
echo "<target> Target profile defined in Makefile.conf (debug, core2, etc)"
exit 0
;;
"-g"|"--gdb") o_run_in_gdb=1 ;;
"-v"|"--valgrind") o_run_in_valgrind=1 ;;
*) o_target="$arg"
esac
done
if [ "$o_run_in_valgrind" = "1" ] && [ "$o_run_in_gdb" = "1" ]; then
echo "Error: -g and -v options are incompatible."
exit 1
fi
executable="src/build/$o_target/haruhi" # executable file
run="$executable" # run command (with gdb/valgrind)
corefile="core"
if [ "$o_run_in_valgrind" = "1" ]; then
run="valgrind --leak-check=full --show-reachable=yes $run"
fi
if [ "$o_run_in_gdb" = "1" ]; then
run="gdb $run -ex \"break 'Haruhi::fail'\" -ex run"
fi
echo "Will run: $run"
echo ""
ulimit -c unlimited
export MALLOC_CHECK=_2
export DIST="$o_target"
export QT_NO_GLIB=1
if nice -n 15 make -C src -j2; then
if ! sh -c "$run"; then
if [ -f "$corefile" ] && [ "$o_run_in_gdb" != "1" ]; then
echo "Core file found, running GDB."
gdb --core="$corefile" "$executable"
fi
fi
fi