forked from 00vareladavid/scheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool
executable file
·51 lines (43 loc) · 826 Bytes
/
tool
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
#!/usr/bin/env dash
c_file="src/main.c"
x_file="scheme"
err_file="err.ascii"
memcheck() {
valgrind --tool=memcheck \
--leak-check=yes \
--show-reachable=yes \
--num-callers=20 \
--track-fds=yes \
--track-origins=yes \
--log-file=memlog.txt \
"./${x_file}"
}
build () {
echo "Building"
cd src
nix-shell -p gcc binutils gnumake --run "make scheme"
echo "Finishing"
cd ..
}
run () {
if build; then
memcheck
less memlog.txt
else
less -r "$err_file"
fi
}
format () {
clang-format -style=Chromium "$c_file" > temp.c
[ 0 = "$?" ] && mv temp.c "$c_file"
}
usage () {
echo "usage: ./tool [build|memcheck|format]"
}
case "$@" in
memcheck) memcheck;;
build) build;;
format) format;;
run) run;;
*) usage;;
esac