builder: update cached .o files when their .c file is newer

pull/9539/head^2
Delyan Angelov 2021-04-02 08:49:54 +03:00
parent 69ba93f954
commit 897cd4cec2
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 10 additions and 3 deletions

View File

@ -931,9 +931,14 @@ fn (mut v Builder) build_thirdparty_obj_file(path string, moduleflags []cflag.CF
obj_path := os.real_path(path)
cfile := '${obj_path[..obj_path.len - 2]}.c'
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(cfile) && os.file_last_mod_unix(opath) < os.file_last_mod_unix(cfile) {
rebuild_reason_message = '$opath is older than $cfile, rebuilding ...'
} else {
return
}
}
if os.exists(obj_path) {
// Some .o files are distributed with no source
// 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) }
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:
current_folder := os.getwd()
@ -968,8 +973,10 @@ 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 {
panic(err)
}
if res.output != '' {
println(res.output)
}
}
fn missing_compiler_info() string {
$if windows {