compiler: cached modules - windows fixes & organise cached module path (#2302)

compiler: cached modules - windows fixes & organise cached module path (#2302)
This commit is contained in:
joe-conigliaro 2019-10-12 16:41:41 +11:00 committed by GitHub
parent dd053d79b0
commit 40156392f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 39 deletions

View file

@ -107,17 +107,15 @@ fn v_type_str(typ_ string) string {
fn (v &V) generate_vh() {
println('\n\n\n\nGenerating a V header file for module `$v.mod`')
mod_path := v.mod.replace('.', os.PathSeparator)
dir := '$v_modules_path${os.PathSeparator}$mod_path'
dir := if v.dir.starts_with('vlib') {
'$v_modules_path${os.PathSeparator}$v.dir'
} else {
'$v_modules_path${os.PathSeparator}$mod_path'
}
path := dir + '.vh'
if !os.dir_exists(dir) {
// create recursive
mut mkpath := v_modules_path
for subdir in mod_path.split(os.PathSeparator) {
mkpath += os.PathSeparator + subdir
if !os.dir_exists(mkpath) {
os.mkdir(mkpath)
}
}
pdir := dir.all_before_last(os.PathSeparator)
if !os.dir_exists(pdir) {
os.mkdir_all(pdir)
// os.mkdir(os.realpath(dir))
}
file := os.create(path) or { panic(err) }