A task without any file dependency

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') 1
cls.runnable_status = lambda self: Constants.RUN_ME 2
cls.before = 'cxx' 3

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 4

def build(bld):
    tsk = cls(bld.env.copy()) 5
    tsk.inputs = []
    tsk.outputs = [bld.path.find_or_declare('foo.h')] 6

def set_options(opt):
    pass

def configure(conf):
	pass

1

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.

2

Replace runnable_status by a new method which indicates the task must be run each time

3

Indicate that the task must always be run before c++ ones

4

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.

5

Demonstrate the manual creation of the task

6

The task outputs are Node instances, but there are no inputs.