build_file_timestamp.py 803 B

123456789101112131415161718192021222324
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2015
  4. """
  5. Force files to also depend on the timestamps of those located in the build directory. You may
  6. want to use this to force partial rebuilds, see playground/track_output_files/ for a working example.
  7. Note that there is a variety of ways to implement this, one may want use timestamps on source files too for example,
  8. or one may want to hash theA files in the source directory only under certain conditions (md5_tstamp tool)
  9. """
  10. import os
  11. from waflib import Node, Utils
  12. def get_bld_sig(self):
  13. if not self.is_bld() or self.ctx.bldnode is self.ctx.srcnode:
  14. return Utils.h_file(self.abspath())
  15. val = Utils.h_file(self.abspath()) + str(os.stat(self.abspath()).st_mtime).encode('latin-1')
  16. return val
  17. Node.Node.get_bld_sig = get_bld_sig