-
Notifications
You must be signed in to change notification settings - Fork 2
/
compile
36 lines (34 loc) · 1.19 KB
/
compile
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
#!/bin/sh
set -e
set -u
# Extract our directory from $0:
base_dir="${0%/*}"
if ! test -d "${base_dir}" ; then
printf 'Cannot determine base_dir from $0=%s\n' "$0" 1>&2
exit 1
fi
# Always start our build from the top-level:
cd "${base_dir}"
if test -e build ; then
rm -rf build
fi
export CC=clang
export CXX=clang++
cmake -S . -B build
if false ; then
exec cmake --build build
else
# If cmake is building Makefiles, this is an alternative way which
# compiles all source files in parallel (adjust -j16 to your system),
# and count of the total numbers of unique warnings and errors.
cd build
make -k -j16 --output-sync=target 2> make_err.txt && st="$?" || st="$?"
# Show a scoreboard of unique warnings & errors:
#grep -E '\<(warning|error):' make_err.txt | sort | uniq -c | sort -n || true
# Show a scoreboard of warnings & errors summed up over all files:
grep -E '\<(warning|error):' make_err.txt | sed -E -s 's/^.*(\<(warning|error):.*$)/\1/' | sort | uniq -c | sort -n || true
# And print the total counts of errors and warnings:
grep -E '\<(warning|error):' make_err.txt | sed -E -s 's/^.*\<(warning|error):.*/\1/' | sort | uniq -c || true
# Now provide make's exit status:
exit "${st}"
fi