Tro*_*yvs 4 integration config compilation scons visual-studio-code
我在 ubuntu 上安装了 vsc、python、scons。我还为 python 和相关工具安装了语法插件。我正在编辑 SConstruct 文件,我希望当我按“F5”时,它会调出 scons 来执行我的项目文件。
如何配置?
我得到了两个有效的解决方案。第一个基于mat的解决方案:
{
"version": "2.0.0",
"tasks": [
{
"taskName": "SCons BuildVSDebug",
"command": "scons",
"type": "shell",
"group": "build",
"problemMatcher": "$msCompile" // Important to catch the status
}
]
}
Run Code Online (Sandbox Code Playgroud)
我将任务用作preLaunchTask. 默认情况下,如果 questionMatcher 报告了一些问题,VSCode 不会启动可执行文件。当然,问题匹配器必须适合输出(在我的情况下是 Visual Studio 编译器 cl.exe)。但是,可以定义自定义匹配器,这些匹配器可以使用 Regex明确检查 SCons 的状态,以获取 scons 消息,例如“scons:由于错误而终止构建”。也可以使用多个输出匹配器...
我的第二个解决方案旨在自行调试 SCons 构建脚本。它不会运行编译的输出,但允许在 F5 上调试构建系统。
{
"version": "0.2.0",
"configurations": [
{
"name": "Scons Build System",
"type": "python",
"request": "launch",
"pythonPath": "<python 2.7 path>/python",
"program": "<python 2.7 path>/Scripts/scons.py",
"cwd": "${workspaceRoot}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
],
...
},
...
]
}
Run Code Online (Sandbox Code Playgroud)
诀窍是从包安装中启动 SCons script.py。不可能简单地写program: "scons"- 它不会像在外壳上那样被识别。请注意,我没有指定 SConstruct 文件。它是通过设置执行目录隐式找到的cwd。
| 归档时间: |
|
| 查看次数: |
5313 次 |
| 最近记录: |