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

builder: if fpath is a descendant of modules folder add it as a search path

This commit is contained in:
joe-conigliaro 2020-12-22 22:32:02 +11:00
parent 7224cd667c
commit d5b03d16e0
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1

View File

@ -241,6 +241,17 @@ pub fn (b &Builder) find_module_path(mod string, fpath string) ?string {
module_lookup_paths << vmod_file_location.vmod_folder
}
module_lookup_paths << b.module_search_paths
// go up through parents looking for modules a folder.
// we need a proper solution that works most of the time. look at vdoc.get_parent_mod
if fpath.contains(os.path_separator + 'modules' + os.path_separator) {
parts := fpath.split(os.path_separator)
for i := parts.len - 2; i >= 0; i-- {
if parts[i] == 'modules' {
module_lookup_paths << parts[0..i + 1].join(os.path_separator)
break
}
}
}
for search_path in module_lookup_paths {
try_path := os.join_path(search_path, mod_path)
if b.pref.is_verbose {