-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·88 lines (77 loc) · 2.14 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·88 lines (77 loc) · 2.14 KB
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
#!/usr/bin/env bash
set -e
# Should clean?
if [[ $* == *--clean* ]]; then
rm -rf cbuild/
rm -f NeoLisp
rm -f NeoLisp-tests
rm -rf *.dSYM/
exit 0
fi
if [[ $* != *--notest* ]]; then
if ! [ -x "$(command -v cppcheck)" ]; then
printf "Install cppcheck to perform additional code quality checks.\n\n"
else
printf "Running `cppcheck --version`...\n"
# Run cppcheck:
# Note: Cppcheck sometimes generates false positives and does not support C++17 yet, so we ignore its exit code.
# We use it just to bring attention to potential bugs. Also, you can add `unusedFunction` to the list of
# checks enabled below, if the `-j 8` parallelism flag has been removed (as `j -8` disables the check).
cppcheck -j 8 --language=c++ --enable=warning,performance,portability --platform=unix64 --error-exitcode=5 src || true
printf "\n"
fi
fi
# Create build directory
mkdir -p cbuild
cd cbuild
# Generate Makefile
printf "Running cmake...\n"
cmake ..
# Get the number of CPUs
printf "\nNumber of CPUs: " -n
NUMCPUS=4
OS=`uname`
if [[ "$OS" == 'Linux' ]]; then
NUMCPUS=`grep -c '^processor' /proc/cpuinfo`
elif [[ "$OS" == 'Darwin' ]]; then
NUMCPUS=`sysctl -n hw.ncpu`
fi
printf "%s\n" "$NUMCPUS"
# Run make
echo "Compiling..."
if [[ $* != *--notest* ]]; then
make -j$NUMCPUS
else
make -j$NUMCPUS NeoLisp
fi
cd ..
# Symlink from base dir, and strip
echo "Done compiling. Stripping..."
ln -sf cbuild/NeoLisp
strip cbuild/NeoLisp
if [[ $* != *--notest* ]]; then
ln -sf cbuild/NeoLisp-tests
strip cbuild/NeoLisp-tests
fi
echo "Done."
# Run unit tests
if [[ $* != *--notest* ]]; then
TESTS=./cbuild/NeoLisp-tests
if [ -f $TESTS ]; then
printf "\nRunning unit tests...\n\n"
if ! [ -x "$(command -v valgrind)" ]; then
printf "Install Valgrind to perform memory leak checks.\n\n"
$TESTS
else
# Run valgrind
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --suppressions=.valgrind-false-positives.supp --gen-suppressions=all --error-exitcode=999 $TESTS
fi
fi
fi
# Done
if [ $? -eq 0 ]; then
printf "\nYou can run ./NeoLisp now.\n"
exit 0
else
exit $?
fi