I have a wscript
which reads some files during the configure step and based on this sets some variabales.
How do I get waf to automatically re-configure the project, if one of the configuration files change, when running waf build
instead of waf configure build
?
Consider the following scenario:
waf configure
waf build
a.config
is changedwaf build
, instead of waf configure build
.--> How must the wscript
look like, that it checks before running build
if the configuration files have changed, and if so, the project is reconfigured before running build
?
Example:
There is a file a.config
and the wscript
looks like this:
# wscript
def configure(conf):
a = conf.path.find_node('a.config')
conf.env.config = a.read()
def build(bld):
# check the configuration files are up to date.
# actual build
pass
configure
is not really for that. You can use the same code but in build
:
def build(bld):
a = bld.path.find_node('a.config')
bld.env.config = a.read()
bld(features = "myfeature", vars = ["config"], ...)
You can directly use configure with autoconfig
:
from waflib import Configure
def options(opt):
Configure.autoconfig = True
def configure(conf):
conf.env.config = "my_value"
def my_processing(task):
print "Processing..."
def build(bld):
bld(rule = my_processing, vars = ["config"])
Any change to conf.env.config
will trigger rebuild.
If you need to have separate config files, you can use load
:
def configure(conf):
pass
def my_processing(task):
print "Processing..."
def build(bld):
bld.load("my_config", tooldir="my_config_dir")
bld(rule = my_processing, vars = ["config1", "config2"])
with a my_config_dir/my_config.py
file like that:
def build(bld):
bld.env.config1 = "one"
bld.env.config2 = "two"
# ...
bld.load()
will execute the build
function in my_config.
Any change to config1
or config2
will trigger rebuild