diff options
| author | ruki <[email protected]> | 2025-01-22 15:14:55 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-22 15:14:55 +0800 |
| commit | 5ceda7120b2c8d702196e48ae6e11c848da611da (patch) | |
| tree | e089f879f989c51ca075e778fe24506d50e388f5 | |
| parent | e7e33166b1ebfbb67b9a48a581414064a61da9ac (diff) | |
| parent | f42c68d86a82e4004748ce4fdbefab5d9f3c9736 (diff) | |
Merge pull request #6104 from xmake-io/depend
fix depend.is_changed #6089
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 20 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/object.lua | 7 |
2 files changed, 21 insertions, 6 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 22840f09e..61d51c4a3 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -103,14 +103,23 @@ function is_changed(dependinfo, opt) end -- check whether the dependent files are changed + local timecache = opt.timecache local lastmtime = opt.lastmtime or 0 _g.files_mtime = _g.files_mtime or {} local files_mtime = _g.files_mtime for _, file in ipairs(files) do -- get and cache the file mtime - local mtime = files_mtime[file] or os.mtime(file) - files_mtime[file] = mtime + local mtime + if timecache then + mtime = files_mtime[file] + if mtime == nil then + mtime = os.mtime(file) + files_mtime[file] = mtime + end + else + mtime = os.mtime(file) + end -- source and header files have been changed or not exists? if mtime == 0 or mtime > lastmtime then @@ -186,8 +195,6 @@ end -- files = {sourcefile, ...}}) -- function on_changed(callback, opt) - - -- init option opt = opt or {} -- dry run? we only do callback directly and do not change any status @@ -209,7 +216,10 @@ function on_changed(callback, opt) -- @note we use mtime(dependfile) instead of mtime(objectfile) to ensure the object file is is fully compiled. -- @see https://github.com/xmake-io/xmake/issues/748 - if not is_changed(dependinfo, {lastmtime = opt.lastmtime or os.mtime(dependfile), values = opt.values, files = opt.files}) then + if not is_changed(dependinfo, { + timecache = opt.timecache, + lastmtime = opt.lastmtime or os.mtime(dependfile), + values = opt.values, files = opt.files}) then return end diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua index 25bf3385b..60137f3cb 100644 --- a/xmake/modules/private/action/build/object.lua +++ b/xmake/modules/private/action/build/object.lua @@ -55,9 +55,14 @@ function _do_build_file(target, sourcefile, opt) -- -- we also need avoid the problem of not being able to recompile after the objectfile has been deleted -- @see https://github.com/xmake-io/xmake/issues/2551#issuecomment-1183922208 + -- + -- optimization: + -- we enable time cache to speed up is_changed, because there are a lot of header files in depfiles. + -- but we need to cache it in link stage, maybe some objectfiles will be updated. + -- @see https://github.com/xmake-io/xmake/issues/6089 local depvalues = {compinst:program(), compflags} local lastmtime = os.isfile(objectfile) and os.mtime(dependfile) or 0 - if not dryrun and not depend.is_changed(dependinfo, {lastmtime = lastmtime, values = depvalues}) then + if not dryrun and not depend.is_changed(dependinfo, {lastmtime = lastmtime, values = depvalues, timecache = true}) then return end |
