-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
brutal.sh
executable file
·129 lines (106 loc) · 2.17 KB
/
brutal.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
set -e
JOBS=""
SILENT="-s"
DEBUG=""
TARGET=""
export CONFIG=${CONFIG:="devel"}
export COVERAGE=""
if [[ -z "${TOOLCHAIN}" ]]; then
TOOLCHAIN="llvm"
fi
usage()
{
TOOLS="$(make list-host) "
echo "Usage: $0 [options...] [tool] [args...]"
echo ""
echo "Options:"
echo " -a, --all Make all before"
echo " -c, --clean Do a clean build"
echo " -d, --debug Run the tool inside a debuger"
echo " --doc open the doc in your prefered browser"
echo " -n, --nuke Nuke the build dir"
echo " -f, --fast Do it fast"
echo " --format Format all C and header files in sources/"
echo " -h, --help Show usage"
echo " -o, --coverage Generate code coverage"
echo " -r, --run Start the virtual machine"
echo " --resolve print the path of the tool"
echo " -v, --verbose Enable detailed logging"
echo ""
echo "Tools:"
echo " $TOOLS"
echo ""
exit 1
}
eval_arg()
{
case $1 in
"-a" | "--all")
TARGET=all
;;
"-c" | "--clean")
TARGET=clean
;;
"-d" | "--debug")
DEBUG="lldb --"
;;
"--doc")
doxygen meta/doxyfile
xdg-open bin/doxygen/index.html
;;
"-n" | "--nuke")
TARGET=nuke
;;
"-o" | "--coverage")
COVERAGE="yes"
;;
"-f" | "--fast")
JOBS="-j"
;;
"-h" | "--help")
usage
;;
"-r" | "--run")
TARGET=run
;;
"-v" | "--verbose")
SILENT=""
;;
"--format")
find sources/ -name '*.c' -o -name '*.h' -exec clang-format -i '{}' \;
;;
*)
echo "Unknown option '$1'!"
echo ""
usage
;;
esac
}
if [ -z "$1" ]; then
usage
exit 1
fi
if [ $1 == "--resolve" ]; then
PKGS=./bin/$CONFIG/$(uname -m)-host-$TOOLCHAIN
shift
echo $PKGS/$1
exit 0
fi
while [[ $1 == -* ]]; do
eval_arg $1
shift
done
if [ $# -gt 0 ]; then
TOOLS="$(make list-host) "
if [[ $TOOLS != *"$1 "* ]]; then
echo "Unknown tool '$1'!"
echo ""
usage
fi
PKGS=./bin/$CONFIG/$(uname -m)-host-$TOOLCHAIN
make $JOBS $SILENT $PKGS/$1
$DEBUG $PKGS/$@
else
make $JOBS $SILENT $TARGET
fi