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

builder: a small -usecache fix, when v is run in subfolders

This commit is contained in:
Delyan Angelov 2020-11-08 09:18:05 +02:00
parent 4b35495fbe
commit 6da8454b3b

View File

@ -127,6 +127,10 @@ fn (mut v Builder) post_process_c_compiler_output(res os.Result) {
fn (mut v Builder) rebuild_cached_module(vexe string, imp_path string) string { fn (mut v Builder) rebuild_cached_module(vexe string, imp_path string) string {
res := v.pref.cache_manager.exists('.o', imp_path) or { res := v.pref.cache_manager.exists('.o', imp_path) or {
println('Cached $imp_path .o file not found... Building .o file for $imp_path') println('Cached $imp_path .o file not found... Building .o file for $imp_path')
// do run `v build-module x` always in main vfolder; x can be a relative path
pwd := os.getwd()
vroot := os.dir(vexe)
os.chdir(vroot)
boptions := v.pref.build_options.join(' ') boptions := v.pref.build_options.join(' ')
rebuild_cmd := '$vexe $boptions build-module $imp_path' rebuild_cmd := '$vexe $boptions build-module $imp_path'
// eprintln('>> rebuild_cmd: $rebuild_cmd') // eprintln('>> rebuild_cmd: $rebuild_cmd')
@ -134,6 +138,7 @@ fn (mut v Builder) rebuild_cached_module(vexe string, imp_path string) string {
rebuilded_o := v.pref.cache_manager.exists('.o', imp_path) or { rebuilded_o := v.pref.cache_manager.exists('.o', imp_path) or {
panic('could not rebuild cache module for $imp_path, error: $err') panic('could not rebuild cache module for $imp_path, error: $err')
} }
os.chdir(pwd)
return rebuilded_o return rebuilded_o
} }
return res return res