@@ -103,14 +103,23 @@ function is_changed(dependinfo, opt)
103103 end
104104
105105 -- check whether the dependent files are changed
106+ local timecache = opt .timecache
106107 local lastmtime = opt .lastmtime or 0
107108 _g .files_mtime = _g .files_mtime or {}
108109 local files_mtime = _g .files_mtime
109110 for _ , file in ipairs (files ) do
110111
111112 -- get and cache the file mtime
112- local mtime = files_mtime [file ] or os .mtime (file )
113- files_mtime [file ] = mtime
113+ local mtime
114+ if timecache then
115+ mtime = files_mtime [file ]
116+ if mtime == nil then
117+ mtime = os .mtime (file )
118+ files_mtime [file ] = mtime
119+ end
120+ else
121+ mtime = os .mtime (file )
122+ end
114123
115124 -- source and header files have been changed or not exists?
116125 if mtime == 0 or mtime > lastmtime then
186195-- files = {sourcefile, ...}})
187196--
188197function on_changed (callback , opt )
189-
190- -- init option
191198 opt = opt or {}
192199
193200 -- dry run? we only do callback directly and do not change any status
@@ -209,7 +216,10 @@ function on_changed(callback, opt)
209216
210217 -- @note we use mtime(dependfile) instead of mtime(objectfile) to ensure the object file is is fully compiled.
211218 -- @see https://github.com/xmake-io/xmake/issues/748
212- if not is_changed (dependinfo , {lastmtime = opt .lastmtime or os .mtime (dependfile ), values = opt .values , files = opt .files }) then
219+ if not is_changed (dependinfo , {
220+ timecache = opt .timecache ,
221+ lastmtime = opt .lastmtime or os .mtime (dependfile ),
222+ values = opt .values , files = opt .files }) then
213223 return
214224 end
215225
0 commit comments