waf has the subst
feature to copy files. In build context it can be used like that:
def build(bld):
bld(features='subst', source='wscript', target='wscript_copy', is_copy=True)
But I need to make use of the subst
feature in the configure
step:
def configure(conf):
conf(features='subst', source='wscript', target='wscript_copy', is_copy=True)
But this is not possible, as configure has no BuildContext:
TypeError: 'ConfigurationContext' object is not callable
Is there a way to make this work?
ConfigureContext
is not meant to use tasks.
If you really need it, you can do the same the conf.check()
method do (see waf book §10.4.2). It uses waflib.Configure.run_build(self, *k, **kw)
, which is not exactly public. See waflib.Tools.c_config
for its use by check()
.
It seems unneeded complexity to me. If you only need to copy files to setup your workspace, use plain python.
from shutil import copyfile
def configure(conf):
copyfile('wscript', 'wscript_copy')
The build part use tasks management and tasks dependencies to build things if needed.
If you need substitution of env variables, you can code it in a waf tool to use like:
def configure(conf):
conf.load("mysubst")
conf.substitute(wscript', 'wscript_copy')