v / ci / linux_ci.vsh
470 lines · 399 sloc · 16.98 KB · 80fd66f7f832317310c8a770eed2cad73265bda7
Raw
1import common { Task, exec }
2import os
3
4// Shared tasks/helpers
5fn all_code_is_formatted() {
6 if common.is_github_job {
7 exec('v -silent test-cleancode')
8 } else {
9 exec('v -progress test-cleancode')
10 }
11}
12
13fn verify_v_test_works() {
14 exec('echo \$VFLAGS')
15 exec('v cmd/tools/test_if_v_test_system_works.v')
16 exec('./cmd/tools/test_if_v_test_system_works')
17}
18
19fn test_pure_v_math_module() {
20 exec('v -exclude @vlib/math/*.c.v test vlib/math/')
21}
22
23fn self_tests() {
24 if common.is_github_job {
25 exec('v -W -silent test-self vlib')
26 } else {
27 exec('v -progress test-self vlib')
28 }
29}
30
31fn build_examples() {
32 if common.is_github_job {
33 exec('v -W build-examples')
34 } else {
35 exec('v -progress build-examples')
36 }
37}
38
39fn v_doctor() {
40 exec('v doctor')
41}
42
43fn build_v_with_prealloc() {
44 exec('v -cg -cstrict -o vstrict1 cmd/v')
45 // -prealloc uses _Thread_local for g_memory_block; bundled tcc does not support it.
46 prealloc_cc_flag := if os.getenv('VFLAGS').contains('-cc tcc') { ' -cc cc' } else { '' }
47 exec('./vstrict1${prealloc_cc_flag} -o vprealloc -prealloc cmd/v')
48 exec('./vprealloc run examples/hello_world.v')
49 exec('./vprealloc -o v3 cmd/v')
50 exec('./v3 -o v4 cmd/v')
51 exec('./v4 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v')
52}
53
54// TCC job tasks
55fn install_dependencies_for_examples_and_tools_tcc() {
56 if common.is_github_job {
57 exec('.github/workflows/disable_azure_mirror.sh')
58 }
59 exec('v retry -- sudo apt update')
60 exec('v retry -- sudo apt install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind')
61 exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev')
62 // Wayland development libraries for sokol Wayland support
63 exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev')
64 // The following is needed for examples/wkhtmltopdf.v
65 exec('v retry -- sudo apt install --quiet -y xfonts-75dpi xfonts-base expect')
66 exec('v retry -- wget --quiet https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb')
67 exec('v retry -- sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb')
68}
69
70fn test_v_to_c_tcc() {
71 exec('thirdparty/tcc/tcc.exe -version')
72 exec('v -cg -o vtcc cmd/v') // ensure vtcc can build itself twice
73}
74
75fn v_self_compilation_tcc() {
76 exec('v -o v2 cmd/v')
77 exec('./v2 -o v3 cmd/v')
78 exec('./v3 -o v4 cmd/v')
79}
80
81fn v_doctor_tcc() {
82 v_doctor()
83}
84
85fn verify_v_test_works_tcc() {
86 verify_v_test_works()
87}
88
89fn test_pure_v_math_module_tcc() {
90 test_pure_v_math_module()
91}
92
93fn self_tests_tcc() {
94 exec('v -keepc -cc tcc -g self')
95 self_tests()
96}
97
98fn build_examples_tcc() {
99 build_examples()
100}
101
102fn run_submodule_example_tcc() {
103 exec('v -W run examples/submodule')
104}
105
106fn build_tools_tcc() {
107 if common.is_github_job {
108 exec('v -N -W build-tools')
109 } else {
110 exec('v -progress -N -W build-tools')
111 }
112}
113
114fn build_vbinaries_tcc() {
115 exec('v -N -W build-vbinaries')
116}
117
118fn build_benches_tcc() {
119 exec('v should-compile-all vlib/v/tests/bench/')
120}
121
122fn run_vsh_script_tcc() {
123 exec('v run examples/v_script.vsh')
124}
125
126fn test_v_tutorials_tcc() {
127 exec('v tutorials/building_a_simple_web_blog_with_veb/code/blog')
128}
129
130fn build_fast_tcc() {
131 exec('cd cmd/tools/fast && v fast.v')
132 exec('cd cmd/tools/fast && ./fast')
133}
134
135fn v_self_compilation_usecache_tcc() {
136 $if !enable_usecache_test ? {
137 eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
138 return
139 }
140 exec('v wipe-cache')
141 exec('v -usecache examples/hello_world.v')
142 exec('./examples/hello_world')
143
144 exec('v wipe-cache')
145 exec('v -o v2 -usecache cmd/v')
146 exec('./v2 -o v3 -usecache cmd/v')
147 exec('./v3 version')
148
149 exec('v wipe-cache')
150 exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
151 exec('rm -f ./examples/hello_world v2 v3 tetris')
152}
153
154fn test_password_input_tcc() {
155 exec('v test examples/password/')
156}
157
158fn test_readline_tcc() {
159 exec('v test examples/readline/')
160}
161
162fn test_leak_detector_tcc() {
163 exec('v -gc boehm_leak -o testcase_leak vlib/v/tests/testcase_leak.vv')
164 exec('./testcase_leak 2>leaks.txt')
165 exec('grep "Found 1 leaked object" leaks.txt')
166 exec('grep -P ", sz=\\s?1000," leaks.txt')
167}
168
169fn test_leak_detector_not_active_tcc() {
170 exec('v -o testcase_leak vlib/v/tests/testcase_leak.vv')
171 exec('./testcase_leak 2>leaks.txt')
172 exec('[ "$(stat -c %s leaks.txt)" = "0" ]')
173}
174
175// GCC job tasks
176fn all_code_is_formatted_gcc() {
177 all_code_is_formatted()
178}
179
180fn install_dependencies_for_examples_and_tools_gcc() {
181 if common.is_github_job {
182 exec('.github/workflows/disable_azure_mirror.sh')
183 }
184 exec('v retry -- sudo apt update')
185 exec('v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind')
186 exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
187 // Wayland development libraries for sokol Wayland support
188 exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev wayland-protocols libegl-dev')
189}
190
191fn recompile_v_with_cstrict_gcc() {
192 exec('v -cc gcc -cg -cstrict -o vstrict cmd/v')
193}
194
195fn valgrind_v_c_gcc() {
196 exec('valgrind --error-exitcode=1 v -o v.c cmd/v')
197}
198
199fn run_sanitizers_gcc() {
200 exec('v -o v2 cmd/v -cflags -fsanitize=thread')
201 exec('v -o v3 cmd/v -cflags "-fsanitize=undefined -fno-sanitize=alignment"')
202 exec('UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v')
203 exec('UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v')
204}
205
206fn v_self_compilation_gcc() {
207 exec('v -o v2 cmd/v')
208 exec('./v2 -o v3 cmd/v')
209 exec('./v3 -o v4 cmd/v')
210}
211
212fn v_self_compilation_usecache_gcc() {
213 $if !enable_usecache_test ? {
214 eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
215 return
216 }
217 exec('v wipe-cache')
218 exec('v -usecache examples/hello_world.v')
219 exec('examples/hello_world')
220
221 exec('v wipe-cache')
222 exec('v -o v2 -usecache cmd/v')
223 exec('./v2 -o v3 -usecache cmd/v')
224 exec('./v3 version')
225
226 exec('v wipe-cache')
227 exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
228 exec('rm -f ./examples/hello_world v2 v3 tetris')
229}
230
231fn verify_v_test_works_gcc() {
232 verify_v_test_works()
233}
234
235fn test_pure_v_math_module_gcc() {
236 test_pure_v_math_module()
237}
238
239fn self_tests_gcc() {
240 self_tests()
241}
242
243fn self_tests_prod_gcc() {
244 exec('v -o vprod -prod cmd/v')
245 exec('./vprod -silent test-self vlib')
246}
247
248fn self_tests_cstrict_gcc() {
249 exec('VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 v -cc gcc -cstrict -silent test-self vlib')
250}
251
252fn build_examples_gcc() {
253 build_examples()
254}
255
256fn build_tetris_autofree_gcc() {
257 exec('v -autofree -o tetris examples/tetris/tetris.v')
258 exec('rm -f tetris')
259}
260
261fn build_blog_autofree_gcc() {
262 exec('v -autofree -o blog tutorials/building_a_simple_web_blog_with_veb/code/blog')
263 exec('rm -f blog')
264}
265
266fn build_option_test_autofree_gcc() {
267 exec('v -autofree vlib/v/tests/options/option_test.c.v')
268}
269
270fn v_self_compilation_parallel_cc_gcc() {
271 exec('v -o v2 -parallel-cc cmd/v')
272 exec('rm -f v2')
273}
274
275fn build_modules_gcc() {
276 exec('v build-module vlib/os')
277 exec('v build-module vlib/builtin')
278 exec('v build-module vlib/strconv')
279 exec('v build-module vlib/time')
280 exec('v build-module vlib/term')
281 exec('v build-module vlib/math')
282 exec('v build-module vlib/strings')
283 exec('v build-module vlib/v/token')
284 exec('v build-module vlib/v/ast')
285 exec('v build-module vlib/v/parser')
286 exec('v build-module vlib/v/gen/c')
287 exec('v build-module vlib/v/depgraph')
288 exec('v build-module vlib/os/cmdline')
289}
290
291fn compile_vdoctor_prod_gcc() {
292 exec('v -showcc -cc gcc -prod cmd/tools/vdoctor.v')
293}
294
295fn compile_vup_prod_gcc() {
296 exec('v -showcc -cc gcc -prod cmd/tools/vup.v')
297}
298
299// Clang job tasks
300fn all_code_is_formatted_clang() {
301 all_code_is_formatted()
302}
303
304fn install_dependencies_for_examples_and_tools_clang() {
305 if common.is_github_job {
306 exec('.github/workflows/disable_azure_mirror.sh')
307 }
308 exec('v retry -- sudo apt update')
309 exec('v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind')
310 exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
311 // Wayland development libraries for sokol Wayland support
312 exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev wayland-protocols libegl-dev')
313 exec('v retry -- sudo apt install --quiet -y clang')
314}
315
316fn recompile_v_with_cstrict_clang() {
317 exec('v -cc clang -cg -cstrict -o vstrict cmd/v')
318 exec('rm -f vstrict')
319}
320
321fn valgrind_clang() {
322 exec('valgrind --error-exitcode=1 v -o v.c cmd/v')
323 exec('rm -f v.c')
324}
325
326fn run_sanitizers_clang() {
327 exec('.github/workflows/run_sanitizers.sh')
328}
329
330fn v_self_compilation_clang() {
331 exec('v -o v2 cmd/v')
332 exec('./v2 -o v3 cmd/v')
333 exec('./v3 -o v4 cmd/v')
334}
335
336fn v_self_compilation_usecache_clang() {
337 $if !enable_usecache_test ? {
338 eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
339 return
340 }
341 exec('v wipe-cache')
342 exec('v -usecache examples/hello_world.v')
343 exec('./examples/hello_world')
344
345 exec('v wipe-cache')
346 exec('v -o v2 -usecache cmd/v')
347 exec('./v2 -o v3 -usecache cmd/v')
348 exec('./v3 version')
349
350 exec('v wipe-cache')
351 exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
352 exec('rm -f ./examples/hello_world v2 v3 tetris')
353}
354
355fn verify_v_test_works_clang() {
356 verify_v_test_works()
357}
358
359fn test_pure_v_math_module_clang() {
360 test_pure_v_math_module()
361}
362
363fn self_tests_clang() {
364 self_tests()
365}
366
367fn self_tests_vprod_clang() {
368 exec('v -o vprod -prod cmd/v')
369 exec('./vprod -silent test-self vlib')
370}
371
372fn self_tests_cstrict_clang() {
373 exec('VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./vprod -cstrict -silent test-self vlib')
374}
375
376fn build_examples_clang() {
377 build_examples()
378}
379
380fn build_examples_autofree_clang() {
381 exec('v -N -W -autofree -experimental -o tetris examples/tetris/tetris.v')
382 exec('rm -f tetris')
383}
384
385fn build_modules_clang() {
386 exec('v build-module vlib/os')
387 exec('v build-module vlib/builtin')
388 exec('v build-module vlib/strconv')
389 exec('v build-module vlib/time')
390 exec('v build-module vlib/term')
391 exec('v build-module vlib/math')
392 exec('v build-module vlib/strings')
393 exec('v build-module vlib/v/token')
394 exec('v build-module vlib/v/ast')
395 exec('v build-module vlib/v/parser')
396 exec('v build-module vlib/v/gen/c')
397 exec('v build-module vlib/v/depgraph')
398 exec('v build-module vlib/os/cmdline')
399}
400
401fn test_inline_assembly() {
402 exec('v test vlib/v/slow_tests/assembly')
403}
404
405// Collect all tasks
406const all_tasks = {
407 'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
408 // tcc tasks
409 'all_code_is_formatted_tcc': Task{all_code_is_formatted, 'All code is formatted (tcc)'}
410 'install_dependencies_for_examples_and_tools_tcc': Task{install_dependencies_for_examples_and_tools_tcc, 'Install deps for examples/tools (tcc)'}
411 'test_v_to_c_tcc': Task{test_v_to_c_tcc, 'Test v->c with tcc'}
412 'v_self_compilation_tcc': Task{v_self_compilation_tcc, 'V self compilation (tcc)'}
413 'v_doctor_tcc': Task{v_doctor_tcc, 'v doctor (tcc)'}
414 'verify_v_test_works_tcc': Task{verify_v_test_works_tcc, 'Verify `v test` works (tcc)'}
415 'test_pure_v_math_module_tcc': Task{test_pure_v_math_module_tcc, 'Test pure V math module (tcc)'}
416 'self_tests_tcc': Task{self_tests_tcc, 'Self tests (tcc)'}
417 'build_examples_tcc': Task{build_examples_tcc, 'Build examples (tcc)'}
418 'run_submodule_example_tcc': Task{run_submodule_example_tcc, 'Run submodule example (tcc)'}
419 'build_tools_tcc': Task{build_tools_tcc, 'Build V tools (tcc)'}
420 'build_vbinaries_tcc': Task{build_vbinaries_tcc, 'Build V binaries (tcc)'}
421 'build_benches_tcc': Task{build_benches_tcc, 'Build benches (tcc)'}
422 'run_vsh_script_tcc': Task{run_vsh_script_tcc, 'Run a VSH script (tcc)'}
423 'test_v_tutorials_tcc': Task{test_v_tutorials_tcc, 'Test V tutorials (tcc)'}
424 'build_fast_tcc': Task{build_fast_tcc, 'Build cmd/tools/fast (tcc)'}
425 'v_self_compilation_usecache_tcc': Task{v_self_compilation_usecache_tcc, 'V self compilation with -usecache (tcc)'}
426 'test_password_input_tcc': Task{test_password_input_tcc, 'Test password input (tcc)'}
427 'test_readline_tcc': Task{test_readline_tcc, 'Test readline (tcc)'}
428 'test_leak_detector_tcc': Task{test_leak_detector_tcc, 'Test leak detector (tcc)'}
429 'test_leak_detector_not_active_tcc': Task{test_leak_detector_not_active_tcc, 'Test leak detector not active (tcc)'}
430 // gcc tasks
431 'all_code_is_formatted_gcc': Task{all_code_is_formatted_gcc, 'All code is formatted (gcc)'}
432 'install_dependencies_for_examples_and_tools_gcc': Task{install_dependencies_for_examples_and_tools_gcc, 'Install deps for examples/tools (gcc)'}
433 'recompile_v_with_cstrict_gcc': Task{recompile_v_with_cstrict_gcc, 'Recompile V with -cstrict and gcc'}
434 'valgrind_v_c_gcc': Task{valgrind_v_c_gcc, 'Valgrind v.c (gcc)'}
435 'run_sanitizers_gcc': Task{run_sanitizers_gcc, 'Run sanitizers (gcc)'}
436 'v_self_compilation_gcc': Task{v_self_compilation_gcc, 'V self compilation (gcc)'}
437 'v_self_compilation_usecache_gcc': Task{v_self_compilation_usecache_gcc, 'V self compilation with -usecache (gcc)'}
438 'verify_v_test_works_gcc': Task{verify_v_test_works_gcc, 'Verify `v test` works (gcc)'}
439 'test_pure_v_math_module_gcc': Task{test_pure_v_math_module_gcc, 'Test pure V math module (gcc)'}
440 'self_tests_gcc': Task{self_tests_gcc, 'Self tests (gcc)'}
441 'self_tests_prod_gcc': Task{self_tests_prod_gcc, 'Self tests (-prod) (gcc)'}
442 'self_tests_cstrict_gcc': Task{self_tests_cstrict_gcc, 'Self tests (-cstrict) (gcc)'}
443 'build_examples_gcc': Task{build_examples_gcc, 'Build examples (gcc)'}
444 'build_tetris_autofree_gcc': Task{build_tetris_autofree_gcc, 'Build tetris with -autofree (gcc)'}
445 'build_blog_autofree_gcc': Task{build_blog_autofree_gcc, 'Build blog tutorial with -autofree (gcc)'}
446 'build_option_test_autofree_gcc': Task{build_option_test_autofree_gcc, 'Build option_test.c.v with -autofree (gcc)'}
447 'v_self_compilation_parallel_cc_gcc': Task{v_self_compilation_parallel_cc_gcc, 'V self compilation with -parallel-cc (gcc)'}
448 'build_modules_gcc': Task{build_modules_gcc, 'Build modules (gcc)'}
449 'compile_vdoctor_prod_gcc': Task{compile_vdoctor_prod_gcc, 'compile vdoctor with -prod (gcc)'}
450 'compile_vup_prod_gcc': Task{compile_vup_prod_gcc, 'compile vup with -prod (gcc)'}
451 // clang tasks
452 'all_code_is_formatted_clang': Task{all_code_is_formatted_clang, 'All code is formatted (clang)'}
453 'install_dependencies_for_examples_and_tools_clang': Task{install_dependencies_for_examples_and_tools_clang, 'Install deps for examples/tools (clang)'}
454 'recompile_v_with_cstrict_clang': Task{recompile_v_with_cstrict_clang, 'Recompile V with -cstrict and clang'}
455 'valgrind_clang': Task{valgrind_clang, 'Valgrind (clang)'}
456 'run_sanitizers_clang': Task{run_sanitizers_clang, 'Run sanitizers (clang)'}
457 'v_self_compilation_clang': Task{v_self_compilation_clang, 'V self compilation (clang)'}
458 'v_self_compilation_usecache_clang': Task{v_self_compilation_usecache_clang, 'V self compilation with -usecache (clang)'}
459 'verify_v_test_works_clang': Task{verify_v_test_works_clang, 'Verify `v test` works (clang)'}
460 'test_pure_v_math_module_clang': Task{test_pure_v_math_module_clang, 'Test pure V math module (clang)'}
461 'self_tests_clang': Task{self_tests_clang, 'Self tests (clang)'}
462 'self_tests_vprod_clang': Task{self_tests_vprod_clang, 'Self tests (vprod) (clang)'}
463 'self_tests_cstrict_clang': Task{self_tests_cstrict_clang, 'Self tests (-cstrict) (clang)'}
464 'build_examples_clang': Task{build_examples_clang, 'Build examples (clang)'}
465 'build_examples_autofree_clang': Task{build_examples_autofree_clang, 'Build examples with -autofree (clang)'}
466 'build_modules_clang': Task{build_modules_clang, 'Build modules (clang)'}
467 'test_inline_assembly': Task{test_inline_assembly, 'Test inline assembly'}
468}
469
470common.run(all_tasks)
471