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.

82 lines
1.9KB

  1. #! /usr/bin/env python
  2. # Thomas Nagy, 2011
  3. # Try to cancel the tasks that cannot run with the option -k when an error occurs:
  4. # 1 direct file dependencies
  5. # 2 tasks listed in the before/after/ext_in/ext_out attributes
  6. from waflib import Task, Runner
  7. Task.CANCELED = 4
  8. def cancel_next(self, tsk):
  9. if not isinstance(tsk, Task.TaskBase):
  10. return
  11. if tsk.hasrun >= Task.SKIPPED:
  12. # normal execution, no need to do anything here
  13. return
  14. try:
  15. canceled_tasks, canceled_nodes = self.canceled_tasks, self.canceled_nodes
  16. except AttributeError:
  17. canceled_tasks = self.canceled_tasks = set([])
  18. canceled_nodes = self.canceled_nodes = set([])
  19. try:
  20. canceled_nodes.update(tsk.outputs)
  21. except AttributeError:
  22. pass
  23. try:
  24. canceled_tasks.add(tsk)
  25. except AttributeError:
  26. pass
  27. def get_out(self):
  28. tsk = self.out.get()
  29. if not self.stop:
  30. self.add_more_tasks(tsk)
  31. self.count -= 1
  32. self.dirty = True
  33. self.cancel_next(tsk) # new code
  34. def error_handler(self, tsk):
  35. if not self.bld.keep:
  36. self.stop = True
  37. self.error.append(tsk)
  38. self.cancel_next(tsk) # new code
  39. Runner.Parallel.cancel_next = cancel_next
  40. Runner.Parallel.get_out = get_out
  41. Runner.Parallel.error_handler = error_handler
  42. def get_next_task(self):
  43. tsk = self.get_next_task_smart_continue()
  44. if not tsk:
  45. return tsk
  46. try:
  47. canceled_tasks, canceled_nodes = self.canceled_tasks, self.canceled_nodes
  48. except AttributeError:
  49. pass
  50. else:
  51. # look in the tasks that this one is waiting on
  52. # if one of them was canceled, cancel this one too
  53. for x in tsk.run_after:
  54. if x in canceled_tasks:
  55. tsk.hasrun = Task.CANCELED
  56. self.cancel_next(tsk)
  57. break
  58. else:
  59. # so far so good, now consider the nodes
  60. for x in getattr(tsk, 'inputs', []) + getattr(tsk, 'deps', []):
  61. if x in canceled_nodes:
  62. tsk.hasrun = Task.CANCELED
  63. self.cancel_next(tsk)
  64. break
  65. return tsk
  66. Runner.Parallel.get_next_task_smart_continue = Runner.Parallel.get_next_task
  67. Runner.Parallel.get_next_task = get_next_task