Skip to content

Commit

Permalink
tools: make fast.v and fast_job.v more self sufficient
Browse files Browse the repository at this point in the history
  • Loading branch information
vlang-bot committed Sep 19, 2024
1 parent 24088a7 commit 9a0f4d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 6 additions & 3 deletions cmd/tools/fast/fast.v
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 {
Expand Down
24 changes: 16 additions & 8 deletions cmd/tools/fast/fast_job.v
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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++
Expand Down

0 comments on commit 9a0f4d8

Please sign in to comment.