-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·133 lines (117 loc) · 3.28 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·133 lines (117 loc) · 3.28 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
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
130
131
132
133
#!/bin/sh
# Build script for QUO project.
# Run `./build.sh` to see the options.
set -e
# ---------- UTIL FUNCTIONS ---------- #
cmd() { echo "$@";"$@"; }
# ---------- COMMANDS FUNCTIONS ---------- #
# Build QUO CLI
# Options:
# release
# debug
# sanitize
# gperf
build() {
mkdir -p build
CFLAGS="-Wall -Wextra"
LDFLAGS="-l:libffi.a -lcurl -lm"
case $1 in
release) CFLAGS="$CFLAGS -O3 -DNDEBUG" ;;
debug) CFLAGS="$CFLAGS -DQUO_DEBUG -g" ;;
sanitize) CFLAGS="$CFLAGS -fsanitize=address" ;;
gperf) CFLAGS="$CFLAGS -pg -O2" ;;
esac
cmd gcc $CFLAGS -o build/quo cli/*.c $LDFLAGS
}
run() {
build
cmd ./build/quo test.quo
}
# Run QUO in the GDB
gdb() {
build debug
cmd gdb -ex run -ex bt -ex quit --args ./build/quo test.quo
}
# Run the QUO test suite in the `tests` directory
test() {
build
cd tests
for f in $(ls); do
name=$(basename "$f")
printf "Test: %-20s " $name
../build/quo $name
if [ $? -eq 0 ]
then printf "\033[32mPASS\033[0m\n"
else printf "\033[31mFAIL\033[0m\n"; exit 1
fi
done
}
# Print statistics of quo.h
stats() {
echo "quo.h: $(cat include/quo.h | wc -l) lines"
echo "quo-mod-*.h: $(cat include/quo-mod-*.h | wc -l) lines"
}
dist() {
echo "Creating distribution"
build release
tar -czvf build/quo-$(git describe --tags --abbrev=0)-linux.tar.gz -C build quo -C .. include
echo "Done"
}
tag() {
echo "=== Manage git tags ==="
printf "Select option Create(c), Delete(d): "
read option
case $option in
c|C)
echo "Create new tag"
echo "Latest tag: $(git describe --tags --abbrev=0)"
printf "Enter new version (e.g 0.0.0): "
read tag
git tag -a $tag -m "Release $tag"
git push origin $tag
;;
d|D)
echo "Deleting tag"
echo "Latest tag: $(git describe --tags)"
echo "Enter tag to delete: "
read tag
git tag -d $tag
git push origin --delete $tag
;;
*)
echo "Invalid option"
exit 1
;;
esac
}
clean() { rm -rf build; }
usage() {
echo "Usage: $0 [option]"
echo "Options:"
echo " build [options...] Build the QUO cli (default)"
echo " Options:"
echo " release Optimized build"
echo " debug Enable debug logs"
echo " sanitize Enable address sanitizer"
echo " gperf Enable GProf build"
echo " run Run the QUO cli on test.quo"
echo " dist Create distribution archive"
echo " tag Manage git tags"
echo " gdb Debug the QUO cli on test.quo"
echo " test Run the QUO test suite"
echo " stats Print statistics of quo.h"
echo " clean Clean up build artifacts"
exit 1
}
# ---------- ARGUMENTS PARSING ---------- #
case ${1-} in
build) shift ; build "$@" ;;
run) run ;;
tag) tag ;;
gdb) gdb ;;
dist) dist ;;
test) test ;;
stats) stats ;;
clean) clean ;;
*) usage ;;
esac