mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-25 11:19:52 +01:00
provide bld(features='subst', subst_fun= fun(task, text)) for convenience
This commit is contained in:
parent
294050ff41
commit
43277c8e77
@ -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')
|
||||
|
||||
|
@ -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('%', '%%')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user