use os.quoted_path more

pull/13261/head
Delyan Angelov 2022-01-22 21:56:01 +02:00
parent fa6f7d4c83
commit 62c3ad4953
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
12 changed files with 42 additions and 29 deletions

View File

@ -330,9 +330,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
}
if !ts.vargs.contains('fmt') {
cmd_options << ' -o "$generated_binary_fpath"'
cmd_options << ' -o ${os.quoted_path(generated_binary_fpath)}'
}
cmd := '"$ts.vexe" ' + cmd_options.join(' ') + ' "$file"'
cmd := '${os.quoted_path(ts.vexe)} ' + cmd_options.join(' ') + ' ${os.quoted_path(file)}'
ts.benchmark.step()
tls_bench.step()
if relative_file.replace('\\', '/') in ts.skip_files {

View File

@ -410,7 +410,7 @@ fn silent_cmdexecute(cmd string) int {
}
fn get_fmt_exit_code(vfile string, vexe string) int {
return silent_cmdexecute('"$vexe" fmt -verify $vfile')
return silent_cmdexecute('${os.quoted_path(vexe)} fmt -verify ${os.quoted_path(vfile)}')
}
fn (mut f MDFile) check_examples() CheckResult {
@ -438,7 +438,7 @@ fn (mut f MDFile) check_examples() CheckResult {
fmt_res := if nofmt { 0 } else { get_fmt_exit_code(vfile, vexe) }
match command {
'compile' {
res := cmdexecute('"$vexe" -w -Wfatal-errors -o x.c $vfile')
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
if res != 0 || fmt_res != 0 {
if res != 0 {
@ -455,7 +455,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'globals' {
res := cmdexecute('"$vexe" -w -Wfatal-errors -enable-globals -o x.c $vfile')
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -enable-globals -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
if res != 0 || fmt_res != 0 {
if res != 0 {
@ -472,7 +472,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'live' {
res := cmdexecute('"$vexe" -w -Wfatal-errors -live -o x.c $vfile')
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -live -o x.c ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, 'example failed to compile with -live'))
@ -488,7 +488,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'failcompile' {
res := silent_cmdexecute('"$vexe" -w -Wfatal-errors -o x.c $vfile')
res := silent_cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -o x.c ${os.quoted_path(vfile)}')
os.rm('x.c') or {}
if res == 0 || fmt_res != 0 {
if res == 0 {
@ -505,7 +505,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'oksyntax' {
res := cmdexecute('"$vexe" -w -Wfatal-errors -check-syntax $vfile')
res := cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -check-syntax ${os.quoted_path(vfile)}')
if res != 0 || fmt_res != 0 {
if res != 0 {
eprintln(eline(f.path, e.sline, 0, '`oksyntax` example with invalid syntax'))
@ -521,7 +521,7 @@ fn (mut f MDFile) check_examples() CheckResult {
oks++
}
'badsyntax' {
res := silent_cmdexecute('"$vexe" -w -Wfatal-errors -check-syntax $vfile')
res := silent_cmdexecute('${os.quoted_path(vexe)} -w -Wfatal-errors -check-syntax ${os.quoted_path(vfile)}')
if res == 0 {
eprintln(eline(f.path, e.sline, 0, '`badsyntax` example can be parsed fine'))
eprintln(vcontent)

View File

@ -241,8 +241,12 @@ fn (mut a App) report_tcc_version(tccfolder string) {
a.line(tccfolder, 'N/A')
return
}
tcc_branch_name := a.cmd(command: 'git -C $tccfolder rev-parse --abbrev-ref HEAD')
tcc_commit := a.cmd(command: 'git -C $tccfolder describe --abbrev=8 --dirty --always --tags')
tcc_branch_name := a.cmd(
command: 'git -C ${os.quoted_path(tccfolder)} rev-parse --abbrev-ref HEAD'
)
tcc_commit := a.cmd(
command: 'git -C ${os.quoted_path(tccfolder)} describe --abbrev=8 --dirty --always --tags'
)
a.line('$tccfolder status', '$tcc_branch_name $tcc_commit')
}

View File

@ -187,7 +187,7 @@ fn generate_screenshots(mut opt Options, output_path string) ? {
if opt.verbose {
eprintln('Compiling shaders (if needed) for `$file`')
}
sh_result := os.execute('$v_exe shader "$app_path"')
sh_result := os.execute('${os.quoted_path(v_exe)} shader ${os.quoted_path(app_path)}')
if sh_result.exit_code != 0 {
if opt.verbose {
eprintln('Skipping shader compile for `$file` v shader failed with:\n$sh_result.output')
@ -241,7 +241,7 @@ fn compare_screenshots(opt Options, output_path string, target_path string) ? {
diff_file := os.join_path(os.temp_dir(), os.file_name(src).all_before_last('.') +
'.diff.tif')
flags := app_config.compare.flags.join(' ')
diff_cmd := '$idiff_exe $flags -abs -od -o "$diff_file" -abs "$src" "$target"'
diff_cmd := '${os.quoted_path(idiff_exe)} $flags -abs -od -o ${os.quoted_path(diff_file)} -abs ${os.quoted_path(src)} ${os.quoted_path(target)}'
if opt.verbose {
eprintln('Running: $diff_cmd')
}
@ -309,7 +309,7 @@ fn take_screenshots(opt Options, app AppConfig) ?[]string {
}
mut flags := app.capture.flags.join(' ')
v_cmd := '$v_exe $flags -d gg_record run "$app.abs_path"'
v_cmd := '${os.quoted_path(v_exe)} $flags -d gg_record run ${os.quoted_path(app.abs_path)}'
if opt.verbose {
eprintln('Running `$v_cmd`')
}

View File

@ -193,7 +193,9 @@ fn compile_shader(opt CompileOptions, shader_file string) ? {
eprintln('$tool_name generating shader code for $slangs in header "$header_name" in "$path" from $shader_file')
}
cmd := '$shdc --input "$shader_file" --output "$out_file" --slang "' + slangs.join(':') + '"'
cmd :=
'${os.quoted_path(shdc)} --input ${os.quoted_path(shader_file)} --output ${os.quoted_path(out_file)} --slang ' +
os.quoted_path(slangs.join(':'))
if opt.verbose {
eprintln('$tool_name executing:\n$cmd')
}

View File

@ -4,9 +4,11 @@ import os
import term
import time
const vexe = os.getenv('VEXE')
const vexe_path = os.getenv('VEXE')
const vroot = os.dir(vexe)
const vroot = os.dir(vexe_path)
const vexe = os.quoted_path(vexe_path)
const args_string = os.args[1..].join(' ')

View File

@ -75,9 +75,14 @@ fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string,
fn v_test_vetting(vargs string) {
expanded_vet_list := util.find_all_v_files(vet_folders) or { return }
vet_session := tsession(vargs, 'vvet', 'v vet', 'vet', expanded_vet_list, vet_known_failing_exceptions)
vet_session := tsession(vargs, 'vvet', '${os.quoted_path(vexe)} vet', 'vet', expanded_vet_list,
vet_known_failing_exceptions)
//
fmt_cmd, fmt_args := if is_fix { 'v fmt -w', 'fmt -w' } else { 'v fmt -verify', 'fmt -verify' }
fmt_cmd, fmt_args := if is_fix {
'${os.quoted_path(vexe)} fmt -w', 'fmt -w'
} else {
'${os.quoted_path(vexe)} fmt -verify', 'fmt -verify'
}
vfmt_list := util.find_all_v_files(vfmt_verify_list) or { return }
exceptions := util.find_all_v_files(vfmt_known_failing_exceptions) or { return }
verify_session := tsession(vargs, 'vfmt.v', fmt_cmd, fmt_args, vfmt_list, exceptions)

View File

@ -212,7 +212,7 @@ fn (mut context Context) process_whole_file_in_worker(path string) (int, int) {
for i in 0 .. len {
verbosity := if context.is_verbose { '-v' } else { '' }
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" '
cmd := '${os.quoted_path(context.myself)} $verbosity --worker --timeout_ms ${context.timeout_ms:5} --cut_index ${i:5} --path ${os.quoted_path(path)} '
context.log(cmd)
mut res := os.execute(cmd)
context.log('worker exit_code: $res.exit_code | worker output:\n$res.output')

View File

@ -47,7 +47,7 @@ fn test_can_compile_and_use_library_with_skip_unused() {
}
fn v_compile(vopts string) os.Result {
cmd := '"$vexe" -showcc $vopts'
cmd := '${os.quoted_path(vexe)} -showcc $vopts'
// dump(cmd)
res := os.execute_or_exit(cmd)
// dump(res)

View File

@ -166,7 +166,7 @@ fn (mut b Builder) v_build_module(vexe string, imp_path string) {
vroot := os.dir(vexe)
os.chdir(vroot) or {}
boptions := b.pref.build_options.join(' ')
rebuild_cmd := '$vexe $boptions build-module $imp_path'
rebuild_cmd := '${os.quoted_path(vexe)} $boptions build-module ${os.quoted_path(imp_path)}'
vcache.dlog('| Builder.' + @FN, 'vexe: $vexe | imp_path: $imp_path | rebuild_cmd: $rebuild_cmd')
$if trace_v_build_module ? {
eprintln('> Builder.v_build_module: $rebuild_cmd')

View File

@ -61,7 +61,7 @@ fn opendiff_exists() bool {
pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
if diff_cmd != '' {
full_cmd := '$diff_cmd --minimal --text --unified=2 --show-function-line="fn " "$file1" "$file2" '
full_cmd := '$diff_cmd --minimal --text --unified=2 --show-function-line="fn " ${os.quoted_path(file1)} ${os.quoted_path(file2)} '
x := os.execute(full_cmd)
if x.exit_code < 0 {
return 'comparison command: `$full_cmd` not found'

View File

@ -155,7 +155,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
for emodule in emodules {
check_module_is_installed(emodule, is_verbose) or { panic(err) }
}
mut compilation_command := "'$vexe' -skip-unused "
mut compilation_command := '${os.quoted_path(vexe)} -skip-unused '
if tool_name in ['vself', 'vup', 'vdoctor', 'vsymlink'] {
// These tools will be called by users in cases where there
// is high chance of there being a problem somewhere. Thus
@ -164,7 +164,7 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
// .v line numbers, to ease diagnostic in #bugs and issues.
compilation_command += ' -g '
}
compilation_command += "'$tool_source'"
compilation_command += os.quoted_path(tool_source)
if is_verbose {
println('Compiling $tool_name with: "$compilation_command"')
}
@ -175,10 +175,10 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
}
}
$if windows {
exit(os.system('"$tool_exe" $tool_args'))
exit(os.system('${os.quoted_path(tool_exe)} $tool_args'))
} $else $if js {
// no way to implement os.execvp in JS backend
exit(os.system('\'$tool_exe\' $tool_args'))
exit(os.system('${os.quote_path(tool_exe)} $tool_args'))
} $else {
os.execvp(tool_exe, args) or { panic(err) }
}
@ -348,7 +348,7 @@ pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
}
if os.exists(mod_v_file) {
vexe := pref.vexe_path()
update_cmd := "'$vexe' update '$modulename'"
update_cmd := "${os.quoted_path(vexe)} update '$modulename'"
if is_verbose {
eprintln('check_module_is_installed: updating with $update_cmd ...')
}
@ -448,7 +448,7 @@ pub fn prepare_tool_when_needed(source_name string) {
}
pub fn recompile_file(vexe string, file string) {
cmd := "'$vexe' '$file'"
cmd := '${os.quoted_path(vexe)} ${os.quoted_path(file)}'
$if trace_recompilation ? {
println('recompilation command: $cmd')
}