2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 01:46:15 +01:00

provide bld(features='subst', subst_fun= fun(task, text)) for convenience

This commit is contained in:
Thomas Nagy 2012-10-08 18:30:47 +02:00
parent 294050ff41
commit 43277c8e77
2 changed files with 10 additions and 0 deletions

View File

@ -31,6 +31,11 @@ def build(bld):
# if you want a file copy, pass "is_copy=True"
bld(features='subst', source='wscript', target='wscript', is_copy=True)
# same thing with a simple function
def fun(task, text):
return text
bld(features='subst', subst_fun=fun, source='wscript', target='wscript2')
# this one is just a reminder that simple files can be created (and a test too)
#bld(rule='echo "การไฟ่" > ${TGT}', target='foo.txt')

View File

@ -668,6 +668,11 @@ class subst_pc(Task.Task):
code = self.inputs[0].read(encoding=getattr(self.generator, 'encoding', 'ISO8859-1'))
if getattr(self.generator, 'subst_fun', None):
code = self.generator.subst_fun(self, code)
self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'ISO8859-1'))
return
# replace all % by %% to prevent errors by % signs
code = code.replace('%', '%%')