SCons中的多个变体MSVS项目失败



我正试图在一个大型SCons项目中设置带有调试和发布构建的visual studio项目。手册宣称

允许使用不同变体多次调用MSVSProject;所有变体都将添加到项目文件中,并带有相应的构建目标和源。

然而,当我尝试这样做时,我得到的错误是";指定了建立同一目标的多种方式";。

最小示例(SConstruct文件(

import os
from SCons.Script import *
env = Environment()
for variant in ['debug', 'release']:
env.MSVSProject(
target = 'hello' + env['MSVSPROJECTSUFFIX'], 
srcs = 'hello.cpp', 
buildtarget = os.path.join(variant, 'hello.exe'), 
variant = variant)

这会产生以下输出:

scons: Reading SConscript files ...
scons: warning: Two different environments were specified for target hello.vcxproj,
but they appear to have the same action: GenerateProject(target, source, env)
File "SConstruct", line 7, in <module>
scons: *** Multiple ways to build the same target were specified for: hello.vcxproj  (from ['prj_inputs:"python.exe" -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.1.2'), join(sys.prefix, 'scons-3.1.2'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" -C "." -f SConstructutf-8; ppdefs: incpath: "debug\hello.exe" "debug" "hello.cpp "hello.vcxproj"'] and from ['prj_inputs:"python.exe" -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-3.1.2'), join(sys.prefix, 'scons-3.1.2'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" -C "." -f SConstructutf-8; ppdefs: incpath: "release\hello.exe" "release" "hello.cpp "hello.vcxproj"'])
File "SConstruct", line 7, in <module>

这是SCons中的一个错误,还是我不理解它应该如何工作?

我意识到,变体可以作为一个调用在列表中传递,但如果不对现有的构建基础设施进行重大重写,就不可能为不同的构建类型维护单独的源和目标列表。我希望每个构建类型使用一个环境,而手册中的引用使SCons似乎能够将它们组合成一个MSVS项目。

如有任何帮助,我们将不胜感激!

这是SCons中的一个错误,已提交

最新更新