-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
executable file
·307 lines (280 loc) · 6.41 KB
/
dev.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#!/bin/zsh
bstrlib=frumul/bstrlib
odir=odir
_compile_base=( -std=c++17 -Wextra -Wall -pedantic -pedantic-errors -Wsign-conversion )
_sourcefile=`readlink -f ${${(%):-%N}}`
export FRUMUL_STDLIB=${_sourcefile%/*}"/stdlib/"
print Variable environment set: '$FRUMUL_STDLIB'=$FRUMUL_STDLIB
_manage_parms () {
# modifies a parameter named NAMED_ARGS, for main parameters
# and POS_ARGS, for other parameters
# default parameters
NAMED_ARGS[compiler]="g++"
i=1
while [[ $i -le $# ]]
do
case $argv[$i] in
-c|--compiler)
((i+=1))
NAMED_ARGS[compiler]=$argv[$i]
print $NAMED_ARGS[compiler]
;;
-d|--debug)
POS_ARGS+=(-D DEBUG -g)
print DEBUG ON
;;
-f|--file)
((i+=1))
NAMED_ARGS[file]=$argv[$i]
;;
-o|--out)
((i+=1))
NAMED_ARGS[out]=$argv[$i]
;;
*)
POS_ARGS+=$argv[$i]
;;
esac
((i+=1))
done
}
compile () { # deprecated
if [[ $1 == 'clang' ]]; then
compiler=$1++
shift
else
compiler='g++'
fi
$compiler -std=c++17\
-Wextra -Wall -pedantic\
-pedantic-errors\
-Wfatal-errors\
-Wsign-conversion\
-D DEBUG\
-D CXXOPTS_USE_UNICODE\
-g\
tests/astbrowser.cpp\
tests/tests.cpp\
frumul/alias.cpp\
frumul/argcollector.cpp\
frumul/bytecode.cpp\
frumul/compiler.cpp\
frumul/exception.cpp\
frumul/fdeclaration.cpp\
frumul/fstring.cpp\
frumul/hinterpreter.cpp\
frumul/lexer.cpp\
frumul/mark.cpp\
frumul/name.cpp\
frumul/node.cpp\
frumul/parameters.cpp\
frumul/parmqueuer.cpp\
frumul/parser.cpp\
frumul/position.cpp\
frumul/retchecker.cpp\
frumul/schildren.cpp\
frumul/symbol.cpp\
frumul/symboltab.cpp\
frumul/tailresult.cpp\
frumul/textto.cpp\
frumul/transpiler.cpp\
frumul/util.cpp\
frumul/value.cpp\
frumul/vm.cpp\
frumul/vmtypes.cpp\
frumul/warning.cpp\
-o out\
$odir/token.o\
/usr/lib/gcc/x86_64-linux-gnu/6/libstdc++fs.a\
-isystem frumul/icu/usr/local/include\
-isystem frumul/cxxopts/include\
-licuuc -licudata -licuio -licui18n \
-Lfrumul/icu/usr/local/lib \
-Wl,-Rfrumul/icu/usr/local/lib\
$@
}
build_main_lib () {
typeset -A NAMED_ARGS
POS_ARGS=()
_manage_parms $@
compiler=$NAMED_ARGS[compiler]
unset "NAMED_ARGS[compiler]"
$compiler $NAMED_ARGS $_compile_base \
-Wfatal-errors \
-shared \
-o libfrumul.so\
-fPIC\
frumul/alias.cpp\
frumul/argcollector.cpp\
frumul/bytecode.cpp\
frumul/compiler.cpp\
frumul/exception.cpp\
frumul/dynloader.cpp\
frumul/fdeclaration.cpp\
frumul/fstring.cpp\
frumul/hinterpreter.cpp\
frumul/lexer.cpp\
frumul/mark.cpp\
frumul/name.cpp\
frumul/node.cpp\
frumul/parameters.cpp\
frumul/parmqueuer.cpp\
frumul/parser.cpp\
frumul/position.cpp\
frumul/retchecker.cpp\
frumul/schildren.cpp\
frumul/stackvar.cpp\
frumul/symbol.cpp\
frumul/symboltab.cpp\
frumul/tailresult.cpp\
frumul/textto.cpp\
frumul/token.cpp\
frumul/transpiler.cpp\
frumul/util.cpp\
frumul/value.cpp\
frumul/vm.cpp\
frumul/vmtypes.cpp\
frumul/warning.cpp\
tools/disassembler.cpp\
-I tools/ \
-I frumul/ \
/usr/lib/gcc/x86_64-linux-gnu/8/libstdc++fs.a\
-isystem frumul/icu/usr/local/include\
-isystem frumul/cxxopts/include\
-licuuc -licudata -licuio -licui18n \
-Lfrumul/icu/usr/local/lib \
-Wl,-Rfrumul/icu/usr/local/lib \
$POS_ARGS
}
_build_main () {
typeset -A NAMED_ARGS
POS_ARGS=()
_manage_parms $@
compiler=$NAMED_ARGS[compiler]
unset "NAMED_ARGS[compiler]"
$compiler $_compile_base \
-D CXXOPTS_USE_UNICODE\
-Wfatal-errors \
-L./ \
-Wl,-rpath=./ \
$files \
-lfrumul \
-ldl \
-o $output_file\
/usr/lib/gcc/x86_64-linux-gnu/8/libstdc++fs.a\
-isystem frumul/icu/usr/local/include\
-isystem frumul/cxxopts/include\
-isystem frumul/include \
-licuuc -licudata -licuio -licui18n \
-Lfrumul/icu/usr/local/lib \
-Wl,-Rfrumul/icu/usr/local/lib \
$POS_ARGS
}
build_main () {
files=(frumul/main.cpp frumul/cmdline.cpp)
output_file="FRUMUL"
_build_main $@
}
build_tests () {
files=(tests/astbrowser.cpp tests/tests.cpp)
output_file="out"
_build_main $@
}
build_lib () {
typeset -A NAMED_ARGS
POS_ARGS=()
_manage_parms $@
compiler=$NAMED_ARGS[compiler]
unset "NAMED_ARGS[compiler]"
input_file="frumul/stdlib/$NAMED_ARGS[file].cpp"
output_file="${FRUMUL_STDLIB}${NAMED_ARGS[file]}.hb"
print File: $input_file
$compiler $_compile_base \
-shared \
-fPIC \
-L. \
-Wl,-rpath=./ \
$input_file \
-o $output_file \
-lfrumul \
-I frumul/ \
-isystem frumul/icu/usr/local/include\
-isystem frumul/cxxopts/include\
-licuuc -licudata -licuio -licui18n \
-Lfrumul/icu/usr/local/lib \
-Wl,-Rfrumul/icu/usr/local/lib \
$POS_ARGS
}
build_functions_lib () {
typeset -A NAMED_ARGS
POS_ARGS=()
_manage_parms $@
compiler=$NAMED_ARGS[compiler]
unset "NAMED_ARGS[compiler]"
input_file="$NAMED_ARGS[file].cpp"
output_file="${NAMED_ARGS[file].out}"
print File: $input_file
$compiler $_compile_base \
-shared \
-fPIC \
-L. \
-Wl,-rpath=./ \
$input_file \
-o $output_file \
-lfrumul \
-I frumul/ \
-isystem frumul/icu/usr/local/include\
-isystem frumul/cxxopts/include\
-licuuc -licudata -licuio -licui18n \
-Lfrumul/icu/usr/local/lib \
-Wl,-Rfrumul/icu/usr/local/lib \
$POS_ARGS
}
build_plugins() {
typeset -A NAMED_ARGS
POS_ARGS=()
_manage_parms $@
compiler=$NAMED_ARGS[compiler]
unset "NAMED_ARGS[compiler]"
input_file="$NAMED_ARGS[file].cpp"
output_file="${NAMED_ARGS[out]}"
print File: $input_file
$compiler $_compile_base \
-shared \
-fPIC \
-L. \
-Wl,-rpath=./ \
$input_file \
-o $output_file \
-lfrumul \
-I frumul/ \
-isystem frumul/icu/usr/local/include\
-isystem frumul/cxxopts/include\
-licuuc -licudata -licuio -licui18n \
-Lfrumul/icu/usr/local/lib \
-Wl,-Rfrumul/icu/usr/local/lib \
$POS_ARGS
}
objectify () {
typeset -A NAMED_ARGS
POS_ARGS=()
_manage_parms $@
compiler=$NAMED_ARGS[compiler]
unset "NAMED_ARGS[compiler]"
print File: $POS_ARGS[1]
cd $odir
$compiler $NAMED_ARGS $_compile_base \
-I ../frumul \
-I ../tools \
-isystem ../frumul/icu/usr/local/include\
-isystem ../frumul/cxxopts/include\
-isystem ../frumul/include\
-D DEBUG\
-g\
-c ../$POS_ARGS[1]
popd
}
alias check_frumul="cppcheck ./frumul/ --enable=all --inconclusive --force --std=c++11 -i $bstrlib"
#alias valgrind="valgrind --leak-check=yes --leak-check=full --show-leak-kinds=all"
alias valgrind="valgrind --leak-check=yes"
alias final_test="./tests/final_tests/final_test.sh"