gpt4 book ai didi

compilation - 如何配置visual studio代码来编译scons?

转载 作者:行者123 更新时间:2023-12-03 19:53:55 26 4
gpt4 key购买 nike

我在 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
}
]
}

我将任务用作 preLaunchTask .默认情况下,如果 questionMatcher 报告了一些问题,VSCode 不会启动可执行文件。当然,问题匹配器必须适合输出(在我的情况下是 Visual Studio 编译器 cl.exe)。但是,可以定义自定义匹配器来明确检查 SCons using Regex 的状态。对于 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"
],
...
},
...
]
}

诀窍是从包安装中启动 SCons script.py。不可能简单地写 program: "scons" - 它不会像在 shell 上那样被识别。
请注意,我没有指定 SConstruct 文件。通过设置执行目录 cwd隐式发现.

关于compilation - 如何配置visual studio代码来编译scons?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39878954/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com