From 9a0f4d846190c3e1a19a84902a58027b4a079dfb Mon Sep 17 00:00:00 2001 From: vlang-bot Date: Thu, 19 Sep 2024 13:51:27 +0300 Subject: [PATCH] tools: make fast.v and fast_job.v more self sufficient --- cmd/tools/fast/fast.v | 9 ++++++--- cmd/tools/fast/fast_job.v | 24 ++++++++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cmd/tools/fast/fast.v b/cmd/tools/fast/fast.v index 56f125fa171ea8..791392ebbeaa22 100644 --- a/cmd/tools/fast/fast.v +++ b/cmd/tools/fast/fast.v @@ -14,11 +14,11 @@ const discard_highest_samples = 16 const voptions = ' -skip-unused -show-timings -stats ' -const fast_dir = os.dir(@FILE) +const fast_dir = os.real_path(os.dir(@FILE)) -const fast_log_path = os.join_path(fast_dir, 'fast.log') +const fast_log_path = os.real_path(os.join_path(fast_dir, 'fast.log')) -const vdir = os.dir(os.dir(os.dir(fast_dir))) +const vdir = os.real_path(os.dir(os.dir(os.dir(fast_dir)))) fn elog(msg string) { line := '${time.now().format_ss_micro()} ${msg}\n' @@ -40,6 +40,9 @@ fn lexec(cmd string) string { } fn main() { + // ensure all log messages will be visible to the observers, even if the program panics + log.set_always_flush(true) + total_sw := time.new_stopwatch() elog('fast.html generator start') defer { diff --git a/cmd/tools/fast/fast_job.v b/cmd/tools/fast/fast_job.v index cc61161ad6bfe1..542bf01fde570b 100644 --- a/cmd/tools/fast/fast_job.v +++ b/cmd/tools/fast/fast_job.v @@ -31,6 +31,17 @@ fn delay() { time.sleep(sleep_period * time.second) } +fn check_output_repo(url string, branch string, folder string) { + if os.exists(folder) { + elog('Note: ${folder} already exists; using it.') + return + } + cmd := 'git clone --filter=blob:none --branch=${branch} ${url} ${folder}' + elog('Note: ${folder} is missing. Cloning to `${folder}`, with: `${cmd}` ...') + res := os.system(cmd) + elog('... cloning done, result: ${res}') +} + fn main() { elog('fast_job start setup ...') // ensure a more stable working environment for the used tools, independent on how this executable was started: @@ -48,14 +59,11 @@ fn main() { elog('fast_job end') } - if !os.exists('fast.vlang.io/') { - println('cloning the fast.vlang.io/ repo...') - os.system('git clone git@github.com:/vlang/website.git fast.vlang.io/') - } - if !os.exists('docs.vlang.io') { - println('cloning the docs.vlang.io/ repo...') - os.system('git clone git@github.com:/vlang/docs.git docs.vlang.io/') - } + elog('fast_job clone output repos...') + check_output_repo('https://github.com/vlang/website', 'gh-pages', 'fast.vlang.io/') + check_output_repo('https://github.com/vlang/docs/', 'main', 'docs.vlang.io/') + check_output_repo('https://github.com/vlang/docs/', 'generator', 'docs.vlang.io/docs_generator/') + mut i := 0 for { i++