mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
ci: fix v -o v2 -usecache cmd/v
after ad5b829
This commit is contained in:
parent
0a50715b03
commit
a0a83248e0
1 changed files with 16 additions and 3 deletions
19
cmd/v/v.v
19
cmd/v/v.v
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
@[has_globals]
|
||||
module main
|
||||
|
||||
import os
|
||||
|
@ -60,7 +59,15 @@ const external_tools = [
|
|||
]
|
||||
const list_of_flags_that_allow_duplicates = ['cc', 'd', 'define', 'cf', 'cflags']
|
||||
|
||||
__global timers = &util.Timers(unsafe { nil })
|
||||
@[unsafe]
|
||||
fn timers_pointer(p &util.Timers) &util.Timers {
|
||||
// TODO: the static variable here is used as a workaround for the current incompatibility of -usecache and globals in the main module:
|
||||
mut static ptimers := unsafe { &util.Timers(nil) }
|
||||
if p != unsafe { nil } {
|
||||
ptimers = p
|
||||
}
|
||||
return ptimers
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unbuffer_stdout()
|
||||
|
@ -71,12 +78,18 @@ fn main() {
|
|||
if '-show-timings' in os.args {
|
||||
timers_should_print = true
|
||||
}
|
||||
timers = util.new_timers(should_print: timers_should_print, label: 'main')
|
||||
mut timers := unsafe {
|
||||
timers_pointer(util.new_timers(
|
||||
should_print: timers_should_print
|
||||
label: 'main'
|
||||
))
|
||||
}
|
||||
timers.start('v start')
|
||||
timers.show('v start')
|
||||
timers.start('TOTAL')
|
||||
// use at_exit here, instead of defer, since some code paths later do early exit(0) or exit(1), for showing errors, or after `v run`
|
||||
at_exit(fn () {
|
||||
mut timers := unsafe { timers_pointer(nil) }
|
||||
timers.show('TOTAL')
|
||||
})!
|
||||
timers.start('v parsing CLI args')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue