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

compiler: cache modules if they are not built yet

This commit is contained in:
Alexander Medvednikov 2019-10-10 22:27:22 +03:00
parent a5ccc4673b
commit e1dd4c19b5
5 changed files with 11 additions and 13 deletions

View File

@ -111,20 +111,14 @@ fn (v mut V) cc() {
a << '-c' a << '-c'
} }
else if v.pref.is_debug { else if v.pref.is_debug {
vexe := os.executable()
builtin_o_path := '$v_modules_path/vlib/builtin.o' builtin_o_path := '$v_modules_path/vlib/builtin.o'
if os.file_exists(builtin_o_path) { if os.file_exists(builtin_o_path) {
libs = builtin_o_path libs = builtin_o_path
} else { } else {
println('$builtin_o_path not found... build module builtin') println('$builtin_o_path not found... building module builtin')
os.system('$vexe build module vlib/builtin')
} }
// '$v_modules_path/vlib/strings.o '+
// '$v_modules_path/vlib/math.o '
/*
if !os.file_exists(libs) {
println('object file `$libs` not found')
exit(1)
}
*/
for imp in v.table.imports { for imp in v.table.imports {
if imp == 'webview' { if imp == 'webview' {
continue continue
@ -134,7 +128,8 @@ fn (v mut V) cc() {
if os.file_exists(path) { if os.file_exists(path) {
libs += ' ' + path libs += ' ' + path
} else { } else {
println('$path not found... build module $imp') println('$path not found... building module $imp')
os.system('$vexe build module vlib/$imp')
} }
} }
} }

View File

@ -419,8 +419,8 @@ fn (p mut Parser) fn_decl() {
p.genln('pthread_mutex_lock(&live_fn_mutex);') p.genln('pthread_mutex_lock(&live_fn_mutex);')
} }
if f.name == 'main__main' || f.name == 'main' || f.name == 'WinMain' { if f.name in ['main__main', 'main', 'WinMain'] {
if p.pref.is_test && !p.scanner.file_path.contains('/volt') { if p.pref.is_test {
p.error_with_token_index('tests cannot have function `main`', f.fn_name_token_idx) p.error_with_token_index('tests cannot have function `main`', f.fn_name_token_idx)
} }
} }

View File

@ -1686,6 +1686,7 @@ fn (p mut Parser) bterm() string {
// also called on *, &, @, . (enum) // also called on *, &, @, . (enum)
fn (p mut Parser) name_expr() string { fn (p mut Parser) name_expr() string {
//println('n')
p.has_immutable_field = false p.has_immutable_field = false
p.is_const_literal = false p.is_const_literal = false
ph := p.cgen.add_placeholder() ph := p.cgen.add_placeholder()
@ -2958,7 +2959,7 @@ fn (p mut Parser) map_init() string {
mut i := 0 mut i := 0
for { for {
key := p.lit key := p.lit
keys_gen += 'tos2((byte*)"$key"), ' keys_gen += 'tos3("$key"), '
p.check(.str) p.check(.str)
p.check(.colon) p.check(.colon)
p.cgen.start_tmp() p.cgen.start_tmp()

View File

@ -177,6 +177,7 @@ pub fn (m &map) keys() []string {
} }
fn (m map) get(key string, out voidptr) bool { fn (m map) get(key string, out voidptr) bool {
//println('g')
if m.root == 0 { if m.root == 0 {
return false return false
} }

View File

@ -333,6 +333,7 @@ pub fn exec(cmd string) ?Result {
} }
} }
// `system` works like `exec()`, but only returns a return code.
pub fn system(cmd string) int { pub fn system(cmd string) int {
mut ret := int(0) mut ret := int(0)
$if windows { $if windows {