look for modules in current path

pull/937/head
AtjonTV 2019-07-02 21:55:57 +02:00 committed by Alexander Medvednikov
parent 75da1e4240
commit ab20db8e6e
1 changed files with 11 additions and 3 deletions

View File

@ -725,8 +725,12 @@ fn (v mut V) add_user_v_files() {
// for pkg in v.table.imports { // for pkg in v.table.imports {
for i := 0; i < v.table.imports.len; i++ { for i := 0; i < v.table.imports.len; i++ {
pkg := v.table.imports[i] pkg := v.table.imports[i]
// mut import_path := '$v.lang_dir/$pkg' idir := os.getwd()
vfiles := v.v_files_from_dir('$v.lang_dir/vlib/$pkg') mut import_path := '$idir/$pkg'
if(!os.file_exists(import_path)) {
import_path = '$v.lang_dir/vlib/$pkg'
}
vfiles := v.v_files_from_dir(import_path)
// Add all imports referenced by these libs // Add all imports referenced by these libs
for file in vfiles { for file in vfiles {
mut p := v.new_parser(file, RUN_IMPORTS) mut p := v.new_parser(file, RUN_IMPORTS)
@ -740,13 +744,17 @@ fn (v mut V) add_user_v_files() {
} }
// Only now add all combined lib files // Only now add all combined lib files
for pkg in v.table.imports { for pkg in v.table.imports {
mut module_path := '$v.lang_dir/vlib/$pkg' idir := os.getwd()
mut module_path := '$idir/$pkg'
// If we are in default mode, we don't parse vlib .v files, but header .vh files in // If we are in default mode, we don't parse vlib .v files, but header .vh files in
// TmpPath/vlib // TmpPath/vlib
// These were generated by vfmt // These were generated by vfmt
if v.pref.build_mode == .default_mode || v.pref.build_mode == .build { if v.pref.build_mode == .default_mode || v.pref.build_mode == .build {
module_path = '$TmpPath/vlib/$pkg' module_path = '$TmpPath/vlib/$pkg'
} }
if(!os.file_exists(module_path)) {
module_path = '$v.lang_dir/vlib/$pkg'
}
vfiles := v.v_files_from_dir(module_path) vfiles := v.v_files_from_dir(module_path)
for vfile in vfiles { for vfile in vfiles {
v.files << vfile v.files << vfile