I have a configuration function in my wscript:
def configure(ctx):
ctx.env.V1 = 123
def build(ctx):
def myfun(task):
return task.exec_command('echo VAR=${V1}')
ctx.exec_command('echo VAR=${V1}')
ctx.add_post_fun(myfun)
But in build and in myfun (both) V1 is not available (it's substituted to an empty string). I can store and load my own ConfigSet. I know that V1 is available in rule, but it seems it is not available in exec_command().
What is the convenient way to do it? To access my config vars in exec_command() in build() body and in pre-/post- commands?
The docs for
waflib.Context.Context.exec_command()specify it as a thin wrapper around eitherwaflib.Utils.run_prefork_process()orwaflib.Utils.run_regular_process(), which is a thin wrapper oversubprocess.Popen(**kwargs).communicate().Both of these let you set
env=as a keyword argument, though it needs to have only values which can actually be stored in the environment (which integers, like your123, cannot).Thus: