2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2025-01-26 02:09:55 +01:00
2011-09-10 11:13:51 +02:00

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)