modules: create the modules directory if it's missing, use cache/
parent
acbca7584b
commit
b107b4f1e5
|
@ -120,7 +120,7 @@ fn (v mut V) cc() {
|
|||
}
|
||||
else if v.pref.is_debug {
|
||||
vexe := os.executable()
|
||||
builtin_o_path := '$v_modules_path/vlib/builtin.o'
|
||||
builtin_o_path := '$v_modules_path/cache/builtin.o'
|
||||
if os.file_exists(builtin_o_path) {
|
||||
libs = builtin_o_path
|
||||
} else {
|
||||
|
@ -132,7 +132,7 @@ fn (v mut V) cc() {
|
|||
if imp == 'webview' { continue }
|
||||
|
||||
imp_path := imp.replace('.', os.PathSeparator)
|
||||
path := '$v_modules_path/vlib/${imp_path}.o'
|
||||
path := '$v_modules_path/cache/${imp_path}.o'
|
||||
println('adding ${imp_path}.o')
|
||||
if os.file_exists(path) {
|
||||
libs += ' ' + path
|
||||
|
|
|
@ -802,6 +802,12 @@ fn (v &V) log(s string) {
|
|||
}
|
||||
|
||||
fn new_v(args[]string) &V {
|
||||
// Create modules dirs if they are missing
|
||||
if !os.dir_exists(v_modules_path) {
|
||||
os.mkdir(v_modules_path)
|
||||
os.mkdir('$v_modules_path${os.PathSeparator}cache')
|
||||
}
|
||||
|
||||
mut vgen_buf := strings.new_builder(1000)
|
||||
vgen_buf.writeln('module main\nimport strings')
|
||||
|
||||
|
|
|
@ -120,8 +120,6 @@ fn (v &V) generate_vh() {
|
|||
}
|
||||
// os.mkdir(os.realpath(dir))
|
||||
}
|
||||
println(path)
|
||||
|
||||
file := os.create(path) or { panic(err) }
|
||||
// Consts
|
||||
mod_def := if v.mod.contains('.') { v.mod.all_after('.') } else { v.mod }
|
||||
|
|
10
vlib/os/os.v
10
vlib/os/os.v
|
@ -858,3 +858,13 @@ pub fn print_backtrace() {
|
|||
*/
|
||||
}
|
||||
|
||||
pub fn mkdir_all(path string) {
|
||||
mut p := ''
|
||||
for subdir in path.split(os.PathSeparator) {
|
||||
p += os.PathSeparator + subdir
|
||||
if !os.dir_exists(p) {
|
||||
os.mkdir(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue