parser: do not duplicate table imports

pull/5958/head
Alexander Medvednikov 2020-07-23 21:59:34 +02:00
parent 75aa92b907
commit 653d40bfe8
3 changed files with 15 additions and 9 deletions

View File

@ -289,28 +289,29 @@ fn (mut v Builder) cc() {
println('$builtin_o_path not found... building module builtin')
os.system('$vexe build module vlib${os.path_separator}builtin')
}
*/
for imp in v.table.imports {
if imp.contains('vweb') {
continue
} // not working
}
// not working
if imp == 'webview' {
continue
}
// println('cache: import "$imp"')
imp_path := imp.replace('.', os.path_separator)
path := '${pref.default_module_path}${os.path_separator}cache${os.path_separator}vlib${os.path_separator}${imp_path}.o'
path := '$pref.default_module_path${os.path_separator}cache${os.path_separator}vlib$os.path_separator${imp_path}.o'
// println('adding ${imp_path}.o')
if os.exists(path) {
libs += ' ' + path
}
else {
} else {
println('$path not found... building module $imp')
os.system('$vexe build module vlib${os.path_separator}$imp_path')
os.system('$vexe build-module vlib$os.path_separator$imp_path')
}
if path.ends_with('vlib/ui.o') {
a << '-framework Cocoa -framework Carbon'
}
}
*/
}
if v.pref.sanitize {
a << '-fsanitize=leak'

View File

@ -732,7 +732,10 @@ fn (mut g Gen) stmt(node ast.Stmt) {
mut skip := false
pos := g.out.buf.len
if g.pref.build_mode == .build_module {
if !node.name.starts_with(g.module_built + '.') && node.mod != g.module_built {
// if node.name.contains('parse_text') {
// println('!!! $node.name mod=$node.mod, built=$g.module_built')
// }
if !node.name.starts_with(g.module_built + '.') && node.mod != g.module_built.after('/') {
// Skip functions that don't have to be generated
// for this module.
skip = true

View File

@ -1398,8 +1398,10 @@ fn (mut p Parser) import_stmt() ast.Import {
}
}
p.imports[mod_alias] = mod_name
p.table.imports << mod_name
p.ast_imports << node
if mod_name !in p.table.imports {
p.table.imports << mod_name
p.ast_imports << node
}
return node
}