我使用scons编译vc10和瑞萨编译器.
是否有任何命令可以在调试模式下获取可执行文件?
如果我使用命令" scons并输入" 执行我的项目,它将进入释放模式.
我无法使用visual studio调试器调试该.exe文件.
谁能告诉我如何在调试模式下获得调试可执行文件?是否有任何命令或标志在scons中设置?
为了得到在调试模式下,它只需添加相应的编译器调试标志在CXXFLAGS建设变量的简单的事情可执行文件,如下所示:
env = Environment()
env.Append(CXXFLAGS = ['/DEBUG'])
Run Code Online (Sandbox Code Playgroud)
但这是相当基本的,我想你可以通过命令行控制何时在调试模式下编译可执行文件.这可以通过命令行目标或命令行选项完成(如debug = 1)
要使用目标,您可以执行以下操作:
envRelease = Environment()
envDebug = Environment()
envDebug.Append(CXXFLAGS = ['/DEBUG'])
targetRelease = envRelease.Program(target = 'helloWorld', source = 'helloWorld.cc')
# This makes the release target the default
envRelease.Default(targetRelease)
targetDebug = envDebug.Program(target = 'helloWorldDebug', source = 'helloWorld.cc')
envDebug.Alias('debug', targetDebug)
Run Code Online (Sandbox Code Playgroud)
如果执行没有命令行目标的SCons,则将按照envRelease.Default()函数的指定构建发行版本.如果您使用调试目标执行SCons,如下所示:scons debug那么调试版本将按envDebug.Alias()函数指定的方式构建.
另一种方法是使用命令行参数,如下所示:scons debug=0或者scons debug=1,它允许您在构建脚本中执行某些逻辑,从而允许您更轻松地控制variant-dir等,如下所示:
env = Environment()
# You can use the ARGUMENTS SCons map
debug = ARGUMENTS.get('debug', 0)
if int(debug):
env.Append(CXXFLAGS = ['/DEBUG'])
env.VariantDir(...)
else:
env.VariantDir(...)
env.Program(target = 'helloWorld', source = 'helloWorld.cc')
Run Code Online (Sandbox Code Playgroud)
看看这里为更多的命令行处理选项.
最后一个选项,我更喜欢的是始终构建两个版本,每个版本都在各自的variantDir中(例如build/vc10/release和build/vc10/debug).
envRelease = Environment()
envDebug = Environment()
envDebug.Append(CXXFLAGS = ['/DEBUG'])
envRelease.VariantDir(...)
targetRelease = envRelease.Program(target = 'helloWorld', source = 'helloWorld.cc')
# This makes the release target the default
envRelease.Default(targetRelease)
# This allows you to only build the release version: scons release
envRelease.Alias('release')
envDebug.VariantDir(...)
targetDebug = envDebug.Program(target = 'helloWorld', source = 'helloWorld.cc')
# This makes the debug target get built by default in addition to the release target
envDebug.Default(targetDebug)
# This allows you to only build the debug version: scons debug
envDebug.Alias('debug')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3510 次 |
| 最近记录: |