diff options
| author | ruki <[email protected]> | 2020-01-04 00:19:44 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-01-04 00:19:44 +0800 |
| commit | 56e004e096ce9fe1cca0ceb1f2808b47073f700c (patch) | |
| tree | 0a2a9fb25029a3faf5cab5327ec824cd5aa0ec9d | |
| parent | ff793d251bfc6814127953751bc3a47bf029b613 (diff) | |
fix check depend mtime
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 8edf450e8..54023b669 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -47,30 +47,17 @@ function is_changed(dependinfo, opt) end -- check the dependent files are changed? - local lastmtime = nil - _g.file_results = _g.file_results or {} + 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 - -- optimization: this file has been not checked? - local status = _g.file_results[file] - if status == nil then + -- get and cache the file mtime + local mtime = files_mtime[file] or (os.isfile(file) and os.mtime(file) or nil) + files_mtime[file] = mtime - -- optimization: only uses the mtime of first object file - lastmtime = lastmtime or opt.lastmtime or 0 - - -- source and header files have been changed? - if not os.isfile(file) or os.mtime(file) > lastmtime then - - -- mark this file as changed - _g.file_results[file] = true - return true - end - - -- mark this file as not changed - _g.file_results[file] = false - - -- has been checked and changed? - elseif status then + -- source and header files have been changed? + if mtime == nil or mtime > lastmtime then return true end end |
