builder: update cached .o files when their .c file is newer
parent
69ba93f954
commit
897cd4cec2
|
@ -931,9 +931,14 @@ fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CF
|
||||||
obj_path := os.real_path(path)
|
obj_path := os.real_path(path)
|
||||||
cfile := '${obj_path[..obj_path.len - 2]}.c'
|
cfile := '${obj_path[..obj_path.len - 2]}.c'
|
||||||
opath := v.pref.cache_manager.postfix_with_key2cpath('.o', obj_path)
|
opath := v.pref.cache_manager.postfix_with_key2cpath('.o', obj_path)
|
||||||
|
mut rebuild_reason_message := '$obj_path not found, building it in $opath ...'
|
||||||
if os.exists(opath) {
|
if os.exists(opath) {
|
||||||
|
if os.exists(cfile) && os.file_last_mod_unix(opath) < os.file_last_mod_unix(cfile) {
|
||||||
|
rebuild_reason_message = '$opath is older than $cfile, rebuilding ...'
|
||||||
|
} else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if os.exists(obj_path) {
|
if os.exists(obj_path) {
|
||||||
// Some .o files are distributed with no source
|
// Some .o files are distributed with no source
|
||||||
// for example thirdparty\tcc\lib\openlibm.o
|
// for example thirdparty\tcc\lib\openlibm.o
|
||||||
|
@ -942,7 +947,7 @@ fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CF
|
||||||
os.cp(obj_path, opath) or { panic(err) }
|
os.cp(obj_path, opath) or { panic(err) }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
println('$obj_path not found, building it in $opath ...')
|
println(rebuild_reason_message)
|
||||||
//
|
//
|
||||||
// prepare for tcc, it needs relative paths to thirdparty/tcc to work:
|
// prepare for tcc, it needs relative paths to thirdparty/tcc to work:
|
||||||
current_folder := os.getwd()
|
current_folder := os.getwd()
|
||||||
|
@ -968,7 +973,9 @@ fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CF
|
||||||
v.pref.cache_manager.save('.description.txt', obj_path, '${obj_path:-30} @ $cmd\n') or {
|
v.pref.cache_manager.save('.description.txt', obj_path, '${obj_path:-30} @ $cmd\n') or {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if res.output != '' {
|
||||||
println(res.output)
|
println(res.output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn missing_compiler_info() string {
|
fn missing_compiler_info() string {
|
||||||
|
|
Loading…
Reference in New Issue