Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check all output files are newer than input files before skipping a task #83

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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