v.util,tools: use os.join_path_single
parent
bd9564e38b
commit
d431145a39
|
@ -309,7 +309,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
} else {
|
} else {
|
||||||
fname.replace('.v', '')
|
fname.replace('.v', '')
|
||||||
}
|
}
|
||||||
generated_binary_fpath := os.join_path(tmpd, generated_binary_fname)
|
generated_binary_fpath := os.join_path_single(tmpd, generated_binary_fname)
|
||||||
if os.exists(generated_binary_fpath) {
|
if os.exists(generated_binary_fpath) {
|
||||||
if ts.rm_binaries {
|
if ts.rm_binaries {
|
||||||
os.rm(generated_binary_fpath) or {}
|
os.rm(generated_binary_fpath) or {}
|
||||||
|
@ -406,7 +406,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vlib_should_be_present(parent_dir string) {
|
pub fn vlib_should_be_present(parent_dir string) {
|
||||||
vlib_dir := os.join_path(parent_dir, 'vlib')
|
vlib_dir := os.join_path_single(parent_dir, 'vlib')
|
||||||
if !os.is_dir(vlib_dir) {
|
if !os.is_dir(vlib_dir) {
|
||||||
eprintln('$vlib_dir is missing, it must be next to the V executable')
|
eprintln('$vlib_dir is missing, it must be next to the V executable')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -427,7 +427,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
|
||||||
eprintln('v compiler args: "$vargs"')
|
eprintln('v compiler args: "$vargs"')
|
||||||
}
|
}
|
||||||
mut session := new_test_session(vargs, true)
|
mut session := new_test_session(vargs, true)
|
||||||
files := os.walk_ext(os.join_path(parent_dir, folder), '.v')
|
files := os.walk_ext(os.join_path_single(parent_dir, folder), '.v')
|
||||||
mut mains := []string{}
|
mut mains := []string{}
|
||||||
mut skipped := oskipped.clone()
|
mut skipped := oskipped.clone()
|
||||||
next_file: for f in files {
|
next_file: for f in files {
|
||||||
|
@ -451,7 +451,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
|
||||||
maxc := if c.len > 300 { 300 } else { c.len }
|
maxc := if c.len > 300 { 300 } else { c.len }
|
||||||
start := c[0..maxc]
|
start := c[0..maxc]
|
||||||
if start.contains('module ') && !start.contains('module main') {
|
if start.contains('module ') && !start.contains('module main') {
|
||||||
skipped_f := f.replace(os.join_path(parent_dir, ''), '')
|
skipped_f := f.replace(os.join_path_single(parent_dir, ''), '')
|
||||||
skipped << skipped_f
|
skipped << skipped_f
|
||||||
}
|
}
|
||||||
for skip_prefix in oskipped {
|
for skip_prefix in oskipped {
|
||||||
|
|
|
@ -76,7 +76,7 @@ pub fn prepare_vc_source(vcdir string, cdir string, commit string) (string, stri
|
||||||
|
|
||||||
pub fn clone_or_pull(remote_git_url string, local_worktree_path string) {
|
pub fn clone_or_pull(remote_git_url string, local_worktree_path string) {
|
||||||
// NB: after clone_or_pull, the current repo branch is === HEAD === master
|
// NB: after clone_or_pull, the current repo branch is === HEAD === master
|
||||||
if os.is_dir(local_worktree_path) && os.is_dir(os.join_path(local_worktree_path, '.git')) {
|
if os.is_dir(local_worktree_path) && os.is_dir(os.join_path_single(local_worktree_path, '.git')) {
|
||||||
// Already existing ... Just pulling in this case is faster usually.
|
// Already existing ... Just pulling in this case is faster usually.
|
||||||
scripting.run('git -C "$local_worktree_path" checkout --quiet master')
|
scripting.run('git -C "$local_worktree_path" checkout --quiet master')
|
||||||
scripting.run('git -C "$local_worktree_path" pull --quiet ')
|
scripting.run('git -C "$local_worktree_path" pull --quiet ')
|
||||||
|
@ -107,7 +107,7 @@ pub mut:
|
||||||
|
|
||||||
pub fn (mut vgit_context VGitContext) compile_oldv_if_needed() {
|
pub fn (mut vgit_context VGitContext) compile_oldv_if_needed() {
|
||||||
vgit_context.vexename = if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
vgit_context.vexename = if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
||||||
vgit_context.vexepath = os.real_path(os.join_path(vgit_context.path_v, vgit_context.vexename))
|
vgit_context.vexepath = os.real_path(os.join_path_single(vgit_context.path_v, vgit_context.vexename))
|
||||||
mut command_for_building_v_from_c_source := ''
|
mut command_for_building_v_from_c_source := ''
|
||||||
mut command_for_selfbuilding := ''
|
mut command_for_selfbuilding := ''
|
||||||
if 'windows' == os.user_os() {
|
if 'windows' == os.user_os() {
|
||||||
|
|
|
@ -110,7 +110,7 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
|
||||||
// check absolute path first
|
// check absolute path first
|
||||||
if !os.exists(abs_path) {
|
if !os.exists(abs_path) {
|
||||||
// ... look relative to the source file:
|
// ... look relative to the source file:
|
||||||
epath = os.real_path(os.join_path(os.dir(p.file_name), epath))
|
epath = os.real_path(os.join_path_single(os.dir(p.file_name), epath))
|
||||||
if !os.exists(epath) {
|
if !os.exists(epath) {
|
||||||
p.error_with_pos('"$epath" does not exist so it cannot be embedded',
|
p.error_with_pos('"$epath" does not exist so it cannot be embedded',
|
||||||
spos)
|
spos)
|
||||||
|
@ -144,11 +144,11 @@ fn (mut p Parser) comptime_call() ast.ComptimeCall {
|
||||||
tmpl_path := if is_html { '${fn_path.last()}.html' } else { path_of_literal_string_param }
|
tmpl_path := if is_html { '${fn_path.last()}.html' } else { path_of_literal_string_param }
|
||||||
// Looking next to the vweb program
|
// Looking next to the vweb program
|
||||||
dir := os.dir(compiled_vfile_path)
|
dir := os.dir(compiled_vfile_path)
|
||||||
mut path := os.join_path(dir, fn_path_joined)
|
mut path := os.join_path_single(dir, fn_path_joined)
|
||||||
path += '.html'
|
path += '.html'
|
||||||
path = os.real_path(path)
|
path = os.real_path(path)
|
||||||
if !is_html {
|
if !is_html {
|
||||||
path = os.join_path(dir, tmpl_path)
|
path = os.join_path_single(dir, tmpl_path)
|
||||||
}
|
}
|
||||||
if !os.exists(path) {
|
if !os.exists(path) {
|
||||||
if is_html {
|
if is_html {
|
||||||
|
|
|
@ -135,7 +135,7 @@ mut sb := strings.new_builder($lstartlength)\n
|
||||||
// an absolute path
|
// an absolute path
|
||||||
templates_folder = ''
|
templates_folder = ''
|
||||||
}
|
}
|
||||||
file_path := os.real_path(os.join_path(templates_folder, '$file_name$file_ext'))
|
file_path := os.real_path(os.join_path_single(templates_folder, '$file_name$file_ext'))
|
||||||
$if trace_tmpl ? {
|
$if trace_tmpl ? {
|
||||||
eprintln('>>> basepath: "$basepath" , template_file: "$template_file" , fn_name: "$fn_name" , @include line: "$line" , file_name: "$file_name" , file_ext: "$file_ext" , templates_folder: "$templates_folder" , file_path: "$file_path"')
|
eprintln('>>> basepath: "$basepath" , template_file: "$template_file" , fn_name: "$fn_name" , @include line: "$line" , file_name: "$file_name" , file_ext: "$file_ext" , templates_folder: "$templates_folder" , file_path: "$file_path"')
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,11 +72,11 @@ pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string {
|
pub fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string {
|
||||||
cdir := os.join_path(os.cache_dir(), unique_prefix)
|
cdir := os.join_path_single(os.cache_dir(), unique_prefix)
|
||||||
os.mkdir(cdir) or {}
|
os.mkdir(cdir) or {}
|
||||||
ctime := time.sys_mono_now()
|
ctime := time.sys_mono_now()
|
||||||
e_file := os.join_path(cdir, '${ctime}.expected.txt')
|
e_file := os.join_path_single(cdir, '${ctime}.expected.txt')
|
||||||
f_file := os.join_path(cdir, '${ctime}.found.txt')
|
f_file := os.join_path_single(cdir, '${ctime}.found.txt')
|
||||||
os.write_file(e_file, expected) or { panic(err) }
|
os.write_file(e_file, expected) or { panic(err) }
|
||||||
os.write_file(f_file, found) or { panic(err) }
|
os.write_file(f_file, found) or { panic(err) }
|
||||||
res := color_compare_files(diff_cmd, e_file, f_file)
|
res := color_compare_files(diff_cmd, e_file, f_file)
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn qualify_import(pref &pref.Preferences, mod string, file_path string) stri
|
||||||
mod_paths << os.vmodules_paths()
|
mod_paths << os.vmodules_paths()
|
||||||
mod_path := mod.replace('.', os.path_separator)
|
mod_path := mod.replace('.', os.path_separator)
|
||||||
for search_path in mod_paths {
|
for search_path in mod_paths {
|
||||||
try_path := os.join_path(search_path, mod_path)
|
try_path := os.join_path_single(search_path, mod_path)
|
||||||
if os.is_dir(try_path) {
|
if os.is_dir(try_path) {
|
||||||
if m1 := mod_path_to_full_name(pref, mod, try_path) {
|
if m1 := mod_path_to_full_name(pref, mod, try_path) {
|
||||||
trace_mod_path_to_full_name(@LINE, mod, try_path, m1)
|
trace_mod_path_to_full_name(@LINE, mod, try_path, m1)
|
||||||
|
@ -70,7 +70,7 @@ pub fn mod_path_to_full_name(pref &pref.Preferences, mod string, path string) ?s
|
||||||
mod_path := mod.replace('.', os.path_separator)
|
mod_path := mod.replace('.', os.path_separator)
|
||||||
// go back through each parent in path_parts and join with `mod_path` to see the dir exists
|
// go back through each parent in path_parts and join with `mod_path` to see the dir exists
|
||||||
for i := path_parts.len - 1; i > 0; i-- {
|
for i := path_parts.len - 1; i > 0; i-- {
|
||||||
try_path := os.join_path(path_parts[0..i].join(os.path_separator), mod_path)
|
try_path := os.join_path_single(path_parts[0..i].join(os.path_separator), mod_path)
|
||||||
// found module path
|
// found module path
|
||||||
if os.is_dir(try_path) {
|
if os.is_dir(try_path) {
|
||||||
// we know we are in one of the `vmod_folders`
|
// we know we are in one of the `vmod_folders`
|
||||||
|
|
|
@ -9,7 +9,7 @@ import os
|
||||||
// V from source.
|
// V from source.
|
||||||
pub fn disabling_file(vroot string) string {
|
pub fn disabling_file(vroot string) string {
|
||||||
tools_folder := os.join_path(vroot, 'cmd', 'tools')
|
tools_folder := os.join_path(vroot, 'cmd', 'tools')
|
||||||
res := os.join_path(tools_folder, '.disable_autorecompilation')
|
res := os.join_path_single(tools_folder, '.disable_autorecompilation')
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub fn set_vroot_folder(vroot_path string) {
|
||||||
// VEXE env variable is needed so that compiler.vexe_path()
|
// VEXE env variable is needed so that compiler.vexe_path()
|
||||||
// can return it later to whoever needs it:
|
// can return it later to whoever needs it:
|
||||||
vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
vname := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
||||||
os.setenv('VEXE', os.real_path(os.join_path(vroot_path, vname)), true)
|
os.setenv('VEXE', os.real_path(os.join_path_single(vroot_path, vname)), true)
|
||||||
os.setenv('VCHILD', 'true', true)
|
os.setenv('VCHILD', 'true', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,11 +121,11 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
||||||
set_vroot_folder(vroot)
|
set_vroot_folder(vroot)
|
||||||
tool_args := args_quote_paths(args)
|
tool_args := args_quote_paths(args)
|
||||||
tools_folder := os.join_path(vroot, 'cmd', 'tools')
|
tools_folder := os.join_path(vroot, 'cmd', 'tools')
|
||||||
tool_basename := os.real_path(os.join_path(tools_folder, tool_name))
|
tool_basename := os.real_path(os.join_path_single(tools_folder, tool_name))
|
||||||
mut tool_exe := ''
|
mut tool_exe := ''
|
||||||
mut tool_source := ''
|
mut tool_source := ''
|
||||||
if os.is_dir(tool_basename) {
|
if os.is_dir(tool_basename) {
|
||||||
tool_exe = path_of_executable(os.join_path(tool_basename, tool_name))
|
tool_exe = path_of_executable(os.join_path_single(tool_basename, tool_name))
|
||||||
tool_source = tool_basename
|
tool_source = tool_basename
|
||||||
} else {
|
} else {
|
||||||
tool_exe = path_of_executable(tool_basename)
|
tool_exe = path_of_executable(tool_basename)
|
||||||
|
@ -240,7 +240,7 @@ pub fn should_recompile_tool(vexe string, tool_source string, tool_name string,
|
||||||
fn tool_source2name_and_exe(tool_source string) (string, string) {
|
fn tool_source2name_and_exe(tool_source string) (string, string) {
|
||||||
sfolder := os.dir(tool_source)
|
sfolder := os.dir(tool_source)
|
||||||
tool_name := os.base(tool_source).replace('.v', '')
|
tool_name := os.base(tool_source).replace('.v', '')
|
||||||
tool_exe := os.join_path(sfolder, path_of_executable(tool_name))
|
tool_exe := os.join_path_single(sfolder, path_of_executable(tool_name))
|
||||||
return tool_name, tool_exe
|
return tool_name, tool_exe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,8 +357,8 @@ fn non_empty(arg []string) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
|
pub fn check_module_is_installed(modulename string, is_verbose bool) ?bool {
|
||||||
mpath := os.join_path(os.vmodules_dir(), modulename)
|
mpath := os.join_path_single(os.vmodules_dir(), modulename)
|
||||||
mod_v_file := os.join_path(mpath, 'v.mod')
|
mod_v_file := os.join_path_single(mpath, 'v.mod')
|
||||||
murl := 'https://github.com/vlang/$modulename'
|
murl := 'https://github.com/vlang/$modulename'
|
||||||
if is_verbose {
|
if is_verbose {
|
||||||
eprintln('check_module_is_installed: mpath: $mpath')
|
eprintln('check_module_is_installed: mpath: $mpath')
|
||||||
|
@ -484,7 +484,7 @@ pub fn get_vtmp_folder() string {
|
||||||
return vtmp
|
return vtmp
|
||||||
}
|
}
|
||||||
uid := os.getuid()
|
uid := os.getuid()
|
||||||
vtmp = os.join_path(os.temp_dir(), 'v_$uid')
|
vtmp = os.join_path_single(os.temp_dir(), 'v_$uid')
|
||||||
if !os.exists(vtmp) || !os.is_dir(vtmp) {
|
if !os.exists(vtmp) || !os.is_dir(vtmp) {
|
||||||
os.mkdir_all(vtmp) or { panic(err) }
|
os.mkdir_all(vtmp) or { panic(err) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub fn filter_vtest_only(paths []string, config FilterVTestConfig) []string {
|
||||||
for relative_path in paths {
|
for relative_path in paths {
|
||||||
mut file := relative_path
|
mut file := relative_path
|
||||||
if config.basepath.len > 0 {
|
if config.basepath.len > 0 {
|
||||||
file = os.join_path(config.basepath, file)
|
file = os.join_path_single(config.basepath, file)
|
||||||
}
|
}
|
||||||
if config.fix_slashes {
|
if config.fix_slashes {
|
||||||
file = file.replace('\\', '/')
|
file = file.replace('\\', '/')
|
||||||
|
|
Loading…
Reference in New Issue