2019-12-01 10:50:13 +01:00
|
|
|
module main
|
|
|
|
|
2020-04-26 08:32:05 +02:00
|
|
|
import os
|
|
|
|
import testing
|
2020-05-30 10:06:16 +02:00
|
|
|
import v.util
|
2019-12-01 10:50:13 +01:00
|
|
|
|
2022-03-06 18:01:22 +01:00
|
|
|
// Note: tools like vdoc are compiled in their own subfolder
|
2021-01-08 11:25:22 +01:00
|
|
|
// => cmd/tools/vdoc/vdoc.exe
|
|
|
|
// Usually, they have several top level .v files in the subfolder,
|
|
|
|
// that cannot be compiled separately, but instead, the whole folder,
|
|
|
|
// should be compiled (v folder).
|
|
|
|
// To implement that, these folders are initially skipped, then added
|
|
|
|
// as a whole *after the testing.prepare_test_session call*.
|
2021-05-28 18:54:44 +02:00
|
|
|
const tools_in_subfolders = ['vdoc', 'vvet', 'vast']
|
2021-01-08 11:25:22 +01:00
|
|
|
|
|
|
|
// non_packaged_tools are tools that should not be packaged with
|
|
|
|
// prebuild versions of V, to keep the size smaller.
|
|
|
|
// They are mainly usefull for the V project itself, not to end users.
|
|
|
|
const non_packaged_tools = ['gen1m', 'gen_vc', 'fast', 'wyhash']
|
2020-12-01 16:43:34 +01:00
|
|
|
|
2019-12-01 10:50:13 +01:00
|
|
|
fn main() {
|
2021-01-08 11:25:22 +01:00
|
|
|
util.ensure_modules_for_all_tools_are_installed('-v' in os.args)
|
2020-12-20 18:01:02 +01:00
|
|
|
args_string := os.args[1..].join(' ')
|
2020-12-01 16:43:34 +01:00
|
|
|
vexe := os.getenv('VEXE')
|
|
|
|
vroot := os.dir(vexe)
|
2021-08-28 11:44:03 +02:00
|
|
|
os.chdir(vroot) ?
|
2021-03-19 15:09:55 +01:00
|
|
|
folder := os.join_path('cmd', 'tools')
|
2021-01-08 11:25:22 +01:00
|
|
|
tfolder := os.join_path(vroot, 'cmd', 'tools')
|
2020-12-01 16:43:34 +01:00
|
|
|
main_label := 'Building $folder ...'
|
|
|
|
finish_label := 'building $folder'
|
2021-01-08 11:25:22 +01:00
|
|
|
//
|
|
|
|
mut skips := []string{}
|
|
|
|
for stool in tools_in_subfolders {
|
2022-05-04 22:30:44 +02:00
|
|
|
skips << os.join_path(tfolder, stool).replace('\\', '/')
|
2021-01-08 11:25:22 +01:00
|
|
|
}
|
|
|
|
buildopts := args_string.all_before('build-tools')
|
|
|
|
mut session := testing.prepare_test_session(buildopts, folder, skips, main_label)
|
2020-12-01 16:43:34 +01:00
|
|
|
session.rm_binaries = false
|
2021-01-08 11:25:22 +01:00
|
|
|
for stool in tools_in_subfolders {
|
|
|
|
session.add(os.join_path(tfolder, stool))
|
|
|
|
}
|
2021-03-19 15:26:07 +01:00
|
|
|
// eprintln('> session.files: $session.files')
|
|
|
|
// eprintln('> session.skip_files: $session.skip_files')
|
2020-12-01 16:43:34 +01:00
|
|
|
session.test()
|
|
|
|
eprintln(session.benchmark.total_message(finish_label))
|
|
|
|
if session.failed {
|
2019-12-01 10:50:13 +01:00
|
|
|
exit(1)
|
|
|
|
}
|
2020-12-01 16:43:34 +01:00
|
|
|
//
|
2020-12-20 18:01:02 +01:00
|
|
|
mut executables := os.ls(session.vtmp_dir) ?
|
2020-12-01 16:43:34 +01:00
|
|
|
executables.sort()
|
2021-01-08 11:25:22 +01:00
|
|
|
for texe in executables {
|
|
|
|
tname := texe.replace(os.file_ext(texe), '')
|
|
|
|
if tname in non_packaged_tools {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
//
|
|
|
|
tpath := os.join_path(session.vtmp_dir, texe)
|
2021-12-12 20:10:43 +01:00
|
|
|
if texe.ends_with('_builder') || texe.ends_with('_builder.exe') {
|
|
|
|
os.mv_by_cp(tpath, os.join_path(tfolder, 'builders', texe)) or { panic(err) }
|
|
|
|
continue
|
|
|
|
}
|
2021-01-08 11:25:22 +01:00
|
|
|
if tname in tools_in_subfolders {
|
2021-03-01 00:18:14 +01:00
|
|
|
os.mv_by_cp(tpath, os.join_path(tfolder, tname, texe)) or { panic(err) }
|
2021-01-26 15:43:10 +01:00
|
|
|
continue
|
|
|
|
}
|
2021-03-14 17:40:00 +01:00
|
|
|
target_path := os.join_path(tfolder, texe)
|
|
|
|
os.mv_by_cp(tpath, target_path) or {
|
2022-04-12 12:38:40 +02:00
|
|
|
emsg := err.msg()
|
|
|
|
if !emsg.contains('vbuild-tools') && !emsg.contains('vtest-all') {
|
|
|
|
eprintln('error while moving $tpath to $target_path: $emsg')
|
2021-01-26 15:43:10 +01:00
|
|
|
}
|
2021-01-08 11:25:22 +01:00
|
|
|
continue
|
|
|
|
}
|
2020-12-01 16:43:34 +01:00
|
|
|
}
|
2019-12-01 10:50:13 +01:00
|
|
|
}
|