Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Compilation 如何配置visual studio代码以编译SCON?_Compilation_Visual Studio Code_Integration_Config_Scons - Fatal编程技术网

Compilation 如何配置visual studio代码以编译SCON?

Compilation 如何配置visual studio代码以编译SCON?,compilation,visual-studio-code,integration,config,scons,Compilation,Visual Studio Code,Integration,Config,Scons,我在ubuntu上安装了vsc、python和scons。我还安装了python语法插件和相关工具。 我正在编辑SConstruct文件,我希望当我按“F5”时,它会显示SCON以执行我的项目文件 如何配置它?这是我计划很快为我的项目做的事情,但以前从未做过。我将开始查找MSVSProject()、env.MSVSProject()和MSVSSolution()、env.MSVSSolution() 我创建了一个包含以下内容的tasks.json文件: { // See https://

我在ubuntu上安装了vsc、python和scons。我还安装了python语法插件和相关工具。 我正在编辑SConstruct文件,我希望当我按“F5”时,它会显示SCON以执行我的项目文件


如何配置它?

这是我计划很快为我的项目做的事情,但以前从未做过。我将开始查找MSVSProject()、env.MSVSProject()和MSVSSolution()、env.MSVSSolution()

我创建了一个包含以下内容的
tasks.json
文件:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "Build wit SCons",
            "command": "scons",
            "type": "shell",
            "group": "build"
        }
    ]
}

它实现了公平的集成,因为我可以使用Shift-Ctrl-B启动构建任务。不幸的是,这不是一个很好的解决方案,因为我还没有找到在VS代码中显示输出状态(成功/错误)的方法。

我有两个可行的解决方案。第一个是基于的解决方案:

{
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "SCons BuildVSDebug",
            "command": "scons",
            "type": "shell",
            "group": "build",
            "problemMatcher": "$msCompile" // Important to catch the status
        }
    ]
}
其中,我将任务用作
预启动任务
。默认情况下,如果problemMatcher报告了一些问题,VSCode不会启动可执行文件。当然,problemMatcher必须适合输出(在我的例子中是visual studio编译器cl.exe)。但是,可以定义自定义匹配器,该匹配器可以显式检查SCON消息的SCON状态,如“SCON:由于错误而终止生成”。也可以使用多个输出匹配器


我的第二个解决方案的目标是自己调试SCON构建脚本。它不会运行编译后的输出,但允许在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"
            ],
            ...
        },
        ...
    ]
}
{
“版本”:“0.2.0”,
“配置”:[
{
“名称”:“Scons构建系统”,
“类型”:“python”,
“请求”:“启动”,
“pythonPath”:“/python”,
“程序”:“/Scripts/scons.py”,
“cwd”:“${workspaceRoot}”,
“调试选项”:[
“WaitOnAbnormalExit”,
“WaitOnNormalExit”,
“重定向输出”
],
...
},
...
]
}
诀窍是从软件包安装启动SCons script.py。不可能简单地编写
程序:“scons”
——它不会像在shell上那样被识别。 请注意,我没有指定SConstruct文件。它是通过设置执行目录
cwd
隐式找到的