build_file_tracker.py 898 B

12345678910111213141516171819202122232425262728
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2015
  4. """
  5. Force files to 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 the files in the source directory only under certain conditions (md5_tstamp tool)
  9. or to hash the file in the build directory with its timestamp
  10. """
  11. import os
  12. from waflib import Node, Utils
  13. def get_bld_sig(self):
  14. if not self.is_bld() or self.ctx.bldnode is self.ctx.srcnode:
  15. return Utils.h_file(self.abspath())
  16. try:
  17. # add the creation time to the signature
  18. return self.sig + str(os.stat(self.abspath()).st_mtime)
  19. except AttributeError:
  20. return None
  21. Node.Node.get_bld_sig = get_bld_sig