builder: module caching fixes
parent
f005079e0b
commit
eb8973c362
|
@ -165,8 +165,8 @@ fn parse_args(args []string) (&pref.Preferences, string) {
|
||||||
'-showcc' {
|
'-showcc' {
|
||||||
res.show_cc = true
|
res.show_cc = true
|
||||||
}
|
}
|
||||||
'-cache' {
|
'-usecache' {
|
||||||
res.is_cache = true
|
res.use_cache = true
|
||||||
}
|
}
|
||||||
'-keepc' {
|
'-keepc' {
|
||||||
res.keep_c = true
|
res.keep_c = true
|
||||||
|
|
|
@ -215,7 +215,7 @@ fn (mut v Builder) cc() {
|
||||||
mut libs := '' // builtin.o os.o http.o etc
|
mut libs := '' // builtin.o os.o http.o etc
|
||||||
if v.pref.build_mode == .build_module {
|
if v.pref.build_mode == .build_module {
|
||||||
a << '-c'
|
a << '-c'
|
||||||
} else if v.pref.is_cache {
|
} else if v.pref.use_cache {
|
||||||
/*
|
/*
|
||||||
QTODO
|
QTODO
|
||||||
builtin_o_path := os.join_path(pref.default_module_path, 'cache', 'vlib', 'builtin.o')
|
builtin_o_path := os.join_path(pref.default_module_path, 'cache', 'vlib', 'builtin.o')
|
||||||
|
@ -305,13 +305,18 @@ fn (mut v Builder) cc() {
|
||||||
// add all flags (-I -l -L etc) not .o files
|
// add all flags (-I -l -L etc) not .o files
|
||||||
a << cflags.c_options_without_object_files()
|
a << cflags.c_options_without_object_files()
|
||||||
a << libs
|
a << libs
|
||||||
if v.pref.is_cache {
|
if v.pref.use_cache {
|
||||||
cached_files := [ 'builtin.o', 'math.o']
|
//vexe := pref.vexe_path()
|
||||||
for cfile in cached_files {
|
|
||||||
ofile := os.join_path(pref.default_module_path, 'cache', 'vlib', cfile)
|
cached_modules:= [ 'builtin', 'os' ]//, 'math']
|
||||||
if os.exists(ofile) {
|
for cfile in cached_modules{
|
||||||
a << ofile
|
ofile := os.join_path(pref.default_module_path, 'cache', 'vlib', cfile + '.o')
|
||||||
|
if !os.exists(ofile) {
|
||||||
|
println('${cfile}.o is missing. Building...')
|
||||||
|
println('$vexe build-module vlib/$cfile')
|
||||||
|
os.system('$vexe build-module vlib/$cfile')
|
||||||
}
|
}
|
||||||
|
a << ofile
|
||||||
}
|
}
|
||||||
if !is_cc_tcc {
|
if !is_cc_tcc {
|
||||||
$if linux {
|
$if linux {
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
||||||
*/
|
*/
|
||||||
//
|
//
|
||||||
g.fn_args(it.args, it.is_variadic)
|
g.fn_args(it.args, it.is_variadic)
|
||||||
if it.no_body || (g.pref.is_cache && it.is_builtin) {
|
if it.no_body || (g.pref.use_cache && it.is_builtin) {
|
||||||
// Just a function header.
|
// Just a function header.
|
||||||
// Builtin function bodies are defined in builtin.o
|
// Builtin function bodies are defined in builtin.o
|
||||||
g.definitions.writeln(');')
|
g.definitions.writeln(');')
|
||||||
|
@ -104,7 +104,7 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
|
||||||
}
|
}
|
||||||
// Profiling mode? Start counting at the beginning of the function (save current time).
|
// Profiling mode? Start counting at the beginning of the function (save current time).
|
||||||
if g.pref.is_prof {
|
if g.pref.is_prof {
|
||||||
g.profile_fn( it.name, is_main )
|
g.profile_fn(it.name, is_main)
|
||||||
}
|
}
|
||||||
g.stmts(it.stmts)
|
g.stmts(it.stmts)
|
||||||
// ////////////
|
// ////////////
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub mut:
|
||||||
show_cc bool // -showcc, print cc command
|
show_cc bool // -showcc, print cc command
|
||||||
// NB: passing -cg instead of -g will set is_vlines to false and is_g to true, thus making v generate cleaner C files,
|
// NB: passing -cg instead of -g will set is_vlines to false and is_g to true, thus making v generate cleaner C files,
|
||||||
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
// which are sometimes easier to debug / inspect manually than the .tmp.c files by plain -g (when/if v line number generation breaks).
|
||||||
is_cache bool // turns on v usage of the module cache to speed up compilation.
|
use_cache bool // turns on v usage of the module cache to speed up compilation.
|
||||||
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
|
is_stats bool // `v -stats file_test.v` will produce more detailed statistics for the tests that were run
|
||||||
no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers)
|
no_auto_free bool // `v -nofree` disable automatic `free()` insertion for better performance in some applications (e.g. compilers)
|
||||||
// TODO Convert this into a []string
|
// TODO Convert this into a []string
|
||||||
|
|
Loading…
Reference in New Issue