首页 > 解决方案 > 多变体 MSVS 项目在 SCons 中失败

问题描述

我正在尝试在大型 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 项目中。

任何帮助将不胜感激!

标签: sconsvisual-studio-project

解决方案


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


推荐阅读