Skip to content

Commit

Permalink
Merge pull request #84 from nozyh/feature/trace_manual_file_change
Browse files Browse the repository at this point in the history
Check all output files are newer than input files before skipping a task
  • Loading branch information
beam2d committed Aug 13, 2014
2 parents 5722773 + f6dcf43 commit 8f32135
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions maflib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,36 @@ def __init__(self, env, generator):
self.inputs = [ExperimentNode(s) for s in self.inputs]
self.outputs = [ExperimentNode(s) for s in self.outputs]

def runnable_status(self):
"""Override :py:meth:`waflib.Task.Task.runnable_status` to add extra runnable
condition checkers.
"""

status = super(ExperimentTask, self).runnable_status()

if status != waflib.Task.SKIP_ME:
return status

# addtional condition checks if status is SKIP_ME
def node_time(n):
try:
return os.path.getmtime(n.abspath())
except OSError:
return 0

# Run if some input node is newer than some output node.
# This strange condition happens when a user manually delete/modify
# a file in build directory; waf doesn't care these changes so
# we trace here by comparing modification dates of files.
if self.inputs and self.outputs:
input_update_date = max([node_time(n) for n in self.inputs])
output_update_date = min([node_time(n) for n in self.outputs])

if input_update_date > output_update_date:
return waflib.Task.RUN_ME

return waflib.Task.SKIP_ME

def sig_explicit_deps(self):
"""Calculates the hash value of this task.
Expand Down

0 comments on commit 8f32135

Please sign in to comment.