jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.9KB

  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2010 (ita)
  4. """
  5. This tool modifies the task signature scheme to store and obtain
  6. information about the task execution (why it must run, etc)::
  7. def configure(conf):
  8. conf.load('why')
  9. After adding the tool, a full rebuild is necessary:
  10. waf clean build --zones=task
  11. """
  12. from waflib import Task, Utils, Logs, Errors
  13. def signature(self):
  14. # compute the result one time, and suppose the scan_signature will give the good result
  15. try: return self.cache_sig
  16. except AttributeError: pass
  17. self.m = Utils.md5()
  18. self.m.update(self.hcode.encode())
  19. id_sig = self.m.digest()
  20. # explicit deps
  21. self.m = Utils.md5()
  22. self.sig_explicit_deps()
  23. exp_sig = self.m.digest()
  24. # env vars
  25. self.m = Utils.md5()
  26. self.sig_vars()
  27. var_sig = self.m.digest()
  28. # implicit deps / scanner results
  29. self.m = Utils.md5()
  30. if self.scan:
  31. try:
  32. self.sig_implicit_deps()
  33. except Errors.TaskRescan:
  34. return self.signature()
  35. impl_sig = self.m.digest()
  36. ret = self.cache_sig = impl_sig + id_sig + exp_sig + var_sig
  37. return ret
  38. Task.Task.signature = signature
  39. old = Task.Task.runnable_status
  40. def runnable_status(self):
  41. ret = old(self)
  42. if ret == Task.RUN_ME:
  43. try:
  44. old_sigs = self.generator.bld.task_sigs[self.uid()]
  45. except (KeyError, AttributeError):
  46. Logs.debug("task: task must run as no previous signature exists")
  47. else:
  48. new_sigs = self.cache_sig
  49. def v(x):
  50. return Utils.to_hex(x)
  51. Logs.debug("Task %r" % self)
  52. msgs = ['* Implicit or scanner dependency', '* Task code', '* Source file, explicit or manual dependency', '* Configuration data variable']
  53. tmp = 'task: -> %s: %s %s'
  54. for x in range(len(msgs)):
  55. l = len(Utils.SIG_NIL)
  56. a = new_sigs[x*l : (x+1)*l]
  57. b = old_sigs[x*l : (x+1)*l]
  58. if (a != b):
  59. Logs.debug(tmp % (msgs[x].ljust(35), v(a), v(b)))
  60. return ret
  61. Task.Task.runnable_status = runnable_status