Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

+110
View File
@@ -0,0 +1,110 @@
module common
import os
import log
import term
import time
// exec is a helper function, to execute commands and exit early, if they fail.
pub fn exec(command string) {
cmd := resolve_v_command(command)
log.info('cmd: ${cmd}')
result := os.system(cmd)
if result != 0 {
exit(result)
}
}
// resolve_v_command ensures that commands starting with `v ` use the V from @VEXEROOT,
// not a potentially different V found via PATH.
fn resolve_v_command(command string) string {
if command.starts_with('v ') {
return os.quoted_path(os.join_path_single(@VEXEROOT, 'v')) + command[1..]
}
return command
}
// unset is a helper function to unset a specific env variable.
pub fn unset(evar string) {
log.info('unsetting env variable: ${evar}')
os.unsetenv(evar)
}
// file_size_greater_than asserts that the given file exists, and is at least min_fsize bytes long.
pub fn file_size_greater_than(fpath string, min_fsize u64) {
log.info('path should exist `${fpath}` ...')
if !os.exists(fpath) {
exit(1)
}
log.info('path exists, and should be a file: `${fpath}` ...')
if !os.is_file(fpath) {
exit(2)
}
real_size := os.file_size(fpath)
log.info('actual file size of `${fpath}` is ${real_size}, wanted: ${min_fsize}, diff: ${real_size - min_fsize}.')
if real_size < min_fsize {
exit(3)
}
}
const self_command = os.quoted_path(os.join_path_single(@VEXEROOT, 'v')) + ' ' +
os.real_path(os.executable()).replace_once(os.real_path(@VEXEROOT), '').trim_left('/\\') +
'.vsh'
pub const is_github_job = os.getenv('GITHUB_JOB') != ''
pub type Fn = fn ()
pub struct Task {
pub mut:
f Fn = unsafe { nil }
label string
}
pub fn (t Task) run(tname string) {
cmd := '${self_command} ${tname}'
log.info('Start ${term.colorize(term.yellow, t.label)}, cmd: `${cmd}`')
start := time.now()
t.f()
dt := time.now() - start
log.info('Finished ${term.colorize(term.yellow, t.label)} in ${dt.milliseconds()} ms, cmd: `${cmd}`')
println('')
}
pub fn run(all_tasks map[string]Task) {
unbuffer_stdout()
log.use_stdout()
if os.args.len < 2 {
println('Usage: v run macos_ci.vsh <task_name>')
println('Available tasks are: ${all_tasks.keys()}')
exit(0)
}
task_name := os.args[1]
if task_name == 'all' {
log.info(term.colorize(term.green, 'Run everything...'))
mut failed_tasks := []string{}
for tname, t in all_tasks {
cmd := '${self_command} ${tname}'
log.info('Start ${term.colorize(term.yellow, t.label)}, cmd: `${cmd}`')
start := time.now()
result := os.system(cmd)
dt := time.now() - start
if result != 0 {
log.error('FAILED ${term.colorize(term.red, t.label)} in ${dt.milliseconds()} ms, cmd: `${cmd}`')
failed_tasks << tname
} else {
log.info('Finished ${term.colorize(term.yellow, t.label)} in ${dt.milliseconds()} ms, cmd: `${cmd}`')
}
}
if failed_tasks.len > 0 {
log.error('${failed_tasks.len} task(s) failed: ${failed_tasks}')
exit(1)
}
exit(0)
}
t := all_tasks[task_name] or {
eprintln('Unknown task with name: `${task_name}`')
exit(1)
}
t.run(task_name)
}
+145
View File
@@ -0,0 +1,145 @@
import os
import common { Task, exec }
fn v_doctor() {
if common.is_github_job {
println('::group::vdoctor')
} else {
println('### vdoctor')
}
dump(os.getenv('PATH'))
exec('v doctor')
if common.is_github_job {
exec('freebsd-version')
exec('sysctl hw.model')
exec('sysctl hw.ncpu')
exec('sysctl hw.physmem')
exec('sysctl hw.usermem')
exec('whoami')
exec('pwd')
exec('ls -la')
exec('git log -n1')
exec('cc --version')
println('::endgroup::')
}
}
fn build_v_with_prealloc() {
if common.is_github_job {
println('::group::Build v with prealloc')
} else {
println('### Build v with prealloc')
}
exec('v -cg -cstrict -o vstrict1 cmd/v')
// -prealloc uses _Thread_local for g_memory_block; bundled tcc does not support it.
prealloc_cc_flag := if os.getenv('VFLAGS').contains('-cc tcc') { ' -cc cc' } else { '' }
exec('./vstrict1${prealloc_cc_flag} -o vprealloc -prealloc cmd/v')
exec('./vprealloc run examples/hello_world.v')
exec('./vprealloc -o v3 cmd/v')
exec('./v3 -o v4 cmd/v')
exec('./v4 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v')
if common.is_github_job {
println('::endgroup::')
}
}
fn verify_v_test_works() {
if common.is_github_job {
println('::group::Verify v test')
} else {
println('### Verify v test')
}
exec('echo \$VFLAGS')
exec('v cmd/tools/test_if_v_test_system_works.v')
exec('./cmd/tools/test_if_v_test_system_works')
if common.is_github_job {
println('::endgroup::')
}
}
fn build_fast_script() {
if common.is_github_job {
println('::group::Build fast script')
} else {
println('### Build fast script')
}
exec('cd cmd/tools/fast && v fast.v')
if common.is_github_job {
println('::endgroup::')
}
}
fn check_math() {
if common.is_github_job {
println('::group::Test vlib/math')
} else {
println('### Test vlib/math')
}
exec('v -silent test vlib/math')
println('Test the math module, using only the pure V versions,')
println(' without the .c.v overrides.')
exec('v -silent -exclude @vlib/math/*.c.v test vlib/math')
if common.is_github_job {
println('::endgroup::')
}
}
fn test_inline_assembly() {
if common.is_github_job {
println('::group::Test inline Assembly')
} else {
println('### Test inline Assembly')
}
exec('v test vlib/v/slow_tests/assembly')
if common.is_github_job {
println('::endgroup::')
}
}
fn check_compress() {
if common.is_github_job {
println('::group::Test vlib/compress')
} else {
println('### Test vlib/compress')
}
exec('v -silent test vlib/compress')
if common.is_github_job {
println('::endgroup::')
}
}
fn run_essential_tests() {
if common.is_github_job {
println('::group::Run essential tests')
exec('VTEST_JUST_ESSENTIAL=1 v -silent test-self')
println('::endgroup::')
} else {
println('### Run essential tests')
exec('VTEST_JUST_ESSENTIAL=1 v -progress test-self')
}
}
fn build_examples() {
if common.is_github_job {
println('::group::Build examples')
exec('v -W build-examples')
println('::endgroup::')
} else {
println('### Build examples')
exec('v -progress build-examples')
}
}
const all_tasks = {
'v_doctor': Task{v_doctor, 'Run v doctor'}
'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
'verify_v_test_works': Task{verify_v_test_works, 'Verify that v test works'}
'build_fast_script': Task{build_fast_script, 'Check that building fast.v works'}
'check_math': Task{check_math, 'Check the `math` module works'}
'check_compress': Task{check_compress, 'Check the `compress` module works'}
'test_inline_assembly': Task{test_inline_assembly, 'Test inline Assembly'}
'run_essential_tests': Task{run_essential_tests, 'Run only the essential tests'}
'build_examples': Task{build_examples, 'Build examples'}
}
common.run(all_tasks)
+470
View File
@@ -0,0 +1,470 @@
import common { Task, exec }
import os
// Shared tasks/helpers
fn all_code_is_formatted() {
if common.is_github_job {
exec('v -silent test-cleancode')
} else {
exec('v -progress test-cleancode')
}
}
fn verify_v_test_works() {
exec('echo \$VFLAGS')
exec('v cmd/tools/test_if_v_test_system_works.v')
exec('./cmd/tools/test_if_v_test_system_works')
}
fn test_pure_v_math_module() {
exec('v -exclude @vlib/math/*.c.v test vlib/math/')
}
fn self_tests() {
if common.is_github_job {
exec('v -W -silent test-self vlib')
} else {
exec('v -progress test-self vlib')
}
}
fn build_examples() {
if common.is_github_job {
exec('v -W build-examples')
} else {
exec('v -progress build-examples')
}
}
fn v_doctor() {
exec('v doctor')
}
fn build_v_with_prealloc() {
exec('v -cg -cstrict -o vstrict1 cmd/v')
// -prealloc uses _Thread_local for g_memory_block; bundled tcc does not support it.
prealloc_cc_flag := if os.getenv('VFLAGS').contains('-cc tcc') { ' -cc cc' } else { '' }
exec('./vstrict1${prealloc_cc_flag} -o vprealloc -prealloc cmd/v')
exec('./vprealloc run examples/hello_world.v')
exec('./vprealloc -o v3 cmd/v')
exec('./v3 -o v4 cmd/v')
exec('./v4 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v')
}
// TCC job tasks
fn install_dependencies_for_examples_and_tools_tcc() {
if common.is_github_job {
exec('.github/workflows/disable_azure_mirror.sh')
}
exec('v retry -- sudo apt update')
exec('v retry -- sudo apt install --quiet -y libssl-dev sqlite3 libsqlite3-dev valgrind')
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev libegl-dev')
// Wayland development libraries for sokol Wayland support
exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev')
// The following is needed for examples/wkhtmltopdf.v
exec('v retry -- sudo apt install --quiet -y xfonts-75dpi xfonts-base expect')
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')
exec('v retry -- sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb')
}
fn test_v_to_c_tcc() {
exec('thirdparty/tcc/tcc.exe -version')
exec('v -cg -o vtcc cmd/v') // ensure vtcc can build itself twice
}
fn v_self_compilation_tcc() {
exec('v -o v2 cmd/v')
exec('./v2 -o v3 cmd/v')
exec('./v3 -o v4 cmd/v')
}
fn v_doctor_tcc() {
v_doctor()
}
fn verify_v_test_works_tcc() {
verify_v_test_works()
}
fn test_pure_v_math_module_tcc() {
test_pure_v_math_module()
}
fn self_tests_tcc() {
exec('v -keepc -cc tcc -g self')
self_tests()
}
fn build_examples_tcc() {
build_examples()
}
fn run_submodule_example_tcc() {
exec('v -W run examples/submodule')
}
fn build_tools_tcc() {
if common.is_github_job {
exec('v -N -W build-tools')
} else {
exec('v -progress -N -W build-tools')
}
}
fn build_vbinaries_tcc() {
exec('v -N -W build-vbinaries')
}
fn build_benches_tcc() {
exec('v should-compile-all vlib/v/tests/bench/')
}
fn run_vsh_script_tcc() {
exec('v run examples/v_script.vsh')
}
fn test_v_tutorials_tcc() {
exec('v tutorials/building_a_simple_web_blog_with_veb/code/blog')
}
fn build_fast_tcc() {
exec('cd cmd/tools/fast && v fast.v')
exec('cd cmd/tools/fast && ./fast')
}
fn v_self_compilation_usecache_tcc() {
$if !enable_usecache_test ? {
eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
return
}
exec('v wipe-cache')
exec('v -usecache examples/hello_world.v')
exec('./examples/hello_world')
exec('v wipe-cache')
exec('v -o v2 -usecache cmd/v')
exec('./v2 -o v3 -usecache cmd/v')
exec('./v3 version')
exec('v wipe-cache')
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
exec('rm -f ./examples/hello_world v2 v3 tetris')
}
fn test_password_input_tcc() {
exec('v test examples/password/')
}
fn test_readline_tcc() {
exec('v test examples/readline/')
}
fn test_leak_detector_tcc() {
exec('v -gc boehm_leak -o testcase_leak vlib/v/tests/testcase_leak.vv')
exec('./testcase_leak 2>leaks.txt')
exec('grep "Found 1 leaked object" leaks.txt')
exec('grep -P ", sz=\\s?1000," leaks.txt')
}
fn test_leak_detector_not_active_tcc() {
exec('v -o testcase_leak vlib/v/tests/testcase_leak.vv')
exec('./testcase_leak 2>leaks.txt')
exec('[ "$(stat -c %s leaks.txt)" = "0" ]')
}
// GCC job tasks
fn all_code_is_formatted_gcc() {
all_code_is_formatted()
}
fn install_dependencies_for_examples_and_tools_gcc() {
if common.is_github_job {
exec('.github/workflows/disable_azure_mirror.sh')
}
exec('v retry -- sudo apt update')
exec('v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind')
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
// Wayland development libraries for sokol Wayland support
exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev wayland-protocols libegl-dev')
}
fn recompile_v_with_cstrict_gcc() {
exec('v -cc gcc -cg -cstrict -o vstrict cmd/v')
}
fn valgrind_v_c_gcc() {
exec('valgrind --error-exitcode=1 v -o v.c cmd/v')
}
fn run_sanitizers_gcc() {
exec('v -o v2 cmd/v -cflags -fsanitize=thread')
exec('v -o v3 cmd/v -cflags "-fsanitize=undefined -fno-sanitize=alignment"')
exec('UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v')
exec('UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v3 -o v.c cmd/v')
}
fn v_self_compilation_gcc() {
exec('v -o v2 cmd/v')
exec('./v2 -o v3 cmd/v')
exec('./v3 -o v4 cmd/v')
}
fn v_self_compilation_usecache_gcc() {
$if !enable_usecache_test ? {
eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
return
}
exec('v wipe-cache')
exec('v -usecache examples/hello_world.v')
exec('examples/hello_world')
exec('v wipe-cache')
exec('v -o v2 -usecache cmd/v')
exec('./v2 -o v3 -usecache cmd/v')
exec('./v3 version')
exec('v wipe-cache')
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
exec('rm -f ./examples/hello_world v2 v3 tetris')
}
fn verify_v_test_works_gcc() {
verify_v_test_works()
}
fn test_pure_v_math_module_gcc() {
test_pure_v_math_module()
}
fn self_tests_gcc() {
self_tests()
}
fn self_tests_prod_gcc() {
exec('v -o vprod -prod cmd/v')
exec('./vprod -silent test-self vlib')
}
fn self_tests_cstrict_gcc() {
exec('VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 v -cc gcc -cstrict -silent test-self vlib')
}
fn build_examples_gcc() {
build_examples()
}
fn build_tetris_autofree_gcc() {
exec('v -autofree -o tetris examples/tetris/tetris.v')
exec('rm -f tetris')
}
fn build_blog_autofree_gcc() {
exec('v -autofree -o blog tutorials/building_a_simple_web_blog_with_veb/code/blog')
exec('rm -f blog')
}
fn build_option_test_autofree_gcc() {
exec('v -autofree vlib/v/tests/options/option_test.c.v')
}
fn v_self_compilation_parallel_cc_gcc() {
exec('v -o v2 -parallel-cc cmd/v')
exec('rm -f v2')
}
fn build_modules_gcc() {
exec('v build-module vlib/os')
exec('v build-module vlib/builtin')
exec('v build-module vlib/strconv')
exec('v build-module vlib/time')
exec('v build-module vlib/term')
exec('v build-module vlib/math')
exec('v build-module vlib/strings')
exec('v build-module vlib/v/token')
exec('v build-module vlib/v/ast')
exec('v build-module vlib/v/parser')
exec('v build-module vlib/v/gen/c')
exec('v build-module vlib/v/depgraph')
exec('v build-module vlib/os/cmdline')
}
fn compile_vdoctor_prod_gcc() {
exec('v -showcc -cc gcc -prod cmd/tools/vdoctor.v')
}
fn compile_vup_prod_gcc() {
exec('v -showcc -cc gcc -prod cmd/tools/vup.v')
}
// Clang job tasks
fn all_code_is_formatted_clang() {
all_code_is_formatted()
}
fn install_dependencies_for_examples_and_tools_clang() {
if common.is_github_job {
exec('.github/workflows/disable_azure_mirror.sh')
}
exec('v retry -- sudo apt update')
exec('v retry -- sudo apt install --quiet -y postgresql libpq-dev libssl-dev sqlite3 libsqlite3-dev valgrind')
exec('v retry -- sudo apt install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev libxrandr-dev libasound2-dev')
// Wayland development libraries for sokol Wayland support
exec('v retry -- sudo apt install --quiet -y libwayland-dev libxkbcommon-dev libwayland-egl1-mesa libxkbcommon-x11-dev wayland-protocols libegl-dev')
exec('v retry -- sudo apt install --quiet -y clang')
}
fn recompile_v_with_cstrict_clang() {
exec('v -cc clang -cg -cstrict -o vstrict cmd/v')
exec('rm -f vstrict')
}
fn valgrind_clang() {
exec('valgrind --error-exitcode=1 v -o v.c cmd/v')
exec('rm -f v.c')
}
fn run_sanitizers_clang() {
exec('.github/workflows/run_sanitizers.sh')
}
fn v_self_compilation_clang() {
exec('v -o v2 cmd/v')
exec('./v2 -o v3 cmd/v')
exec('./v3 -o v4 cmd/v')
}
fn v_self_compilation_usecache_clang() {
$if !enable_usecache_test ? {
eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
return
}
exec('v wipe-cache')
exec('v -usecache examples/hello_world.v')
exec('./examples/hello_world')
exec('v wipe-cache')
exec('v -o v2 -usecache cmd/v')
exec('./v2 -o v3 -usecache cmd/v')
exec('./v3 version')
exec('v wipe-cache')
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
exec('rm -f ./examples/hello_world v2 v3 tetris')
}
fn verify_v_test_works_clang() {
verify_v_test_works()
}
fn test_pure_v_math_module_clang() {
test_pure_v_math_module()
}
fn self_tests_clang() {
self_tests()
}
fn self_tests_vprod_clang() {
exec('v -o vprod -prod cmd/v')
exec('./vprod -silent test-self vlib')
}
fn self_tests_cstrict_clang() {
exec('VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 ./vprod -cstrict -silent test-self vlib')
}
fn build_examples_clang() {
build_examples()
}
fn build_examples_autofree_clang() {
exec('v -N -W -autofree -experimental -o tetris examples/tetris/tetris.v')
exec('rm -f tetris')
}
fn build_modules_clang() {
exec('v build-module vlib/os')
exec('v build-module vlib/builtin')
exec('v build-module vlib/strconv')
exec('v build-module vlib/time')
exec('v build-module vlib/term')
exec('v build-module vlib/math')
exec('v build-module vlib/strings')
exec('v build-module vlib/v/token')
exec('v build-module vlib/v/ast')
exec('v build-module vlib/v/parser')
exec('v build-module vlib/v/gen/c')
exec('v build-module vlib/v/depgraph')
exec('v build-module vlib/os/cmdline')
}
fn test_inline_assembly() {
exec('v test vlib/v/slow_tests/assembly')
}
// Collect all tasks
const all_tasks = {
'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
// tcc tasks
'all_code_is_formatted_tcc': Task{all_code_is_formatted, 'All code is formatted (tcc)'}
'install_dependencies_for_examples_and_tools_tcc': Task{install_dependencies_for_examples_and_tools_tcc, 'Install deps for examples/tools (tcc)'}
'test_v_to_c_tcc': Task{test_v_to_c_tcc, 'Test v->c with tcc'}
'v_self_compilation_tcc': Task{v_self_compilation_tcc, 'V self compilation (tcc)'}
'v_doctor_tcc': Task{v_doctor_tcc, 'v doctor (tcc)'}
'verify_v_test_works_tcc': Task{verify_v_test_works_tcc, 'Verify `v test` works (tcc)'}
'test_pure_v_math_module_tcc': Task{test_pure_v_math_module_tcc, 'Test pure V math module (tcc)'}
'self_tests_tcc': Task{self_tests_tcc, 'Self tests (tcc)'}
'build_examples_tcc': Task{build_examples_tcc, 'Build examples (tcc)'}
'run_submodule_example_tcc': Task{run_submodule_example_tcc, 'Run submodule example (tcc)'}
'build_tools_tcc': Task{build_tools_tcc, 'Build V tools (tcc)'}
'build_vbinaries_tcc': Task{build_vbinaries_tcc, 'Build V binaries (tcc)'}
'build_benches_tcc': Task{build_benches_tcc, 'Build benches (tcc)'}
'run_vsh_script_tcc': Task{run_vsh_script_tcc, 'Run a VSH script (tcc)'}
'test_v_tutorials_tcc': Task{test_v_tutorials_tcc, 'Test V tutorials (tcc)'}
'build_fast_tcc': Task{build_fast_tcc, 'Build cmd/tools/fast (tcc)'}
'v_self_compilation_usecache_tcc': Task{v_self_compilation_usecache_tcc, 'V self compilation with -usecache (tcc)'}
'test_password_input_tcc': Task{test_password_input_tcc, 'Test password input (tcc)'}
'test_readline_tcc': Task{test_readline_tcc, 'Test readline (tcc)'}
'test_leak_detector_tcc': Task{test_leak_detector_tcc, 'Test leak detector (tcc)'}
'test_leak_detector_not_active_tcc': Task{test_leak_detector_not_active_tcc, 'Test leak detector not active (tcc)'}
// gcc tasks
'all_code_is_formatted_gcc': Task{all_code_is_formatted_gcc, 'All code is formatted (gcc)'}
'install_dependencies_for_examples_and_tools_gcc': Task{install_dependencies_for_examples_and_tools_gcc, 'Install deps for examples/tools (gcc)'}
'recompile_v_with_cstrict_gcc': Task{recompile_v_with_cstrict_gcc, 'Recompile V with -cstrict and gcc'}
'valgrind_v_c_gcc': Task{valgrind_v_c_gcc, 'Valgrind v.c (gcc)'}
'run_sanitizers_gcc': Task{run_sanitizers_gcc, 'Run sanitizers (gcc)'}
'v_self_compilation_gcc': Task{v_self_compilation_gcc, 'V self compilation (gcc)'}
'v_self_compilation_usecache_gcc': Task{v_self_compilation_usecache_gcc, 'V self compilation with -usecache (gcc)'}
'verify_v_test_works_gcc': Task{verify_v_test_works_gcc, 'Verify `v test` works (gcc)'}
'test_pure_v_math_module_gcc': Task{test_pure_v_math_module_gcc, 'Test pure V math module (gcc)'}
'self_tests_gcc': Task{self_tests_gcc, 'Self tests (gcc)'}
'self_tests_prod_gcc': Task{self_tests_prod_gcc, 'Self tests (-prod) (gcc)'}
'self_tests_cstrict_gcc': Task{self_tests_cstrict_gcc, 'Self tests (-cstrict) (gcc)'}
'build_examples_gcc': Task{build_examples_gcc, 'Build examples (gcc)'}
'build_tetris_autofree_gcc': Task{build_tetris_autofree_gcc, 'Build tetris with -autofree (gcc)'}
'build_blog_autofree_gcc': Task{build_blog_autofree_gcc, 'Build blog tutorial with -autofree (gcc)'}
'build_option_test_autofree_gcc': Task{build_option_test_autofree_gcc, 'Build option_test.c.v with -autofree (gcc)'}
'v_self_compilation_parallel_cc_gcc': Task{v_self_compilation_parallel_cc_gcc, 'V self compilation with -parallel-cc (gcc)'}
'build_modules_gcc': Task{build_modules_gcc, 'Build modules (gcc)'}
'compile_vdoctor_prod_gcc': Task{compile_vdoctor_prod_gcc, 'compile vdoctor with -prod (gcc)'}
'compile_vup_prod_gcc': Task{compile_vup_prod_gcc, 'compile vup with -prod (gcc)'}
// clang tasks
'all_code_is_formatted_clang': Task{all_code_is_formatted_clang, 'All code is formatted (clang)'}
'install_dependencies_for_examples_and_tools_clang': Task{install_dependencies_for_examples_and_tools_clang, 'Install deps for examples/tools (clang)'}
'recompile_v_with_cstrict_clang': Task{recompile_v_with_cstrict_clang, 'Recompile V with -cstrict and clang'}
'valgrind_clang': Task{valgrind_clang, 'Valgrind (clang)'}
'run_sanitizers_clang': Task{run_sanitizers_clang, 'Run sanitizers (clang)'}
'v_self_compilation_clang': Task{v_self_compilation_clang, 'V self compilation (clang)'}
'v_self_compilation_usecache_clang': Task{v_self_compilation_usecache_clang, 'V self compilation with -usecache (clang)'}
'verify_v_test_works_clang': Task{verify_v_test_works_clang, 'Verify `v test` works (clang)'}
'test_pure_v_math_module_clang': Task{test_pure_v_math_module_clang, 'Test pure V math module (clang)'}
'self_tests_clang': Task{self_tests_clang, 'Self tests (clang)'}
'self_tests_vprod_clang': Task{self_tests_vprod_clang, 'Self tests (vprod) (clang)'}
'self_tests_cstrict_clang': Task{self_tests_cstrict_clang, 'Self tests (-cstrict) (clang)'}
'build_examples_clang': Task{build_examples_clang, 'Build examples (clang)'}
'build_examples_autofree_clang': Task{build_examples_autofree_clang, 'Build examples with -autofree (clang)'}
'build_modules_clang': Task{build_modules_clang, 'Build modules (clang)'}
'test_inline_assembly': Task{test_inline_assembly, 'Test inline assembly'}
}
common.run(all_tasks)
+163
View File
@@ -0,0 +1,163 @@
import common { Task, exec }
import os
fn test_symlink() {
exec('v symlink')
}
fn test_cross_compilation() {
exec('v -o hw -os linux examples/hello_world.v && ls -la hw && file hw')
exec('v -d use_openssl -o ve -os linux examples/veb/veb_example.v && ls -la ve && file ve')
}
fn build_with_cstrict() {
exec('v -cg -cstrict -o vstrict1 cmd/v')
}
fn all_code_is_formatted() {
if common.is_github_job {
exec('VJOBS=1 v -silent test-cleancode')
} else {
vjobs := os.getenv_opt('VJOBS') or { '1' }
exec('VJOBS=${vjobs} v -progress test-cleancode')
}
}
fn run_sanitizers() {
exec('v -o v2 cmd/v -cflags -fsanitize=undefined')
exec('UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v')
}
fn build_using_v() {
exec('v -o v2 cmd/v')
exec('./v2 -o v3 cmd/v')
}
fn verify_v_test_works() {
exec('echo \$VFLAGS')
exec('v cmd/tools/test_if_v_test_system_works.v')
exec('./cmd/tools/test_if_v_test_system_works')
}
fn install_iconv() {
// Skip Homebrew when iconv is already linkable for V on this machine.
if os.system('v -silent test vlib/encoding/iconv/') == 0 {
return
}
exec('brew list --versions libiconv >/dev/null 2>&1 || brew install libiconv')
}
fn test_pure_v_math_module() {
exec('v -silent -exclude @vlib/math/*.c.v test vlib/math/')
}
fn self_tests() {
if common.is_github_job {
exec('VJOBS=1 v -silent test-self vlib')
} else {
vjobs := os.getenv_opt('VJOBS') or { '1' }
exec('VJOBS=${vjobs} v -progress test-self vlib')
}
}
fn build_examples() {
if common.is_github_job {
exec('v build-examples')
} else {
exec('v -progress build-examples')
}
}
fn build_examples_v_compiled_with_tcc() {
exec('v -o vtcc -cc tcc cmd/v')
if common.is_github_job {
exec('./vtcc build-examples')
} else {
exec('./vtcc -progress build-examples')
}
}
fn build_tetris_autofree() {
exec('v -autofree -o tetris examples/tetris/tetris.v')
}
fn build_blog_autofree() {
exec('v -autofree -o blog tutorials/building_a_simple_web_blog_with_veb/code/blog')
}
fn build_examples_prod() {
exec('v -prod examples/news_fetcher.v')
}
fn v_doctor() {
exec('v doctor')
}
fn build_v_with_prealloc() {
exec('v -cg -cstrict -o vstrict1 cmd/v')
exec('./vstrict1 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v')
exec('./vstrict1 -o vprealloc -prealloc cmd/v')
// TODO: fix prealloc on macos (the rwmutex implementation for shared maps there seems to require that mutexes are allocated by C.malloc directly, and segfaults for arbitrary memory addresses)
// exec('./vprealloc run examples/hello_world.v')
// exec('./vprealloc -o v3 cmd/v')
// exec('./v3 -o v4 cmd/v')
}
fn v_self_compilation_usecache() {
$if !enable_usecache_test ? {
eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
return
}
exec('v -usecache examples/hello_world.v')
exec('./examples/hello_world')
exec('v -o v2 -usecache cmd/v')
exec('./v2 -o v3 -usecache cmd/v')
exec('./v3 version')
exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
}
fn v_self_compilation_parallel_cc() {
exec('v -o vp -parallel-cc cmd/v')
// exec('./v2 -o v3 -usecache cmd/v')
exec('./vp version')
exec('./vp -o tetris examples/tetris/tetris.v')
}
fn test_password_input() {
exec('v -silent test examples/password/')
}
fn test_readline() {
exec('v -silent test examples/readline/')
}
fn test_inline_assembly() {
exec('v test vlib/v/slow_tests/assembly')
}
const all_tasks = {
'test_symlink': Task{test_symlink, 'Test symlink'}
'test_cross_compilation': Task{test_cross_compilation, 'Test cross compilation to Linux'}
'build_with_cstrict': Task{build_with_cstrict, 'Build V with -cstrict'}
'all_code_is_formatted': Task{all_code_is_formatted, 'All code is formatted'}
'run_sanitizers': Task{run_sanitizers, 'Run sanitizers'}
'build_using_v': Task{build_using_v, 'Build V using V'}
'verify_v_test_works': Task{verify_v_test_works, 'Verify `v test` works'}
'install_iconv': Task{install_iconv, 'Install iconv for encoding.iconv'}
'test_pure_v_math_module': Task{test_pure_v_math_module, 'Test pure V math module'}
'self_tests': Task{self_tests, 'Self tests'}
'build_examples': Task{build_examples, 'Build examples'}
'build_tetris_autofree': Task{build_tetris_autofree, 'Build tetris with -autofree'}
'build_blog_autofree': Task{build_blog_autofree, 'Build blog tutorial with -autofree'}
'build_examples_prod': Task{build_examples_prod, 'Build examples with -prod'}
'build_examples_v_compiled_with_tcc': Task{build_examples_v_compiled_with_tcc, 'Build examples with V build with tcc'}
'v_doctor': Task{v_doctor, 'v doctor'}
'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
'v_self_compilation_usecache': Task{v_self_compilation_usecache, 'V self compilation with -usecache'}
'v_self_compilation_parallel_cc': Task{v_self_compilation_parallel_cc, 'V self compilation with -parallel-cc'}
'test_password_input': Task{test_password_input, 'Test password input'}
'test_readline': Task{test_readline, 'Test readline'}
'test_inline_assembly': Task{test_inline_assembly, 'Test inline assembly'}
}
common.run(all_tasks)
+145
View File
@@ -0,0 +1,145 @@
import os
import common { Task, exec }
fn v_doctor() {
if common.is_github_job {
println('::group::vdoctor')
} else {
println('### vdoctor')
}
dump(os.getenv('PATH'))
exec('v doctor')
if common.is_github_job {
exec('uname -mrs')
exec('sysctl hw.model')
exec('sysctl hw.ncpu')
exec('sysctl hw.physmem')
exec('sysctl hw.usermem')
exec('whoami')
exec('pwd')
exec('ls -la')
exec('git log -n1')
exec('cc --version')
println('::endgroup::')
}
}
fn build_v_with_prealloc() {
if common.is_github_job {
println('::group::Build v with prealloc')
} else {
println('### Build v with prealloc')
}
exec('v -cg -cstrict -o vstrict1 cmd/v')
// -prealloc uses _Thread_local for g_memory_block; bundled tcc does not support it.
prealloc_cc_flag := if os.getenv('VFLAGS').contains('-cc tcc') { ' -cc cc' } else { '' }
exec('./vstrict1${prealloc_cc_flag} -o vprealloc -prealloc cmd/v')
exec('./vprealloc run examples/hello_world.v')
exec('./vprealloc -o v3 cmd/v')
exec('./v3 -o v4 cmd/v')
exec('./v4 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v')
if common.is_github_job {
println('::endgroup::')
}
}
fn verify_v_test_works() {
if common.is_github_job {
println('::group::Verify v test')
} else {
println('### Verify v test')
}
exec('echo \$VFLAGS')
exec('v cmd/tools/test_if_v_test_system_works.v')
exec('./cmd/tools/test_if_v_test_system_works')
if common.is_github_job {
println('::endgroup::')
}
}
fn build_fast_script() {
if common.is_github_job {
println('::group::Build fast script')
} else {
println('### Build fast script')
}
exec('cd cmd/tools/fast && v fast.v')
if common.is_github_job {
println('::endgroup::')
}
}
fn check_math() {
if common.is_github_job {
println('::group::Test vlib/math')
} else {
println('### Test vlib/math')
}
exec('v -silent test vlib/math')
println('Test the math module, using only the pure V versions,')
println(' without the .c.v overrides.')
exec('v -silent -exclude @vlib/math/*.c.v test vlib/math')
if common.is_github_job {
println('::endgroup::')
}
}
fn check_compress() {
if common.is_github_job {
println('::group::Test vlib/compress')
} else {
println('### Test vlib/compress')
}
exec('v -silent test vlib/compress')
if common.is_github_job {
println('::endgroup::')
}
}
fn test_inline_assembly() {
if common.is_github_job {
println('::group::Test inline Assembly')
} else {
println('### Test inline Assembly')
}
exec('v test vlib/v/slow_tests/assembly')
if common.is_github_job {
println('::endgroup::')
}
}
fn run_essential_tests() {
if common.is_github_job {
println('::group::Run essential tests')
exec('VTEST_JUST_ESSENTIAL=1 v -silent test-self')
println('::endgroup::')
} else {
println('### Run essential tests')
exec('VTEST_JUST_ESSENTIAL=1 v -progress test-self')
}
}
fn build_examples() {
if common.is_github_job {
println('::group::Build examples')
exec('v -W build-examples')
println('::endgroup::')
} else {
println('### Build examples')
exec('v -progress build-examples')
}
}
const all_tasks = {
'v_doctor': Task{v_doctor, 'Run v doctor'}
'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
'verify_v_test_works': Task{verify_v_test_works, 'Verify that v test works'}
'build_fast_script': Task{build_fast_script, 'Check that building fast.v works'}
'check_math': Task{check_math, 'Check the `math` module works'}
'check_compress': Task{check_compress, 'Check the `compress` module works'}
'test_inline_assembly': Task{test_inline_assembly, 'Test inline Assembly'}
'run_essential_tests': Task{run_essential_tests, 'Run only the essential tests'}
'build_examples': Task{build_examples, 'Build examples'}
}
common.run(all_tasks)