-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.sh
executable file
·135 lines (110 loc) · 2.64 KB
/
test.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
130
131
132
133
134
135
mkdir -p ./build
cc='clang++'
flags='-std=c++14 -stdlib=libc++ -O0 -g -Wall -Wextra -ferror-limit=3'
flags_pp_header='-E'
flags_pp='-E -DSKIP_LIB'
flags_pch=''
flags_obj='-c'
flags_out='-lgc'
pg='python ./lib/myparser/myparser.py'
pg_flags='c++ -p ./lib/myparser/'
lint='cppcheck'
lint_flags='-q --std=c++11 --enable=all' # --std=c++14 --inconclusive
test_cc='clang'
test_flags='-O -foptimize-sibling-calls -g -Wall -Wextra -ferror-limit=3'
test_flags_out='-lgc -nostartfiles'
echo '======== build precompiled files ========'
echo
new=$($cc $flags_pp_header $flags include.hpp)
echo $new | diff -q - ./build/include.hpp 1> /dev/null 2> /dev/null
if [ $? -eq 0 ]
then
inc_changed=0
echo 'not changed'
echo
else
inc_changed=1
echo 'changed'
echo $cc $flags_pch $flags ./include.hpp -o ./build/include.pch
$cc $flags_pch $flags ./include.hpp -o ./build/include.pch
if [ $? -eq 0 ]
then
echo $new > ./build/include.hpp
else
echo '' > ./build/include.hpp
exit
fi
echo
fi
echo '======== generate the parser ========'
echo
echo $pg $pg_flags ./syntax.md -o ./parser_syntax.hpp
$pg $pg_flags ./syntax.md -o ./parser_syntax.hpp
if [ $? -ne 0 ]
then
exit
fi
echo
echo '======== build updated files ========'
echo
objs=''
upds=''
for file in $(ls ./*.cpp)
do
new=$($cc $flags_pp $flags $file)
echo $new | diff -q - ./build/$file 1> /dev/null 2> /dev/null
if [ $? -eq 0 -a $inc_changed -eq 0 ]
then
echo 'not changed: '$file
echo
else
echo 'changed: '$file
echo $cc $flags_obj $flags -include-pch ./build/include.pch $file -o ./build/$file.o
$cc $flags_obj $flags -include-pch ./build/include.pch $file -o ./build/$file.o
if [ $? -eq 0 ]
then
echo $new > ./build/$file
else
echo '' > ./build/$file
exit
fi
echo
upds=$(echo $upds $file)
fi
objs=$(echo $objs ./build/$file.o)
done
echo '======== lint ========'
echo
echo $lint $lint_flags $upds
$lint $lint_flags $upds
echo
echo '======== build the test ========'
echo
echo $cc $flags_out $flags $objs -o ./build/test.out
$cc $flags_out $flags $objs -o ./build/test.out
if [ $? -ne 0 ]
then
exit
fi
echo
./build/test.out
if [ $? -ne 0 ]
then
exit
fi
echo
echo '======== build the generated file ========'
echo
echo $test_cc $test_flags_out $test_flags -include lbexec.h ./build/test.gen.c -o ./build/test.gen.out
$test_cc $test_flags_out $test_flags -include lbexec.h ./build/test.gen.c -o ./build/test.gen.out
if [ $? -ne 0 ]
then
exit
fi
echo
./build/test.gen.out
if [ $? -ne 0 ]
then
exit
fi
echo