mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: deprecate os.exec (returning ?os.Result), in favour of os.execute, which returns os.Result (#8974)
This commit is contained in:
@ -50,7 +50,7 @@ fn main() {
|
||||
date := time.unix(commit_date.int())
|
||||
mut out := os.create('table.html') ?
|
||||
// Place the new row on top
|
||||
table =
|
||||
table =
|
||||
'<tr>
|
||||
<td>$date.format()</td>
|
||||
<td><a target=_blank href="https://github.com/vlang/v/commit/$commit">$commit</a></td>
|
||||
@ -81,7 +81,7 @@ fn main() {
|
||||
}
|
||||
|
||||
fn exec(s string) string {
|
||||
e := os.exec(s) or { panic(err) }
|
||||
e := os.execute_or_panic(s)
|
||||
return e.output.trim_right('\r\n')
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ fn measure(cmd string, description string) int {
|
||||
}
|
||||
|
||||
fn measure_steps(vdir string) (int, int, int) {
|
||||
resp := os.exec('$vdir/vprod -o v.c -show-timings $vdir/cmd/v') or { panic(err) }
|
||||
resp := os.execute_or_panic('$vdir/vprod -o v.c -show-timings $vdir/cmd/v')
|
||||
lines := resp.output.split_into_lines()
|
||||
if lines.len != 3 {
|
||||
return 0, 0, 0
|
||||
|
@ -17,20 +17,22 @@ fn main() {
|
||||
return
|
||||
}
|
||||
for {
|
||||
os.exec('git pull --rebase') or {
|
||||
res_pull := os.execute('git pull --rebase')
|
||||
if res_pull.exit_code != 0 {
|
||||
println('failed to git pull. uncommitted changes?')
|
||||
return
|
||||
}
|
||||
// println('running fast')
|
||||
resp := os.exec('./fast') or {
|
||||
println(err)
|
||||
resp := os.execute('./fast')
|
||||
if resp.exit_code < 0 {
|
||||
println(resp.output)
|
||||
return
|
||||
}
|
||||
if resp.exit_code != 0 {
|
||||
println('resp != 0, skipping')
|
||||
} else {
|
||||
os.chdir('website')
|
||||
os.exec('git checkout gh-pages') ?
|
||||
os.execute_or_panic('git checkout gh-pages')
|
||||
os.cp('../index.html', 'index.html') ?
|
||||
os.system('git commit -am "update benchmark"')
|
||||
os.system('git push origin gh-pages')
|
||||
|
@ -43,13 +43,13 @@ const (
|
||||
// version
|
||||
app_version = '0.1.2'
|
||||
// description
|
||||
app_description = "This tool regenerates V\'s bootstrap .c files every time the V master branch is updated."
|
||||
app_description = "This tool regenerates V's bootstrap .c files every time the V master branch is updated."
|
||||
// assume something went wrong if file size less than this
|
||||
too_short_file_limit = 5000
|
||||
// create a .c file for these os's
|
||||
vc_build_oses = [
|
||||
'nix',
|
||||
/* all nix based os */
|
||||
// all nix based os
|
||||
'windows',
|
||||
]
|
||||
)
|
||||
@ -188,8 +188,8 @@ fn parse_flags(mut fp flag.FlagParser) FlagOptions {
|
||||
work_dir: fp.string('work-dir', 0, work_dir, 'gen_vc working directory')
|
||||
purge: fp.bool('purge', 0, false, 'force purge the local repositories')
|
||||
port: fp.int('port', 0, server_port, 'port for web server to listen on')
|
||||
log_to: fp.string('log-to', 0, log_to, "log to is \'file\' or \'terminal\'")
|
||||
log_file: fp.string('log-file', 0, log_file, "log file to use when log-to is \'file\'")
|
||||
log_to: fp.string('log-to', 0, log_to, "log to is 'file' or 'terminal'")
|
||||
log_file: fp.string('log-file', 0, log_file, "log file to use when log-to is 'file'")
|
||||
dry_run: fp.bool('dry-run', 0, dry_run, 'when specified dont push anything to remote repo')
|
||||
force: fp.bool('force', 0, false, 'force update even if already up to date')
|
||||
}
|
||||
@ -318,9 +318,10 @@ fn (mut gen_vc GenVC) command_execute(cmd string, dry bool) string {
|
||||
return gen_vc.command_execute_dry(cmd)
|
||||
}
|
||||
gen_vc.logger.info('cmd: $cmd')
|
||||
r := os.exec(cmd) or {
|
||||
r := os.execute(cmd)
|
||||
if r.exit_code < 0 {
|
||||
gen_vc.logger.error('$err_msg_cmd_x: "$cmd" could not start.')
|
||||
gen_vc.logger.error(err.msg)
|
||||
gen_vc.logger.error(r.output)
|
||||
// something went wrong, better start fresh next time
|
||||
gen_vc.purge_repos()
|
||||
gen_vc.gen_error = true
|
||||
|
@ -60,19 +60,23 @@ pub fn rmrf(path string) {
|
||||
}
|
||||
}
|
||||
|
||||
// execute a command, and return a result, or an error, if it failed in any way.
|
||||
pub fn exec(cmd string) ?os.Result {
|
||||
verbose_trace(@FN, cmd)
|
||||
x := os.exec(cmd) or {
|
||||
x := os.execute(cmd)
|
||||
if x.exit_code != 0 {
|
||||
verbose_trace(@FN, '## failed.')
|
||||
return err
|
||||
return error(x.output)
|
||||
}
|
||||
verbose_trace_exec_result(x)
|
||||
return x
|
||||
}
|
||||
|
||||
// run a command, tracing its results, and returning ONLY its output
|
||||
pub fn run(cmd string) string {
|
||||
verbose_trace(@FN, cmd)
|
||||
x := os.exec(cmd) or {
|
||||
x := os.execute(cmd)
|
||||
if x.exit_code < 0 {
|
||||
verbose_trace(@FN, '## failed.')
|
||||
return ''
|
||||
}
|
||||
@ -85,7 +89,8 @@ pub fn run(cmd string) string {
|
||||
|
||||
pub fn exit_0_status(cmd string) bool {
|
||||
verbose_trace(@FN, cmd)
|
||||
x := os.exec(cmd) or {
|
||||
x := os.execute(cmd)
|
||||
if x.exit_code < 0 {
|
||||
verbose_trace(@FN, '## failed.')
|
||||
return false
|
||||
}
|
||||
|
@ -287,7 +287,8 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
if testing.show_start {
|
||||
ts.append_message(.info, ' starting $relative_file ...')
|
||||
}
|
||||
r := os.exec(cmd) or {
|
||||
r := os.execute(cmd)
|
||||
if r.exit_code < 0 {
|
||||
ts.failed = true
|
||||
ts.benchmark.fail()
|
||||
tls_bench.fail()
|
||||
@ -387,7 +388,10 @@ pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string) b
|
||||
}
|
||||
|
||||
pub fn build_v_cmd_failed(cmd string) bool {
|
||||
res := os.exec(cmd) or { return true }
|
||||
res := os.execute(cmd)
|
||||
if res.exit_code < 0 {
|
||||
return true
|
||||
}
|
||||
if res.exit_code != 0 {
|
||||
eprintln('')
|
||||
eprintln(res.output)
|
||||
|
@ -29,10 +29,10 @@ const (
|
||||
|
||||
struct Context {
|
||||
mut:
|
||||
vgo vgit.VGitOptions
|
||||
commit_v string = 'master'
|
||||
vgo vgit.VGitOptions
|
||||
commit_v string = 'master'
|
||||
// the commit from which you want to produce a working v compiler (this may be a commit-ish too)
|
||||
commit_vc string = 'master'
|
||||
commit_vc string = 'master'
|
||||
// this will be derived from commit_v
|
||||
commit_v_hash string // this will be filled from the commit-ish commit_v using rev-list. It IS a commit hash.
|
||||
path_v string // the full path to the v folder inside workdir.
|
||||
@ -40,7 +40,7 @@ mut:
|
||||
cmd_to_run string // the command that you want to run *in* the oldv repo
|
||||
cc string = 'cc'
|
||||
// the C compiler to use for bootstrapping.
|
||||
cleanup bool // should the tool run a cleanup first
|
||||
cleanup bool // should the tool run a cleanup first
|
||||
}
|
||||
|
||||
fn (mut c Context) compile_oldv_if_needed() {
|
||||
@ -100,9 +100,7 @@ fn main() {
|
||||
scripting.cprintln('# v commit hash: $context.commit_v_hash')
|
||||
scripting.cprintln('# checkout folder: $context.path_v')
|
||||
if context.cmd_to_run.len > 0 {
|
||||
cmdres := os.exec(context.cmd_to_run) or {
|
||||
panic(err)
|
||||
}
|
||||
cmdres := os.execute_or_panic(context.cmd_to_run)
|
||||
scripting.cprintln('# command: ${context.cmd_to_run:-34s} exit code: ${cmdres.exit_code:-4d} result:')
|
||||
println(cmdres.output)
|
||||
exit(cmdres.exit_code)
|
||||
|
@ -42,7 +42,7 @@ mut:
|
||||
}
|
||||
|
||||
struct Aints {
|
||||
values []int
|
||||
values []int
|
||||
mut:
|
||||
imin int
|
||||
imax int
|
||||
@ -206,7 +206,10 @@ fn (mut context Context) run() {
|
||||
for i in 1 .. context.warmup + 1 {
|
||||
print('${context.cgoback}warming up run: ${i:4}/${context.warmup:-4} for ${cmd:-50s} took ${duration:6} ms ...')
|
||||
mut sw := time.new_stopwatch({})
|
||||
os.exec(cmd) or { continue }
|
||||
res := os.execute(cmd)
|
||||
if res.exit_code != 0 {
|
||||
continue
|
||||
}
|
||||
duration = int(sw.elapsed().milliseconds())
|
||||
}
|
||||
run_warmups++
|
||||
@ -225,8 +228,8 @@ fn (mut context Context) run() {
|
||||
eprintln('${i:10} non 0 exit code for cmd: $cmd')
|
||||
continue
|
||||
}
|
||||
context.results[icmd].outputs <<
|
||||
res.output.trim_right('\r\n').replace('\r\n', '\n').split('\n')
|
||||
context.results[icmd].outputs << res.output.trim_right('\r\n').replace('\r\n',
|
||||
'\n').split('\n')
|
||||
context.results[icmd].timings << duration
|
||||
sum += duration
|
||||
runs++
|
||||
|
@ -55,7 +55,7 @@ fn main() {
|
||||
|
||||
fn check_ok(cmd string) string {
|
||||
println('> check_ok cmd: $cmd')
|
||||
res := os.exec(cmd) or { panic(err) }
|
||||
res := os.execute(cmd)
|
||||
if res.exit_code != 0 {
|
||||
eprintln('> check_ok failed.\n$res.output')
|
||||
exit(1)
|
||||
@ -65,7 +65,7 @@ fn check_ok(cmd string) string {
|
||||
|
||||
fn check_fail(cmd string) string {
|
||||
println('> check_fail cmd: $cmd')
|
||||
res := os.exec(cmd) or { panic(err) }
|
||||
res := os.execute(cmd)
|
||||
if res.exit_code == 0 {
|
||||
eprintln('> check_fail succeeded, but it should have failed.\n$res.output')
|
||||
exit(1)
|
||||
|
@ -211,7 +211,10 @@ fn (mut f MDFile) debug() {
|
||||
}
|
||||
|
||||
fn cmdexecute(cmd string) int {
|
||||
res := os.exec(cmd) or { return 1 }
|
||||
res := os.execute(cmd)
|
||||
if res.exit_code < 0 {
|
||||
return 1
|
||||
}
|
||||
if res.exit_code != 0 {
|
||||
eprint(res.output)
|
||||
}
|
||||
@ -219,7 +222,7 @@ fn cmdexecute(cmd string) int {
|
||||
}
|
||||
|
||||
fn silent_cmdexecute(cmd string) int {
|
||||
res := os.exec(cmd) or { return 1 }
|
||||
res := os.execute(cmd)
|
||||
return res.exit_code
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,8 @@ fn (c &Create) write_main(new bool) {
|
||||
fn (c &Create) create_git_repo(dir string) {
|
||||
// Create Git Repo and .gitignore file
|
||||
if !os.is_dir('$dir/.git') {
|
||||
os.exec('git init $dir') or {
|
||||
res := os.execute('git init $dir')
|
||||
if res.exit_code != 0 {
|
||||
cerror('Unable to create git repo')
|
||||
exit(4)
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ fn (mut a App) collect_info() {
|
||||
arch_details << 'little endian'
|
||||
}
|
||||
if os_kind == 'macos' {
|
||||
arch_details << a.cmd({
|
||||
arch_details << a.cmd(
|
||||
command: 'sysctl -n machdep.cpu.brand_string'
|
||||
})
|
||||
)
|
||||
}
|
||||
if os_kind == 'linux' {
|
||||
mut cpu_details := ''
|
||||
@ -48,16 +48,16 @@ fn (mut a App) collect_info() {
|
||||
arch_details << cpu_details
|
||||
}
|
||||
if os_kind == 'windows' {
|
||||
arch_details << a.cmd({
|
||||
arch_details << a.cmd(
|
||||
command: 'wmic cpu get name /format:table'
|
||||
line: 1
|
||||
})
|
||||
)
|
||||
}
|
||||
//
|
||||
mut os_details := ''
|
||||
wsl_check := a.cmd({
|
||||
wsl_check := a.cmd(
|
||||
command: 'cat /proc/sys/kernel/osrelease'
|
||||
})
|
||||
)
|
||||
if os_kind == 'linux' {
|
||||
os_details = a.get_linux_os_name()
|
||||
if 'hypervisor' in a.cpu_info('flags') {
|
||||
@ -75,26 +75,27 @@ fn (mut a App) collect_info() {
|
||||
os_details += ' (WSL)'
|
||||
}
|
||||
// From https://unix.stackexchange.com/a/14346
|
||||
if a.cmd(command: '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?') == '0' {
|
||||
awk_cmd := '[ "$(awk \'\$5=="/" {print \$1}\' </proc/1/mountinfo)" != "$(awk \'\$5=="/" {print \$1}\' </proc/$$/mountinfo)" ] ; echo \$?'
|
||||
if a.cmd(command: awk_cmd) == '0' {
|
||||
os_details += ' (chroot)'
|
||||
}
|
||||
} else if os_kind == 'macos' {
|
||||
mut details := []string{}
|
||||
details << a.cmd({
|
||||
details << a.cmd(
|
||||
command: 'sw_vers -productName'
|
||||
})
|
||||
details << a.cmd({
|
||||
)
|
||||
details << a.cmd(
|
||||
command: 'sw_vers -productVersion'
|
||||
})
|
||||
details << a.cmd({
|
||||
)
|
||||
details << a.cmd(
|
||||
command: 'sw_vers -buildVersion'
|
||||
})
|
||||
)
|
||||
os_details = details.join(', ')
|
||||
} else if os_kind == 'windows' {
|
||||
wmic_info := a.cmd({
|
||||
wmic_info := a.cmd(
|
||||
command: 'wmic os get * /format:value'
|
||||
line: -1
|
||||
})
|
||||
)
|
||||
p := a.parse(wmic_info, '=')
|
||||
caption, build_number, os_arch := p['caption'], p['buildnumber'], p['osarchitecture']
|
||||
os_details = '$caption v$build_number $os_arch'
|
||||
@ -104,15 +105,15 @@ fn (mut a App) collect_info() {
|
||||
}
|
||||
a.line('OS', '$os_kind, $os_details')
|
||||
a.line('Processor', arch_details.join(', '))
|
||||
a.line('CC version', a.cmd({
|
||||
a.line('CC version', a.cmd(
|
||||
command: 'cc --version'
|
||||
}))
|
||||
))
|
||||
a.println('')
|
||||
getwd := os.getwd()
|
||||
vmodules := os.vmodules_dir()
|
||||
vexe := os.getenv('VEXE')
|
||||
vroot := os.dir(vexe)
|
||||
os.chdir(vroot)
|
||||
os.chdir(vroot)
|
||||
a.line('getwd', getwd)
|
||||
a.line('vmodules', vmodules)
|
||||
a.line('vroot', vroot)
|
||||
@ -130,9 +131,9 @@ fn (mut a App) collect_info() {
|
||||
a.line('env VFLAGS', '"$vflags"')
|
||||
}
|
||||
a.println('')
|
||||
a.line('Git version', a.cmd({
|
||||
a.line('Git version', a.cmd(
|
||||
command: 'git --version'
|
||||
}))
|
||||
))
|
||||
a.line('Git vroot status', a.git_info())
|
||||
a.line('.git/config present', os.is_file('.git/config').str())
|
||||
//
|
||||
@ -145,7 +146,8 @@ struct CmdConfig {
|
||||
}
|
||||
|
||||
fn (mut a App) cmd(c CmdConfig) string {
|
||||
x := os.exec(c.command) or {
|
||||
x := os.execute(c.command)
|
||||
if x.exit_code < 0 {
|
||||
return 'N/A'
|
||||
}
|
||||
if x.exit_code == 0 {
|
||||
@ -189,9 +191,7 @@ fn (mut a App) get_linux_os_name() string {
|
||||
if !os.is_file('/etc/os-release') {
|
||||
continue
|
||||
}
|
||||
lines := os.read_file('/etc/os-release') or {
|
||||
continue
|
||||
}
|
||||
lines := os.read_file('/etc/os-release') or { continue }
|
||||
vals := a.parse(lines, '=')
|
||||
if vals['PRETTY_NAME'] == '' {
|
||||
continue
|
||||
@ -200,24 +200,24 @@ fn (mut a App) get_linux_os_name() string {
|
||||
break
|
||||
}
|
||||
'lsb_release' {
|
||||
exists := a.cmd({
|
||||
exists := a.cmd(
|
||||
command: 'type lsb_release'
|
||||
})
|
||||
)
|
||||
if exists.starts_with('Error') {
|
||||
continue
|
||||
}
|
||||
os_details = a.cmd({
|
||||
os_details = a.cmd(
|
||||
command: 'lsb_release -d -s'
|
||||
})
|
||||
)
|
||||
break
|
||||
}
|
||||
'kernel' {
|
||||
if !os.is_file('/proc/version') {
|
||||
continue
|
||||
}
|
||||
os_details = a.cmd({
|
||||
os_details = a.cmd(
|
||||
command: 'cat /proc/version'
|
||||
})
|
||||
)
|
||||
break
|
||||
}
|
||||
'uname' {
|
||||
@ -235,22 +235,23 @@ fn (mut a App) cpu_info(key string) string {
|
||||
if a.cached_cpuinfo.len > 0 {
|
||||
return a.cached_cpuinfo[key]
|
||||
}
|
||||
info := os.exec('cat /proc/cpuinfo') or {
|
||||
return a.cached_cpuinfo[key]
|
||||
info := os.execute('cat /proc/cpuinfo')
|
||||
if info.exit_code != 0 {
|
||||
return '`cat /proc/cpuinfo` could not run'
|
||||
}
|
||||
a.cached_cpuinfo = a.parse(info.output, ':')
|
||||
return a.cached_cpuinfo[key]
|
||||
}
|
||||
|
||||
fn (mut a App) git_info() string {
|
||||
mut out := a.cmd({
|
||||
mut out := a.cmd(
|
||||
command: 'git -C . describe --abbrev=8 --dirty --always --tags'
|
||||
}).trim_space()
|
||||
os.exec('git -C . remote add V_REPO https://github.com/vlang/v') or { } // ignore failure (i.e. remote exists)
|
||||
os.exec('git -C . fetch V_REPO') or { }
|
||||
commit_count := a.cmd({
|
||||
).trim_space()
|
||||
os.execute('git -C . remote add V_REPO https://github.com/vlang/v') // ignore failure (i.e. remote exists)
|
||||
os.execute('git -C . fetch V_REPO')
|
||||
commit_count := a.cmd(
|
||||
command: 'git rev-list @{0}...V_REPO/master --right-only --count'
|
||||
}).int()
|
||||
).int()
|
||||
if commit_count > 0 {
|
||||
out += ' ($commit_count commit(s) behind V master)'
|
||||
}
|
||||
@ -262,12 +263,12 @@ fn (mut a App) report_tcc_version(tccfolder string) {
|
||||
a.line(tccfolder, 'N/A')
|
||||
return
|
||||
}
|
||||
tcc_branch_name := a.cmd({
|
||||
tcc_branch_name := a.cmd(
|
||||
command: 'git -C $tccfolder rev-parse --abbrev-ref HEAD'
|
||||
})
|
||||
tcc_commit := a.cmd({
|
||||
)
|
||||
tcc_commit := a.cmd(
|
||||
command: 'git -C $tccfolder describe --abbrev=8 --dirty --always --tags'
|
||||
})
|
||||
)
|
||||
a.line('$tccfolder status', '$tcc_branch_name $tcc_commit')
|
||||
}
|
||||
|
||||
@ -278,9 +279,7 @@ fn (mut a App) report_info() {
|
||||
}
|
||||
|
||||
fn is_writable_dir(path string) bool {
|
||||
res := os.is_writable_folder(path) or {
|
||||
false
|
||||
}
|
||||
res := os.is_writable_folder(path) or { false }
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,8 @@ fn main() {
|
||||
if foptions.is_verbose {
|
||||
eprintln('vfmt worker_cmd: $worker_cmd')
|
||||
}
|
||||
worker_result := os.exec(worker_cmd) or {
|
||||
worker_result := os.execute(worker_cmd)
|
||||
if worker_result.exit_code != 0 {
|
||||
errors++
|
||||
continue
|
||||
}
|
||||
@ -277,7 +278,7 @@ fn (foptions &FormatOptions) post_process_file(file string, formatted_file_path
|
||||
}
|
||||
|
||||
fn (f FormatOptions) str() string {
|
||||
return
|
||||
return
|
||||
'FormatOptions{ is_l: $f.is_l, is_w: $f.is_w, is_diff: $f.is_diff, is_verbose: $f.is_verbose,' +
|
||||
' is_all: $f.is_all, is_worker: $f.is_worker, is_debug: $f.is_debug, is_noerror: $f.is_noerror,' +
|
||||
' is_verify: $f.is_verify" }'
|
||||
|
@ -193,13 +193,7 @@ fn vpm_install(module_names []string) {
|
||||
vcs_install_cmd := supported_vcs_install_cmds[vcs]
|
||||
cmd := '$vcs_install_cmd "$mod.url" "$final_module_path"'
|
||||
verbose_println(' command: $cmd')
|
||||
cmdres := os.exec(cmd) or {
|
||||
errors++
|
||||
println('Could not install module "$name" to "$final_module_path" .')
|
||||
verbose_println('Error command: $cmd')
|
||||
verbose_println('Error details: $err')
|
||||
continue
|
||||
}
|
||||
cmdres := os.execute(cmd)
|
||||
if cmdres.exit_code != 0 {
|
||||
errors++
|
||||
println('Failed installing module "$name" to "$final_module_path" .')
|
||||
@ -232,13 +226,7 @@ fn vpm_update(m []string) {
|
||||
vcs := vcs_used_in_dir(final_module_path) or { continue }
|
||||
vcs_cmd := supported_vcs_update_cmds[vcs[0]]
|
||||
verbose_println(' command: $vcs_cmd')
|
||||
vcs_res := os.exec('$vcs_cmd') or {
|
||||
errors++
|
||||
println('Could not update module "$name".')
|
||||
verbose_println('Error command: $vcs_cmd')
|
||||
verbose_println('Error details:\n$err')
|
||||
continue
|
||||
}
|
||||
vcs_res := os.execute('$vcs_cmd')
|
||||
if vcs_res.exit_code != 0 {
|
||||
errors++
|
||||
println('Failed updating module "$name".')
|
||||
@ -265,9 +253,10 @@ fn get_outdated() ?[]string {
|
||||
vcs_cmd_steps := supported_vcs_outdated_steps[vcs[0]]
|
||||
mut outputs := []string{}
|
||||
for step in vcs_cmd_steps {
|
||||
res := os.exec(step) or {
|
||||
res := os.execute(step)
|
||||
if res.exit_code < 0 {
|
||||
verbose_println('Error command: $step')
|
||||
verbose_println('Error details:\n$err')
|
||||
verbose_println('Error details:\n$res.output')
|
||||
return error('Error while checking latest commits for "$name".')
|
||||
}
|
||||
if vcs[0] == 'hg' {
|
||||
|
@ -381,9 +381,10 @@ fn repl_run_vfile(file string) ?os.Result {
|
||||
$if trace_repl_temp_files ? {
|
||||
eprintln('>> repl_run_vfile file: $file')
|
||||
}
|
||||
s := os.exec('"$vexe" -repl run "$file"') or {
|
||||
rerror(err.msg)
|
||||
return err
|
||||
s := os.execute('"$vexe" -repl run "$file"')
|
||||
if s.exit_code < 0 {
|
||||
rerror(s.output)
|
||||
return error(s.output)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ fn main() {
|
||||
}
|
||||
|
||||
fn compile(vroot string, cmd string) {
|
||||
result := os.exec(cmd) or { panic(err) }
|
||||
result := os.execute_or_panic(cmd)
|
||||
if result.exit_code != 0 {
|
||||
eprintln('cannot compile to `$vroot`: \n$result.output')
|
||||
exit(1)
|
||||
|
@ -3,16 +3,21 @@ module main
|
||||
import os
|
||||
import v.pref
|
||||
|
||||
const freetype_repo_url = 'https://github.com/ubawurinna/freetype-windows-binaries'
|
||||
|
||||
const freetype_folder = os.join_path('thirdparty', 'freetype')
|
||||
|
||||
fn main() {
|
||||
$if windows {
|
||||
println('Setup freetype...')
|
||||
vroot := os.dir(pref.vexe_path())
|
||||
os.chdir(vroot)
|
||||
if os.is_dir('./thirdparty/freetype') {
|
||||
if os.is_dir(freetype_folder) {
|
||||
println('Thirdparty "freetype" is already installed.')
|
||||
} else {
|
||||
s := os.exec('git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries ./thirdparty/freetype/') or {
|
||||
panic(err)
|
||||
s := os.execute('git clone --depth=1 $freetype_repo_url $freetype_folder')
|
||||
if s.exit_code != 0 {
|
||||
panic(s.output)
|
||||
}
|
||||
println(s.output)
|
||||
println('Thirdparty "freetype" installed successfully.')
|
||||
|
@ -31,7 +31,7 @@ fn setup_symlink_unix(vexe string) {
|
||||
}
|
||||
link_path = link_dir + '/v'
|
||||
}
|
||||
ret := os.exec('ln -sf $vexe $link_path') or { panic(err) }
|
||||
ret := os.execute_or_panic('ln -sf $vexe $link_path')
|
||||
if ret.exit_code == 0 {
|
||||
println('Symlink "$link_path" has been created')
|
||||
} else {
|
||||
|
@ -13,11 +13,10 @@ const (
|
||||
support_color = term.can_show_color_on_stderr() && term.can_show_color_on_stdout()
|
||||
ecode_timeout = 101
|
||||
ecode_memout = 102
|
||||
ecode_exec = 103
|
||||
ecode_details = map{
|
||||
'101': 'too slow'
|
||||
'102': 'too memory hungry'
|
||||
'103': 'worker executable not found'
|
||||
-1: 'worker executable not found'
|
||||
101: 'too slow'
|
||||
102: 'too memory hungry'
|
||||
}
|
||||
)
|
||||
|
||||
@ -217,10 +216,7 @@ fn (mut context Context) process_whole_file_in_worker(path string) (int, int) {
|
||||
context.cut_index = i // needed for the progress bar
|
||||
cmd := '"$context.myself" $verbosity --worker --timeout_ms ${context.timeout_ms:5} --cut_index ${i:5} --path "$path" '
|
||||
context.log(cmd)
|
||||
res := os.exec(cmd) or { os.Result{
|
||||
output: err.msg
|
||||
exit_code: ecode_exec
|
||||
} }
|
||||
mut res := os.execute(cmd)
|
||||
context.log('worker exit_code: $res.exit_code | worker output:\n$res.output')
|
||||
if res.exit_code != 0 {
|
||||
fails++
|
||||
@ -236,7 +232,7 @@ fn (mut context Context) process_whole_file_in_worker(path string) (int, int) {
|
||||
err := if is_panic {
|
||||
red('parser failure: panic')
|
||||
} else {
|
||||
red('parser failure: crash, ${ecode_details[res.exit_code.str()]}')
|
||||
red('parser failure: crash, ${ecode_details[res.exit_code]}')
|
||||
}
|
||||
path_to_line := bold('$path:$line:$col:')
|
||||
err_line := last_line.trim_left('\t')
|
||||
|
@ -41,7 +41,7 @@ fn main() {
|
||||
app.backup('cmd/tools/vup.exe')
|
||||
}
|
||||
app.recompile_v()
|
||||
os.exec('"$app.vexe" cmd/tools/vup.v') or { panic(err) }
|
||||
os.execute_or_panic('"$app.vexe" cmd/tools/vup.v')
|
||||
app.show_current_v_version()
|
||||
}
|
||||
|
||||
@ -71,14 +71,13 @@ fn (app App) recompile_v() {
|
||||
opts := if app.is_prod { '-prod' } else { '' }
|
||||
vself := '"$app.vexe" $opts self'
|
||||
app.vprintln('> recompiling v itself with `$vself` ...')
|
||||
if self_result := os.exec(vself) {
|
||||
if self_result.exit_code == 0 {
|
||||
println(self_result.output.trim_space())
|
||||
return
|
||||
} else {
|
||||
app.vprintln('`$vself` failed, running `make`...')
|
||||
app.vprintln(self_result.output.trim_space())
|
||||
}
|
||||
self_result := os.execute(vself)
|
||||
if self_result.exit_code == 0 {
|
||||
println(self_result.output.trim_space())
|
||||
return
|
||||
} else {
|
||||
app.vprintln('`$vself` failed, running `make`...')
|
||||
app.vprintln(self_result.output.trim_space())
|
||||
}
|
||||
app.make(vself)
|
||||
}
|
||||
@ -88,19 +87,19 @@ fn (app App) make(vself string) {
|
||||
$if windows {
|
||||
make = 'make.bat'
|
||||
}
|
||||
make_result := os.exec(make) or { panic(err) }
|
||||
make_result := os.execute_or_panic(make)
|
||||
app.vprintln(make_result.output)
|
||||
}
|
||||
|
||||
fn (app App) show_current_v_version() {
|
||||
if vout := os.exec('"$app.vexe" version') {
|
||||
vout := os.execute('"$app.vexe" version')
|
||||
if vout.exit_code >= 0 {
|
||||
mut vversion := vout.output.trim_space()
|
||||
if vout.exit_code == 0 {
|
||||
latest_v_commit := vversion.split(' ').last().all_after('.')
|
||||
if latest_v_commit_time := os.exec('git show -s --format=%ci $latest_v_commit') {
|
||||
if latest_v_commit_time.exit_code == 0 {
|
||||
vversion += ', timestamp: ' + latest_v_commit_time.output.trim_space()
|
||||
}
|
||||
latest_v_commit_time := os.execute('git show -s --format=%ci $latest_v_commit')
|
||||
if latest_v_commit_time.exit_code == 0 {
|
||||
vversion += ', timestamp: ' + latest_v_commit_time.output.trim_space()
|
||||
}
|
||||
}
|
||||
println('Current V version:')
|
||||
@ -118,10 +117,11 @@ fn (app App) backup(file string) {
|
||||
|
||||
fn (app App) git_command(command string) {
|
||||
app.vprintln('git_command: git $command')
|
||||
git_result := os.exec('git $command') or {
|
||||
git_result := os.execute('git $command')
|
||||
if git_result.exit_code < 0 {
|
||||
app.get_git()
|
||||
// Try it again with (maybe) git installed
|
||||
os.exec('git $command') or { panic(err) }
|
||||
os.execute_or_panic('git $command')
|
||||
}
|
||||
if git_result.exit_code != 0 {
|
||||
eprintln(git_result.output)
|
||||
@ -134,13 +134,15 @@ fn (app App) get_git() {
|
||||
$if windows {
|
||||
println('Downloading git 32 bit for Windows, please wait.')
|
||||
// We'll use 32 bit because maybe someone out there is using 32-bit windows
|
||||
os.exec('bitsadmin.exe /transfer "vgit" https://github.com/git-for-windows/git/releases/download/v2.30.0.windows.2/Git-2.30.0.2-32-bit.exe "$os.getwd()/git32.exe"') or {
|
||||
res_download := os.execute('bitsadmin.exe /transfer "vgit" https://github.com/git-for-windows/git/releases/download/v2.30.0.windows.2/Git-2.30.0.2-32-bit.exe "$os.getwd()/git32.exe"')
|
||||
if res_download.exit_code != 0 {
|
||||
eprintln('Unable to install git automatically: please install git manually')
|
||||
panic(err)
|
||||
panic(res_download.output)
|
||||
}
|
||||
os.exec('$os.getwd()/git32.exe') or {
|
||||
res_git32 := os.execute('$os.getwd()/git32.exe')
|
||||
if res_git32.exit_code != 0 {
|
||||
eprintln('Unable to install git automatically: please install git manually')
|
||||
panic(err)
|
||||
panic(res_git32.output)
|
||||
}
|
||||
} $else { // Probably some kind of *nix, usually need to get using a package manager.
|
||||
eprintln("error: Install `git` using your system's package manager")
|
||||
|
@ -34,7 +34,10 @@ fn check_path(vexe string, dir string, tests []string) int {
|
||||
program := path
|
||||
print(path + ' ')
|
||||
// -force is needed so that `v vet` would not skip the regression files
|
||||
res := os.exec('$vexe vet -force $program') or { panic(err) }
|
||||
res := os.execute('$vexe vet -force $program')
|
||||
if res.exit_code < 0 {
|
||||
panic(res.output)
|
||||
}
|
||||
mut expected := os.read_file(program.replace('.vv', '') + '.out') or { panic(err) }
|
||||
expected = clean_line_endings(expected)
|
||||
found := clean_line_endings(res.output)
|
||||
|
Reference in New Issue
Block a user