summaryrefslogtreecommitdiff
path: root/xmake/modules/core/project/depend.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-22 23:24:58 +0800
committerruki <[email protected]>2025-01-22 23:24:58 +0800
commitf42c68d86a82e4004748ce4fdbefab5d9f3c9736 (patch)
treee089f879f989c51ca075e778fe24506d50e388f5 /xmake/modules/core/project/depend.lua
parente7e33166b1ebfbb67b9a48a581414064a61da9ac (diff)
fix depend.is_changed #6089
Diffstat (limited to 'xmake/modules/core/project/depend.lua')
-rw-r--r--xmake/modules/core/project/depend.lua20
1 files changed, 15 insertions, 5 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