mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
all: use arguments() instead of os.args in some files
This commit is contained in:
parent
0dd7698fd1
commit
a045bb0132
@ -6,6 +6,7 @@ import time
|
||||
import arrays
|
||||
import log
|
||||
|
||||
const args = arguments()
|
||||
const warmup_samples = 2
|
||||
|
||||
const max_samples = 20
|
||||
@ -54,7 +55,7 @@ fn main() {
|
||||
if vdir.contains('/tmp/cirrus-ci-build') {
|
||||
ccompiler_path = 'clang'
|
||||
}
|
||||
if os.args.contains('-clang') {
|
||||
if args.contains('-clang') {
|
||||
ccompiler_path = 'clang'
|
||||
}
|
||||
elog('fast_dir: ${fast_dir} | vdir: ${vdir} | compiler: ${ccompiler_path}')
|
||||
@ -68,7 +69,7 @@ fn main() {
|
||||
os.create('table.html')!
|
||||
}
|
||||
|
||||
if !os.args.contains('-noupdate') {
|
||||
if !args.contains('-noupdate') {
|
||||
elog('Fetching updates...')
|
||||
ret := lsystem('${vdir}/v up')
|
||||
if ret != 0 {
|
||||
@ -83,7 +84,7 @@ fn main() {
|
||||
uploaded_index := os.read_file('fast.vlang.io/index.html')!
|
||||
if uploaded_index.contains('>${commit}<') {
|
||||
elog('NOTE: commit ${commit} had been benchmarked already.')
|
||||
if !os.args.contains('-force') {
|
||||
if !args.contains('-force') {
|
||||
elog('nothing more to do')
|
||||
return
|
||||
}
|
||||
@ -98,21 +99,21 @@ fn main() {
|
||||
elog('Benchmarking commit ${commit} , with commit message: "${message}", commit_date: ${commit_date}, date: ${date}')
|
||||
|
||||
// build an optimized V
|
||||
if os.args.contains('-do-not-rebuild-vprod') {
|
||||
if args.contains('-do-not-rebuild-vprod') {
|
||||
if !os.exists('vprod') {
|
||||
elog('Exiting, since if you use `-do-not-rebuild-vprod`, you should already have a `${vdir}/vprod` executable, but it is missing!')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
elog(' Building vprod...')
|
||||
if os.args.contains('-noprod') {
|
||||
if args.contains('-noprod') {
|
||||
lexec('./v -o vprod cmd/v') // for faster debugging
|
||||
} else {
|
||||
lexec('./v -o vprod -prod -prealloc cmd/v')
|
||||
}
|
||||
}
|
||||
|
||||
if !os.args.contains('-do-not-rebuild-caches') {
|
||||
if !args.contains('-do-not-rebuild-caches') {
|
||||
elog('clearing caches...')
|
||||
// cache vlib modules
|
||||
lexec('${vdir}/v wipe-cache')
|
||||
@ -163,7 +164,7 @@ fn main() {
|
||||
res.close()
|
||||
|
||||
// upload the result to github pages
|
||||
if os.args.contains('-upload') {
|
||||
if args.contains('-upload') {
|
||||
$if freebsd {
|
||||
// Note: tcc currently can not compile vpm on FreeBSD, due to its dependence on net.ssl and net.mbedtls, so force using clang instead:
|
||||
elog('FreeBSD: compiling the VPM tool with clang...')
|
||||
|
@ -4,7 +4,8 @@ import os
|
||||
import os.cmdline
|
||||
import v.util.recompilation
|
||||
|
||||
const is_debug = os.args.contains('-debug')
|
||||
const args_ = arguments()
|
||||
const is_debug = args_.contains('-debug')
|
||||
|
||||
// support a renamed `v` executable too:
|
||||
const vexe = os.getenv_opt('VEXE') or { @VEXE }
|
||||
@ -24,7 +25,7 @@ fn main() {
|
||||
recompilation.must_be_enabled(vroot, 'Please install V from source, to use `${vexe_name} self` .')
|
||||
os.chdir(vroot)!
|
||||
os.setenv('VCOLORS', 'always', true)
|
||||
mut args := os.args[1..].filter(it != 'self')
|
||||
mut args := args_[1..].filter(it != 'self')
|
||||
if args.len == 0 || ('-cc' !in args && '-prod' !in args && '-parallel-cc' !in args) {
|
||||
// compiling by default, i.e. `v self`:
|
||||
uos := os.user_os()
|
||||
|
@ -18,14 +18,16 @@ struct App {
|
||||
skip_current bool // skip the current hash check, enabling easier testing on the same commit, without using docker etc
|
||||
}
|
||||
|
||||
const args = arguments()
|
||||
|
||||
fn new_app() App {
|
||||
return App{
|
||||
is_verbose: '-v' in os.args
|
||||
is_prod: '-prod' in os.args
|
||||
is_verbose: '-v' in args
|
||||
is_prod: '-prod' in args
|
||||
vexe: vexe
|
||||
vroot: vroot
|
||||
skip_v_self: '-skip_v_self' in os.args
|
||||
skip_current: '-skip_current' in os.args
|
||||
skip_v_self: '-skip_v_self' in args
|
||||
skip_current: '-skip_current' in args
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,19 @@
|
||||
// This program displays the fibonacci sequence
|
||||
import os
|
||||
const args = arguments()
|
||||
|
||||
fn main() {
|
||||
// Check for user input
|
||||
if os.args.len != 2 {
|
||||
if args.len != 2 {
|
||||
println('usage: fibonacci [rank]')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Parse first argument and cast it to int
|
||||
|
||||
stop := os.args[1].int()
|
||||
stop := args[1].int()
|
||||
// Can only calculate correctly until rank 92
|
||||
if stop > 92 {
|
||||
println('rank must be 92 or less')
|
||||
return
|
||||
}
|
||||
|
||||
// Three consecutive terms of the sequence
|
||||
mut a := i64(0)
|
||||
mut b := i64(0)
|
||||
@ -29,7 +25,6 @@ fn main() {
|
||||
b = c
|
||||
// Compute the new term
|
||||
c = a + b
|
||||
|
||||
// Print the new term
|
||||
println(c)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user