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

compiler: use os.PathSeparator

This commit is contained in:
joe-conigliaro 2019-09-14 01:59:17 +10:00 committed by Alexander Medvednikov
parent 21f3b9eccc
commit c614639e7b

View File

@ -630,7 +630,7 @@ fn get_all_after(joined_args, arg, def string) string {
fn (v &V) module_path(mod string) string { fn (v &V) module_path(mod string) string {
// submodule support // submodule support
if mod.contains('.') { if mod.contains('.') {
//return mod.replace('.', path_sep) //return mod.replace('.', os.PathSeparator)
return mod.replace('.', '/') return mod.replace('.', '/')
} }
return mod return mod
@ -652,8 +652,8 @@ fn new_v(args[]string) &V {
if 'run' in args { if 'run' in args {
dir = get_all_after(joined_args, 'run', '') dir = get_all_after(joined_args, 'run', '')
} }
if dir.ends_with('/') { if dir.ends_with(os.PathSeparator) {
dir = dir.all_before_last('/') dir = dir.all_before_last(os.PathSeparator)
} }
if args.len < 2 { if args.len < 2 {
dir = '' dir = ''
@ -667,8 +667,8 @@ fn new_v(args[]string) &V {
build_mode = .build_module build_mode = .build_module
// v -lib ~/v/os => os.o // v -lib ~/v/os => os.o
//mod = os.dir(dir) //mod = os.dir(dir)
mod = if dir.contains('/') { mod = if dir.contains(os.PathSeparator) {
dir.all_after('/') dir.all_after(os.PathSeparator)
} else { } else {
dir dir
} }
@ -702,7 +702,7 @@ fn new_v(args[]string) &V {
} }
// if we are in `/foo` and run `v .`, the executable should be `foo` // if we are in `/foo` and run `v .`, the executable should be `foo`
if dir == '.' && out_name == 'a.out' { if dir == '.' && out_name == 'a.out' {
base := os.getwd().all_after('/') base := os.getwd().all_after(os.PathSeparator)
out_name = base.trim_space() out_name = base.trim_space()
} }
mut _os := OS.mac mut _os := OS.mac
@ -807,14 +807,13 @@ fn new_v(args[]string) &V {
build_mode: build_mode build_mode: build_mode
cflags: cflags cflags: cflags
ccompiler: find_c_compiler() ccompiler: find_c_compiler()
building_v: !is_repl && (rdir_name == 'compiler' || building_v: !is_repl && (rdir_name == 'compiler' || dir.contains('vlib'))
dir.contains('v/vlib'))
} }
if pref.is_verbose || pref.is_debug { if pref.is_verbose || pref.is_debug {
println('C compiler=$pref.ccompiler') println('C compiler=$pref.ccompiler')
} }
if pref.is_so { if pref.is_so {
out_name_c = out_name.all_after('/') + '_shared_lib.c' out_name_c = out_name.all_after(os.PathSeparator) + '_shared_lib.c'
} }
return &V{ return &V{
os: _os os: _os