You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
waf_old/docs/book/examples/build_manual_tasks/wscript

54 lines
1.1 KiB
Python

#! /usr/bin/env python
"""
Task objects may be created manually
This is tedious and leads to spaghetti code
Yet, it it interesting to see this to understand
why the task generator abstraction is necessary
$ waf configure build
"""
def configure(ctx):
pass
from waflib.Task import Task
class cp(Task):
def run(self):
return self.exec_command('cp %s %s' % (
self.inputs[0].abspath(),
self.outputs[0].abspath()
)
)
class cat(Task):
def run(self):
return self.exec_command('cat %s %s > %s' % (
self.inputs[0].abspath(),
self.inputs[1].abspath(),
self.outputs[0].abspath()
)
)
def build(ctx):
cp_1 = cp(env=ctx.env)
cp_1.set_inputs(ctx.path.find_resource('wscript'))
cp_1.set_outputs(ctx.path.find_or_declare('foo.txt'))
ctx.add_to_group(cp_1)
cp_2 = cp(env=ctx.env)
cp_2.set_inputs(ctx.path.find_resource('wscript'))
cp_2.set_outputs(ctx.path.find_or_declare('bar.txt'))
ctx.add_to_group(cp_2)
cat_1 = cat(env=ctx.env)
cat_1.set_inputs(cp_1.outputs + cp_2.outputs)
cat_1.set_outputs(ctx.path.find_or_declare('foobar.txt'))
ctx.add_to_group(cat_1)
cat_1.set_run_after(cp_1)
cat_1.set_run_after(cp_2)