1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: join => join_path

This commit is contained in:
yuyi
2020-03-09 09:23:34 +08:00
committed by GitHub
parent e3687dc257
commit 876b73f92c
23 changed files with 62 additions and 62 deletions

View File

@ -219,7 +219,7 @@ fn (v mut V) cc() {
a << '-c'
}
else if v.pref.is_cache {
builtin_o_path := os.join(v_modules_path,'cache','vlib','builtin.o')
builtin_o_path := os.join_path(v_modules_path, 'cache', 'vlib', 'builtin.o')
a << builtin_o_path.replace('builtin.o', 'strconv.o') // TODO hack no idea why this is needed
if os.exists(builtin_o_path) {
libs = builtin_o_path

View File

@ -348,7 +348,7 @@ pub fn (v mut V) compile_x64() {
println('v -x64 can only generate Linux binaries for now')
println('You are not on a Linux system, so you will not ' + 'be able to run the resulting executable')
}
//v.files << v.v_files_from_dir(os.join(v.pref.vlib_path,'builtin','bare'))
//v.files << v.v_files_from_dir(os.join_path(v.pref.vlib_path,'builtin','bare'))
v.files << v.pref.path
v.set_module_lookup_paths()
mut b := v.new_v2()
@ -624,7 +624,7 @@ pub fn (v &V) v_files_from_dir(dir string) []string {
continue
}
}
res << os.join(dir,file)
res << os.join_path(dir, file)
}
return res
}
@ -638,7 +638,7 @@ pub fn (v mut V) add_v_files_to_compile() {
}
// Builtin cache exists? Use it.
if v.pref.is_cache {
builtin_vh := os.join(v_modules_path,'vlib','builtin.vh')
builtin_vh := os.join_path(v_modules_path, 'vlib', 'builtin.vh')
if os.exists(builtin_vh) {
v.cached_mods << 'builtin'
builtin_files = [builtin_vh]
@ -721,16 +721,16 @@ pub fn (v &V) get_builtin_files() []string {
// Lookup for built-in folder in lookup path.
// Assumption: `builtin/` folder implies usable implementation of builtin
for location in v.pref.lookup_path {
if !os.exists(os.join(location, 'builtin')) {
if !os.exists(os.join_path(location, 'builtin')) {
continue
}
if v.pref.is_bare {
return v.v_files_from_dir(os.join(location, 'builtin', 'bare'))
return v.v_files_from_dir(os.join_path(location, 'builtin', 'bare'))
}
$if js {
return v.v_files_from_dir(os.join(location, 'builtin','js'))
return v.v_files_from_dir(os.join_path(location, 'builtin', 'js'))
}
return v.v_files_from_dir(os.join(location, 'builtin'))
return v.v_files_from_dir(os.join_path(location, 'builtin'))
}
// Panic. We couldn't find the folder.
verror('`builtin/` not included on module lookup path.
@ -748,18 +748,18 @@ pub fn (v &V) get_user_files() []string {
// See cmd/tools/preludes/README.md for more info about what preludes are
vroot := os.dir(pref.vexe_path())
preludes_path := os.join(vroot,'cmd','tools','preludes')
preludes_path := os.join_path(vroot, 'cmd', 'tools', 'preludes')
if v.pref.is_live {
user_files << os.join(preludes_path,'live_main.v')
user_files << os.join_path(preludes_path, 'live_main.v')
}
if v.pref.is_solive {
user_files << os.join(preludes_path,'live_shared.v')
user_files << os.join_path(preludes_path, 'live_shared.v')
}
if v.pref.is_test {
user_files << os.join(preludes_path,'tests_assertions.v')
user_files << os.join_path(preludes_path, 'tests_assertions.v')
}
if v.pref.is_test && v.pref.is_stats {
user_files << os.join(preludes_path,'tests_with_stats.v')
user_files << os.join_path(preludes_path, 'tests_with_stats.v')
}
is_test := dir.ends_with('_test.v')

View File

@ -28,7 +28,7 @@ mut:
fn generate_vh(mod string) {
println('\n\n\n\nGenerating a V header file for module `$mod`')
vexe := pref.vexe_path()
full_mod_path := os.join(os.dir(vexe),mod)
full_mod_path := os.join_path(os.dir(vexe), mod)
dir := if mod.starts_with('vlib') { '$compiler.v_modules_path${os.path_separator}$mod' } else { mod }
path := dir + '.vh'
pdir := dir.all_before_last(os.path_separator)

View File

@ -170,7 +170,7 @@ fn (v mut V) set_module_lookup_paths() {
v.module_lookup_paths << os.base_dir(v.compiled_dir) // pdir of _test.v
}
v.module_lookup_paths << v.compiled_dir
v.module_lookup_paths << os.join(v.compiled_dir,'modules')
v.module_lookup_paths << os.join_path(v.compiled_dir, 'modules')
v.module_lookup_paths << v.pref.lookup_path
if v.pref.verbosity.is_higher_or_equal(.level_two) {
v.log('v.module_lookup_paths: $v.module_lookup_paths')
@ -189,7 +189,7 @@ fn (p mut Parser) find_module_path(mod string) ?string {
mod_path := p.v.module_path(mod)
for lookup_path in module_lookup_paths {
try_path := os.join(lookup_path,mod_path)
try_path := os.join_path(lookup_path, mod_path)
if p.v.pref.verbosity.is_higher_or_equal(.level_three) {
println(' >> trying to find $mod in $try_path ...')
}

View File

@ -63,7 +63,7 @@ fn worker_repl(p mut sync.PoolProcessor, idx int, thread_id int) voidptr {
p.set_thread_context(idx, tls_bench)
}
tls_bench.cstep = idx
tfolder := os.join(cdir,'vrepl_tests_$idx')
tfolder := os.join_path(cdir, 'vrepl_tests_$idx')
if os.is_dir(tfolder) {
os.rmdir_all(tfolder)
}

View File

@ -19,7 +19,7 @@ pub fn full_path_to_v(dirs_in int) string {
for i := 0; i < dirs_in; i++ {
path = os.dir(path)
}
vexec := os.join( path, vname )
vexec := os.join_path(path, vname)
/*
args := os.args
vreal := os.realpath('v')
@ -56,9 +56,9 @@ pub fn run_repl_file(wd string, vexec string, file string) ?string {
fname := os.filename( file )
input_temporary_filename := os.realpath(os.join( wd, 'input_temporary_filename.txt'))
input_temporary_filename := os.realpath(os.join_path( wd, 'input_temporary_filename.txt'))
os.write_file(input_temporary_filename, input)
os.write_file( os.realpath(os.join( wd, 'original.txt' ) ), fcontent )
os.write_file( os.realpath(os.join_path( wd, 'original.txt' ) ), fcontent )
rcmd := '"$vexec" repl -replfolder "$wd" -replprefix "${fname}." < $input_temporary_filename'
r := os.exec(rcmd) or {
os.rm(input_temporary_filename)

View File

@ -97,7 +97,7 @@ fn (mcache mut ModFileCacher) traverse(mfolder string) ([]string, ModFileAndFold
if 'v.mod' in files {
// TODO: actually read the v.mod file and parse its contents to see
// if its source folder is different
res := ModFileAndFolder{ vmod_file: os.join( cfolder, 'v.mod'), vmod_folder: cfolder }
res := ModFileAndFolder{ vmod_file: os.join_path( cfolder, 'v.mod'), vmod_folder: cfolder }
return folders_so_far, res
}
if mcache.check_for_stop( cfolder, files ) {

View File

@ -6,9 +6,9 @@ module compiler
import os
fn get_vtmp_folder() string {
vtmp := os.join(os.tmpdir(),'v')
vtmp := os.join_path(os.tmpdir(), 'v')
if !os.is_dir(vtmp) {
os.mkdir(vtmp)or{
os.mkdir(vtmp) or {
panic(err)
}
}
@ -17,5 +17,5 @@ fn get_vtmp_folder() string {
fn get_vtmp_filename(base_file_name string, postfix string) string {
vtmp := get_vtmp_folder()
return os.realpath(os.join(vtmp,os.filename(os.realpath(base_file_name)) + postfix))
return os.realpath(os.join_path(vtmp, os.filename(os.realpath(base_file_name)) + postfix))
}