-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·76 lines (52 loc) · 1.19 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
_cmd_list=$(echo $* | tr ' ' '\n')
_run_gdb=0
_run_tests=0
_should_run=1
_input=""
for _cmd in $_cmd_list
do
case $_cmd in
-d|-debug)
let _run_gdb=1
;;
-t|-test)
let _run_tests=1
;;
-h|-help)
echo "Usage: $0 [OPTION]..."
echo "Run the program or the unit-tests."
echo -e "Example: $0 -d\n"
echo "Optional arguments:"
echo -e " -d, -debug\tRun the program through the GDB debugger."
echo -e " -t, -test\tRun the unit-tests."
echo -e " -h, -help\tDisplay this help and exit."
echo -e "\nReport bugs to: [email protected]"
let _should_run=0
break
;;
-i|-input)
for last; do true; done
_input=$last
break
;;
*)
echo "$0: invalid option -- '$_cmd'"
echo -e "Try '$0 -h' for more information."
let _should_run=0
break
;;
esac
done
if [ $_should_run == 1 ]; then
_path="."
if [ $_run_tests == 1 ]; then
_path="tests"
fi
_bin_name=$(cat $_path/CMakeLists.txt | grep add_executable | cut -d' ' -f1 | cut -d'(' -f2)
if [ $_run_gdb == 1 ]; then
gdb -tui -x .gdb-args --args build/bin/$_bin_name
else
./build/bin/$_bin_name $last
fi
fi