5 This module assumes that only one build context is running at a given time, which
6 is not the case if you want to execute configuration tests in parallel.
8 Store some values on the buildcontext mapping file paths to
9 stat values and md5 values (timestamp + md5)
10 this way the md5 hashes are computed only when timestamp change (can be faster)
11 There is usually little or no gain from enabling this, but it can be used to enable
12 the second level cache with timestamps (WAFCACHE)
14 You may have to run distclean or to remove the build directory before enabling/disabling
19 from waflib import Utils, Build, Context
24 Build.BuildContext.store_real
25 except AttributeError:
27 Context.DBFILE += '_md5tstamp'
29 Build.hashes_md5_tstamp = {}
30 Build.SAVED_ATTRS.append('hashes_md5_tstamp')
32 # save the hash cache as part of the default pickle file
33 self.hashes_md5_tstamp = Build.hashes_md5_tstamp
35 Build.BuildContext.store_real = Build.BuildContext.store
36 Build.BuildContext.store = store
39 # we need a module variable for h_file below
42 Build.hashes_md5_tstamp = self.hashes_md5_tstamp or {}
43 except AttributeError:
44 Build.hashes_md5_tstamp = {}
45 Build.BuildContext.restore_real = Build.BuildContext.restore
46 Build.BuildContext.restore = restore
49 st = os.stat(filename)
50 if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
52 if filename in Build.hashes_md5_tstamp:
53 if Build.hashes_md5_tstamp[filename][0] == str(st.st_mtime):
54 return Build.hashes_md5_tstamp[filename][1]
56 ret = Utils.h_file_no_md5(filename)
57 Build.hashes_md5_tstamp[filename] = (str(st.st_mtime), ret)
61 m.update(str(st.st_mtime))
62 m.update(str(st.st_size))
64 Build.hashes_md5_tstamp[filename] = (str(st.st_mtime), m.digest())
66 Utils.h_file_no_md5 = Utils.h_file