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

look for modules in current path

This commit is contained in:
AtjonTV 2019-07-02 21:55:57 +02:00 committed by Alexander Medvednikov
parent 75da1e4240
commit ab20db8e6e

View File

@ -725,8 +725,12 @@ fn (v mut V) add_user_v_files() {
// for pkg in v.table.imports {
for i := 0; i < v.table.imports.len; i++ {
pkg := v.table.imports[i]
// mut import_path := '$v.lang_dir/$pkg'
vfiles := v.v_files_from_dir('$v.lang_dir/vlib/$pkg')
idir := os.getwd()
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
for file in vfiles {
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
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
// TmpPath/vlib
// These were generated by vfmt
if v.pref.build_mode == .default_mode || v.pref.build_mode == .build {
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)
for vfile in vfiles {
v.files << vfile