From 30481a36dc864dcbf0ac0d3bcfee8f9ca201e9b5 Mon Sep 17 00:00:00 2001 From: kdmult Date: Sat, 9 Nov 2019 23:49:15 +0300 Subject: [PATCH] fix broken doc on windows * replace hardcoded slash with os.path_separator * compile only, no link, if building a module --- v.v | 5 +++-- vlib/compiler/module_header.v | 21 +++++++++------------ vlib/compiler/msvc.v | 2 ++ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/v.v b/v.v index a792aa599f..5bc1985ece 100755 --- a/v.v +++ b/v.v @@ -8,6 +8,7 @@ import ( compiler benchmark os + filepath //time ) @@ -78,8 +79,8 @@ fn main() { vdir := os.dir(os.executable()) os.chdir(vdir) mod := args.last() - os.system('$vexe build module vlib/' + args.last()) - txt := os.read_file('$compiler.v_modules_path/vlib/${mod}.vh') or { + os.system('$vexe build module vlib$os.path_separator' + args.last()) + txt := os.read_file(filepath.join(compiler.v_modules_path, 'vlib', '${mod}.vh')) or { panic(err) } println(txt) diff --git a/vlib/compiler/module_header.v b/vlib/compiler/module_header.v index 8ca755f562..70ecc0e1ac 100644 --- a/vlib/compiler/module_header.v +++ b/vlib/compiler/module_header.v @@ -7,6 +7,7 @@ module compiler import ( strings os + filepath ) /* @@ -27,15 +28,10 @@ mut: // `mod` == "vlib/os" fn generate_vh(mod string) { - println('\n\n\n\n1Generating a V header file for module `$mod`') + println('\n\n\n\nGenerating a V header file for module `$mod`') vexe := os.executable() - full_mod_path := os.dir(vexe) + '/' + mod - mod_path := mod.replace('.', os.path_separator) - dir := if mod.starts_with('vlib') { - '$compiler.v_modules_path${os.path_separator}$mod' - } else { - '$compiler.v_modules_path${os.path_separator}$mod' - } + full_mod_path := filepath.join(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) if !os.dir_exists(pdir) { @@ -43,8 +39,9 @@ fn generate_vh(mod string) { // os.mkdir(os.realpath(dir)) } out := os.create(path) or { panic(err) } - mod_def := if mod.contains('/') { mod.all_after('/') } else { mod } // "os" - out.writeln('// $mod module header \n') + mod_path := mod.replace("\\", "/") + out.writeln('// $mod_path module header\n') + mod_def := if mod_path.contains('/') { mod_path.all_after('/') } else { mod_path } // "os" out.writeln('module $mod_def\n') // Consts println(full_mod_path) @@ -55,9 +52,9 @@ fn generate_vh(mod string) { filtered := vfiles.filter(it.ends_with('.v') && !it.ends_with('test.v') && !it.ends_with('_windows.v') && !it.ends_with('_win.v') && !it.ends_with('_lin.v') && - !it.contains('/examples') && + !it.contains('${os.path_separator}examples') && !it.contains('_js.v') && - !it.contains('/js')) // TODO merge once filter allows it + !it.contains('${os.path_separator}js')) // TODO merge once filter allows it println('f:') println(filtered) mut v := new_v(['foo.v']) diff --git a/vlib/compiler/msvc.v b/vlib/compiler/msvc.v index 155c60f34f..512f06873a 100644 --- a/vlib/compiler/msvc.v +++ b/vlib/compiler/msvc.v @@ -267,6 +267,8 @@ pub fn (v mut V) cc_msvc() { //alibs := []string // builtin.o os.o http.o etc if v.pref.build_mode == .build_module { + // Compile only + a << '/c' } else if v.pref.build_mode == .default_mode { /*