2011-09-10 11:13:51 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# Thomas Nagy, 2010 (ita)
|
|
|
|
|
|
|
|
"""
|
|
|
|
This tool modifies the task signature scheme to store and obtain
|
|
|
|
information about the task execution (why it must run, etc)::
|
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
conf.load('why')
|
|
|
|
|
2014-10-15 20:57:16 +02:00
|
|
|
After adding the tool, a full rebuild is necessary:
|
|
|
|
waf clean build --zones=task
|
2011-09-10 11:13:51 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
from waflib import Task, Utils, Logs, Errors
|
|
|
|
|
|
|
|
def signature(self):
|
|
|
|
# compute the result one time, and suppose the scan_signature will give the good result
|
2017-04-17 12:26:47 +02:00
|
|
|
try:
|
|
|
|
return self.cache_sig
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
2011-09-10 11:13:51 +02:00
|
|
|
|
|
|
|
self.m = Utils.md5()
|
2015-04-30 20:58:44 +02:00
|
|
|
self.m.update(self.hcode)
|
2011-09-10 11:13:51 +02:00
|
|
|
id_sig = self.m.digest()
|
|
|
|
|
|
|
|
# explicit deps
|
2015-01-22 21:46:35 +01:00
|
|
|
self.m = Utils.md5()
|
2011-09-10 11:13:51 +02:00
|
|
|
self.sig_explicit_deps()
|
|
|
|
exp_sig = self.m.digest()
|
|
|
|
|
|
|
|
# env vars
|
2015-01-22 21:46:35 +01:00
|
|
|
self.m = Utils.md5()
|
2011-09-10 11:13:51 +02:00
|
|
|
self.sig_vars()
|
|
|
|
var_sig = self.m.digest()
|
|
|
|
|
|
|
|
# implicit deps / scanner results
|
2015-01-22 21:46:35 +01:00
|
|
|
self.m = Utils.md5()
|
2011-09-10 11:13:51 +02:00
|
|
|
if self.scan:
|
|
|
|
try:
|
2011-09-10 12:20:18 +02:00
|
|
|
self.sig_implicit_deps()
|
2011-09-10 11:13:51 +02:00
|
|
|
except Errors.TaskRescan:
|
|
|
|
return self.signature()
|
2015-01-22 21:46:35 +01:00
|
|
|
impl_sig = self.m.digest()
|
2011-09-10 11:13:51 +02:00
|
|
|
|
2015-01-22 21:46:35 +01:00
|
|
|
ret = self.cache_sig = impl_sig + id_sig + exp_sig + var_sig
|
2011-09-10 11:13:51 +02:00
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
Task.Task.signature = signature
|
|
|
|
|
|
|
|
old = Task.Task.runnable_status
|
|
|
|
def runnable_status(self):
|
|
|
|
ret = old(self)
|
|
|
|
if ret == Task.RUN_ME:
|
|
|
|
try:
|
|
|
|
old_sigs = self.generator.bld.task_sigs[self.uid()]
|
2014-04-20 02:29:27 +02:00
|
|
|
except (KeyError, AttributeError):
|
2011-09-10 11:13:51 +02:00
|
|
|
Logs.debug("task: task must run as no previous signature exists")
|
|
|
|
else:
|
|
|
|
new_sigs = self.cache_sig
|
|
|
|
def v(x):
|
|
|
|
return Utils.to_hex(x)
|
|
|
|
|
2016-05-28 16:18:51 +02:00
|
|
|
Logs.debug('Task %r', self)
|
2015-01-22 21:46:35 +01:00
|
|
|
msgs = ['* Implicit or scanner dependency', '* Task code', '* Source file, explicit or manual dependency', '* Configuration data variable']
|
2011-09-10 11:13:51 +02:00
|
|
|
tmp = 'task: -> %s: %s %s'
|
|
|
|
for x in range(len(msgs)):
|
|
|
|
l = len(Utils.SIG_NIL)
|
|
|
|
a = new_sigs[x*l : (x+1)*l]
|
|
|
|
b = old_sigs[x*l : (x+1)*l]
|
|
|
|
if (a != b):
|
2016-05-28 16:18:51 +02:00
|
|
|
Logs.debug(tmp, msgs[x].ljust(35), v(a), v(b))
|
2011-09-10 11:13:51 +02:00
|
|
|
return ret
|
|
|
|
Task.Task.runnable_status = runnable_status
|
|
|
|
|