From ab20db8e6e353a75eb666939459c40fffe924f8e Mon Sep 17 00:00:00 2001 From: AtjonTV Date: Tue, 2 Jul 2019 21:55:57 +0200 Subject: [PATCH] look for modules in current path --- compiler/main.v | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index 843d6d3b39..d28e7f2727 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -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