fix broken doc on windows

* replace hardcoded slash with os.path_separator

* compile only, no link, if building a module
pull/2717/head
kdmult 2019-11-09 23:49:15 +03:00 committed by Alexander Medvednikov
parent e6c9c7d571
commit 30481a36dc
3 changed files with 14 additions and 14 deletions

5
v.v
View File

@ -8,6 +8,7 @@ import (
compiler compiler
benchmark benchmark
os os
filepath
//time //time
) )
@ -78,8 +79,8 @@ fn main() {
vdir := os.dir(os.executable()) vdir := os.dir(os.executable())
os.chdir(vdir) os.chdir(vdir)
mod := args.last() mod := args.last()
os.system('$vexe build module vlib/' + args.last()) os.system('$vexe build module vlib$os.path_separator' + args.last())
txt := os.read_file('$compiler.v_modules_path/vlib/${mod}.vh') or { txt := os.read_file(filepath.join(compiler.v_modules_path, 'vlib', '${mod}.vh')) or {
panic(err) panic(err)
} }
println(txt) println(txt)

View File

@ -7,6 +7,7 @@ module compiler
import ( import (
strings strings
os os
filepath
) )
/* /*
@ -27,15 +28,10 @@ mut:
// `mod` == "vlib/os" // `mod` == "vlib/os"
fn generate_vh(mod string) { 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() vexe := os.executable()
full_mod_path := os.dir(vexe) + '/' + mod full_mod_path := filepath.join(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 { mod }
dir := if mod.starts_with('vlib') {
'$compiler.v_modules_path${os.path_separator}$mod'
} else {
'$compiler.v_modules_path${os.path_separator}$mod'
}
path := dir + '.vh' path := dir + '.vh'
pdir := dir.all_before_last(os.path_separator) pdir := dir.all_before_last(os.path_separator)
if !os.dir_exists(pdir) { if !os.dir_exists(pdir) {
@ -43,8 +39,9 @@ fn generate_vh(mod string) {
// os.mkdir(os.realpath(dir)) // os.mkdir(os.realpath(dir))
} }
out := os.create(path) or { panic(err) } out := os.create(path) or { panic(err) }
mod_def := if mod.contains('/') { mod.all_after('/') } else { mod } // "os" mod_path := mod.replace("\\", "/")
out.writeln('// $mod module header \n') 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') out.writeln('module $mod_def\n')
// Consts // Consts
println(full_mod_path) 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') && 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('_windows.v') && !it.ends_with('_win.v') &&
!it.ends_with('_lin.v') && !it.ends_with('_lin.v') &&
!it.contains('/examples') && !it.contains('${os.path_separator}examples') &&
!it.contains('_js.v') && !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('f:')
println(filtered) println(filtered)
mut v := new_v(['foo.v']) mut v := new_v(['foo.v'])

View File

@ -267,6 +267,8 @@ pub fn (v mut V) cc_msvc() {
//alibs := []string // builtin.o os.o http.o etc //alibs := []string // builtin.o os.o http.o etc
if v.pref.build_mode == .build_module { if v.pref.build_mode == .build_module {
// Compile only
a << '/c'
} }
else if v.pref.build_mode == .default_mode { else if v.pref.build_mode == .default_mode {
/* /*