Given the following requirements
The following example demonstrates how to create a task type fulfilling the requirements, and how to use it.
import Task, Constants, Build, Utils cls = Task.simple_task_type('svnversion', 'date > ${TGT}', color='BLUE')cls.runnable_status = lambda self: Constants.RUN_ME
cls.before = 'cxx'
old_post_run = cls.post_run def post_run(self): old_post_run(self) Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = \ Utils.h_file(self.outputs[0].abspath(self.env)) cls.post_run = post_run
def build(bld): tsk = cls(bld.env.copy())
tsk.inputs = [] tsk.outputs = [bld.path.find_or_declare('foo.h')]
def set_options(opt): pass def configure(conf): pass
Create a new task type, in this example, we pretend it runs a command to retrieve the svn version and stores it in a header. | |
Replace runnable_status by a new method which indicates the task must be run each time | |
Indicate that the task must always be run before c++ ones | |
By default, the task signature is assigned to the node information. In our case the task signature is always the same, and we need a way to indicate to dependent tasks that something has changed. The solution is to compute a hash of the file produced, and to assign it to the node information. | |
Demonstrate the manual creation of the task | |
The task outputs are Node instances, but there are no inputs. |