From bac3c0a63e7cb7cfbd6af20fea9673ee3f3cc667 Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Tue, 26 Nov 2019 11:45:26 +0800 Subject: [PATCH] compiler: add "modules/ " folder for searching local modules --- vlib/compiler/modules.v | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vlib/compiler/modules.v b/vlib/compiler/modules.v index 6994866fd1..2b1d4adbe5 100644 --- a/vlib/compiler/modules.v +++ b/vlib/compiler/modules.v @@ -154,13 +154,15 @@ fn (v &V) find_module_path(mod string) ?string { // Module search order: // 1) search in the *same* directory, as the compiled final v program source // (i.e. the . in `v .` or file.v in `v file.v`) - // 2) search in vlib/ - // 3.1) search in -vpath (if given) - // 3.2) search in ~/.vmodules/ (i.e. modules installed with vpm) (no -vpath) + // 2) search in the modules/ in the same directory. + // 3) search in vlib/ + // 4.1) search in -vpath (if given) + // 4.2) search in ~/.vmodules/ (i.e. modules installed with vpm) (no -vpath) modules_lookup_path := if v.pref.vpath.len > 0 { v.pref.vpath } else { v_modules_path } mod_path := v.module_path(mod) mut tried_paths := []string tried_paths << filepath.join(v.compiled_dir, mod_path) + tried_paths << filepath.join(v.compiled_dir, 'modules', mod_path) tried_paths << filepath.join(v.pref.vlib_path, mod_path) tried_paths << filepath.join(modules_lookup_path, mod_path) for try_path in tried_paths {