modules: create the modules directory if it's missing, use cache/

pull/2300/head
Alexander Medvednikov 2019-10-12 05:04:56 +03:00
parent acbca7584b
commit b107b4f1e5
4 changed files with 19 additions and 5 deletions

View File

@ -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

View File

@ -627,7 +627,7 @@ fn (v mut V) add_v_files_to_compile() {
for file in v.get_user_files() {
mut p := v.new_parser_from_file(file)
// set mod so we dont have to resolve submodule
if v.pref.build_mode == .build_module &&
if v.pref.build_mode == .build_module &&
file.contains(v.mod.replace('.', os.PathSeparator)) {
p.mod = v.mod
}
@ -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')

View File

@ -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 }

View File

@ -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)
}
}
}