我有一个 waf 文件,它正在为多个目标、多个平台以及在某些情况下为多个架构构建多个库。
我目前已经根据 waf 1.7 的文档为如下变体设置了环境:
def configure(conf):
# set up one platform, multiple variants, multiple archs
for arch in ['x86', 'x86_64']:
for tgt in ['dbg', 'rel']:
conf.setenv('platform_' + arch + '_' + tgt)
conf.load('gcc') # or some other compiler, such as msvc
conf.load('gxx')
#set platform arguments
Run Code Online (Sandbox Code Playgroud)
但是,这会导致 waf 在配置期间输出多行搜索编译器。这也意味着我经常多次接近同一个环境。如果可能,我想这样做一次,例如:
def configure(conf):
# set up platform
conf.setenv('platform')
conf.load('gcc')
conf.load('gxx')
# set platform arguments
for arch in ['x86', 'x86_64']:
for tgt in ['dbg', 'rel']:
conf.setenv('platform_' + arch + '_' + tgt, conf.env.derive())
# set specific arguments as needed
Run Code Online (Sandbox Code Playgroud)
然而, conf.env.derive 是一个浅拷贝,而 conf.env.copy() 给了我错误'list' object is not callable
这是如何在 waf 1.7 中完成的?
事实证明,答案是从顶级架构派生,然后分离以允许自己向配置添加更多标志。例子:
def configure(conf):
conf.setenv('platform')
conf.load('gcc')
conf.load('gxx')
for arch, tgt in itertools.product(['x86', 'x86_64'], ['dbg', 'rel']):
conf.setenv('platform')
new_env = conf.env.derive()
new_env.detach()
conf.setenv('platform_' + arch + '_' + tgt, new_env)
# Set architecture / target specifics
Run Code Online (Sandbox Code Playgroud)