tools: fix `v build-tools`
parent
0ddf0a4b92
commit
cc1d313d68
|
@ -14,9 +14,11 @@ pub mut:
|
||||||
skip_files []string
|
skip_files []string
|
||||||
vexe string
|
vexe string
|
||||||
vroot string
|
vroot string
|
||||||
|
vtmp_dir string
|
||||||
vargs string
|
vargs string
|
||||||
failed bool
|
failed bool
|
||||||
benchmark benchmark.Benchmark
|
benchmark benchmark.Benchmark
|
||||||
|
rm_binaries bool = true
|
||||||
silent_mode bool
|
silent_mode bool
|
||||||
progress_mode bool
|
progress_mode bool
|
||||||
root_relative bool // used by CI runs, so that the output is stable everywhere
|
root_relative bool // used by CI runs, so that the output is stable everywhere
|
||||||
|
@ -102,11 +104,13 @@ pub fn new_test_session(_vargs string) TestSession {
|
||||||
}
|
}
|
||||||
vargs := _vargs.replace('-progress', '').replace('-progress', '')
|
vargs := _vargs.replace('-progress', '').replace('-progress', '')
|
||||||
vexe := pref.vexe_path()
|
vexe := pref.vexe_path()
|
||||||
|
new_vtmp_dir := setup_new_vtmp_folder()
|
||||||
return TestSession{
|
return TestSession{
|
||||||
vexe: vexe
|
vexe: vexe
|
||||||
vroot: os.dir(vexe)
|
vroot: os.dir(vexe)
|
||||||
skip_files: skip_files
|
skip_files: skip_files
|
||||||
vargs: vargs
|
vargs: vargs
|
||||||
|
vtmp_dir: new_vtmp_dir
|
||||||
silent_mode: _vargs.contains('-silent')
|
silent_mode: _vargs.contains('-silent')
|
||||||
progress_mode: _vargs.contains('-progress')
|
progress_mode: _vargs.contains('-progress')
|
||||||
}
|
}
|
||||||
|
@ -124,7 +128,6 @@ pub fn (mut ts TestSession) test() {
|
||||||
if current_wd == os.wd_at_startup && current_wd == ts.vroot {
|
if current_wd == os.wd_at_startup && current_wd == ts.vroot {
|
||||||
ts.root_relative = true
|
ts.root_relative = true
|
||||||
}
|
}
|
||||||
new_vtmp_dir := setup_new_vtmp_folder()
|
|
||||||
//
|
//
|
||||||
ts.init()
|
ts.init()
|
||||||
mut remaining_files := []string{}
|
mut remaining_files := []string{}
|
||||||
|
@ -174,13 +177,15 @@ pub fn (mut ts TestSession) test() {
|
||||||
eprintln(term.h_divider('-'))
|
eprintln(term.h_divider('-'))
|
||||||
// cleanup generated .tmp.c files after successfull tests:
|
// cleanup generated .tmp.c files after successfull tests:
|
||||||
if ts.benchmark.nfail == 0 {
|
if ts.benchmark.nfail == 0 {
|
||||||
os.rmdir_all(new_vtmp_dir)
|
if ts.rm_binaries {
|
||||||
|
os.rmdir_all(ts.vtmp_dir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn worker_trunner(mut p sync.PoolProcessor, idx int, thread_id int) voidptr {
|
fn worker_trunner(mut p sync.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
mut ts := &TestSession(p.get_shared_context())
|
mut ts := &TestSession(p.get_shared_context())
|
||||||
tmpd := os.temp_dir()
|
tmpd := ts.vtmp_dir
|
||||||
show_stats := '-stats' in ts.vargs.split(' ')
|
show_stats := '-stats' in ts.vargs.split(' ')
|
||||||
// tls_bench is used to format the step messages/timings
|
// tls_bench is used to format the step messages/timings
|
||||||
mut tls_bench := &benchmark.Benchmark(p.get_thread_context(idx))
|
mut tls_bench := &benchmark.Benchmark(p.get_thread_context(idx))
|
||||||
|
@ -203,14 +208,15 @@ fn worker_trunner(mut p sync.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
'') }
|
'') }
|
||||||
generated_binary_fpath := os.join_path(tmpd, generated_binary_fname)
|
generated_binary_fpath := os.join_path(tmpd, generated_binary_fname)
|
||||||
if os.exists(generated_binary_fpath) {
|
if os.exists(generated_binary_fpath) {
|
||||||
os.rm(generated_binary_fpath)
|
if ts.rm_binaries {
|
||||||
|
os.rm(generated_binary_fpath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mut cmd_options := [ts.vargs]
|
mut cmd_options := [ts.vargs]
|
||||||
if !ts.vargs.contains('fmt') {
|
if !ts.vargs.contains('fmt') {
|
||||||
cmd_options << ' -o "$generated_binary_fpath"'
|
cmd_options << ' -o "$generated_binary_fpath"'
|
||||||
}
|
}
|
||||||
cmd := '"$ts.vexe" ' + cmd_options.join(' ') + ' "$file"'
|
cmd := '"$ts.vexe" ' + cmd_options.join(' ') + ' "$file"'
|
||||||
// eprintln('>>> v cmd: $cmd')
|
|
||||||
ts.benchmark.step()
|
ts.benchmark.step()
|
||||||
tls_bench.step()
|
tls_bench.step()
|
||||||
if relative_file.replace('\\', '/') in ts.skip_files {
|
if relative_file.replace('\\', '/') in ts.skip_files {
|
||||||
|
@ -251,7 +257,9 @@ fn worker_trunner(mut p sync.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if os.exists(generated_binary_fpath) {
|
if os.exists(generated_binary_fpath) {
|
||||||
os.rm(generated_binary_fpath)
|
if ts.rm_binaries {
|
||||||
|
os.rm(generated_binary_fpath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sync.no_result
|
return sync.no_result
|
||||||
}
|
}
|
||||||
|
@ -268,9 +276,7 @@ pub fn v_build_failing(zargs string, folder string) bool {
|
||||||
return v_build_failing_skipped(zargs, folder, [])
|
return v_build_failing_skipped(zargs, folder, [])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string) bool {
|
pub fn prepare_test_session(zargs string, folder string, oskipped []string, main_label string) TestSession {
|
||||||
main_label := 'Building $folder ...'
|
|
||||||
finish_label := 'building $folder'
|
|
||||||
vexe := pref.vexe_path()
|
vexe := pref.vexe_path()
|
||||||
parent_dir := os.dir(vexe)
|
parent_dir := os.dir(vexe)
|
||||||
vlib_should_be_present(parent_dir)
|
vlib_should_be_present(parent_dir)
|
||||||
|
@ -314,6 +320,13 @@ pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string) b
|
||||||
}
|
}
|
||||||
session.files << mains
|
session.files << mains
|
||||||
session.skip_files << skipped
|
session.skip_files << skipped
|
||||||
|
return session
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string) bool {
|
||||||
|
main_label := 'Building $folder ...'
|
||||||
|
finish_label := 'building $folder'
|
||||||
|
mut session := prepare_test_session(zargs, folder, oskipped, main_label)
|
||||||
session.test()
|
session.test()
|
||||||
eprintln(session.benchmark.total_message(finish_label))
|
eprintln(session.benchmark.total_message(finish_label))
|
||||||
return session.failed
|
return session.failed
|
||||||
|
|
|
@ -4,13 +4,33 @@ import os
|
||||||
import testing
|
import testing
|
||||||
import v.util
|
import v.util
|
||||||
|
|
||||||
|
fn p(s string) string {
|
||||||
|
println(s)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
args := os.args
|
args := os.args
|
||||||
args_string := args[1..].join(' ')
|
args_string := args[1..].join(' ')
|
||||||
skips := []string{}
|
skips := []string{}
|
||||||
|
vexe := os.getenv('VEXE')
|
||||||
|
vroot := os.dir(vexe)
|
||||||
util.ensure_modules_for_all_tools_are_installed('-v' in args)
|
util.ensure_modules_for_all_tools_are_installed('-v' in args)
|
||||||
if testing.v_build_failing_skipped(args_string.all_before('build-tools'), 'cmd/tools',
|
folder := 'cmd/tools'
|
||||||
skips) {
|
main_label := 'Building $folder ...'
|
||||||
|
finish_label := 'building $folder'
|
||||||
|
mut session := testing.prepare_test_session(args_string.all_before('build-tools'), folder, skips, main_label)
|
||||||
|
session.rm_binaries = false
|
||||||
|
session.test()
|
||||||
|
eprintln(session.benchmark.total_message(finish_label))
|
||||||
|
if session.failed {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
mut executables := os.ls(session.vtmp_dir)?
|
||||||
|
executables.sort()
|
||||||
|
executables = executables.filter(it !in ['gen1m', 'gen_vc', 'fast', 'wyhash'])
|
||||||
|
for exe in executables {
|
||||||
|
os.mv_by_cp(os.join_path(session.vtmp_dir, exe), os.join_path(vroot, 'cmd', 'tools', exe))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue