v.vmod: cleanup vmod.mod_file_cacher API
parent
2046ae78df
commit
f6bdb3ae81
|
@ -197,7 +197,7 @@ fn module_path(mod string) string {
|
|||
|
||||
pub fn (b Builder) find_module_path(mod, fpath string) ?string {
|
||||
// support @VROOT/v.mod relative paths:
|
||||
vmod_file_location := vmod.mod_file_cacher.get(fpath)
|
||||
vmod_file_location := vmod.mod_file_cacher.get_by_file(fpath)
|
||||
mod_path := module_path(mod)
|
||||
mut module_lookup_paths := []string{}
|
||||
if vmod_file_location.vmod_file.len != 0 && vmod_file_location.vmod_folder !in b.module_search_paths {
|
||||
|
|
|
@ -22,7 +22,7 @@ fn (mut p Parser) hash() ast.HashStmt {
|
|||
mut flag := val[5..]
|
||||
// expand `@VROOT` to its absolute path
|
||||
if flag.contains('@VROOT') {
|
||||
vmod_file_location := vmod.mod_file_cacher.get(p.file_name_dir)
|
||||
vmod_file_location := vmod.mod_file_cacher.get_by_folder(p.file_name_dir)
|
||||
if vmod_file_location.vmod_file.len == 0 {
|
||||
// There was no actual v.mod file found.
|
||||
p.error('To use @VROOT, you need' + ' to have a "v.mod" file in ${p.file_name_dir},' +
|
||||
|
|
|
@ -796,7 +796,7 @@ pub fn (mut s Scanner) scan() token.Token {
|
|||
}
|
||||
if name == 'VMOD_FILE' {
|
||||
if s.vmod_file_content.len == 0 {
|
||||
vmod_file_location := vmod.mod_file_cacher.get( os.dir( os.real_path(s.file_path) ) )
|
||||
vmod_file_location := vmod.mod_file_cacher.get_by_file( s.file_path )
|
||||
if vmod_file_location.vmod_file.len == 0 {
|
||||
s.error('@VMOD_FILE can be used only in projects, that have v.mod file')
|
||||
}
|
||||
|
|
|
@ -58,7 +58,13 @@ pub fn (mcache &ModFileCacher) dump() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut mcache ModFileCacher) get(mfolder string) ModFileAndFolder {
|
||||
|
||||
pub fn (mut mcache ModFileCacher) get_by_file(vfile string) ModFileAndFolder {
|
||||
return mcache.get_by_folder( os.dir( vfile ) )
|
||||
}
|
||||
|
||||
pub fn (mut mcache ModFileCacher) get_by_folder(vfolder string) ModFileAndFolder {
|
||||
mfolder := os.real_path( vfolder )
|
||||
if mfolder in mcache.cache {
|
||||
return mcache.cache[ mfolder ]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue