Vscode-cmake-tools: Is there any way to parse the output of a build to enable "jump to error"

Created on 18 Apr 2016  路  11Comments  路  Source: microsoft/vscode-cmake-tools

One of the most useful features of editor-build integration is to enable immediate access to files with errors or warnings from the build output.

This extension doesn't seem to provide this - can it be added?

Feature Request help wanted

All 11 comments

This is definitely a feature I want to add. It will take a bit of work, as reliably parsing the error output from the different compilers can be difficult. Some compilers (such as Clang) offer machine-parsable output options, so that will be a good place to start.

I've got it on Windows using a Visual Studio CMake generator.

The tips is to define a custom task in tasks.json that runs cmake --build and specify '$msCompile' as problemMatcher

{
    "version": "0.1.0", 
    // cmake --build build 
    "command": "build.bat",
    // Show the output window only if unrecognized errors occur. 
    "showOutput": "silent", 
    // no args
    "args": [],     
    // use the standard msCompile problem matcher to find compile problems
    // in the output. cmake must use a Microsoft Generator
    "problemMatcher": "$msCompile"
}

As you can see, when the task is executed, the output is analyzed and you can navigate to the warnings and errors

image

For clang or gcc you can define your own problemMatcher based on regexp, you can find an exemple with gcc here

Hope this can help you...

Thanks for the info! That'll definitely help. I'll play around with it and see what I can make work.

I've been working on a kind-of solution on the feature/diagnostics-parsing branch. Rather than make a problem matcher, I parse the build output when running the cmake.build command.

I wish that it were possible to use a vscode command in place of the "command" on a task, rather than the name of an external program. The cmake.build command does quite a bit more than simply invoke cmake --build build, and I'd like to be able to use the problemMatcher functionality in conjunction with the custom command. Any opinions on which design would be better?

Parsing the output of GCC and Clang seems to work pretty well, although I don't have quick access to a Windows machine where I can test the MSVC output parser (but it _should_ work). Any MSVC users available to give it a try?

I just try it,
It seems there is a little problem in the MSVC Regex, I'll fix it today and send you a PR.

This should be fixed as of 0.3.0. Thanks for the help!

Is parsing the output hard-coded into the sources? What if I need to parse an unknown (even non-C) compiler output? When I compile via Run Build Task, I add an appropriate problem matcher to tasks.json and everything works. What about CMake tools? Impossible?

At the moment, there is not, unfortunately.

I'm quite new to cmake tools, so excuse me for a dumb question: why to invent your own build system (with custom problem parsers etc.) but not just integrate with vscode build tasks?

Early on I tried to do tasks.json integration, but there was a strong impedance mismatch between what tasks.json supported and what CMake required. I haven't taken a look for a while, so that may have changed, but it has in the past not been sufficient to run builds as required.

Does jump working for now? I remember it used to work. But not now for me.

Was this page helpful?
0 / 5 - 0 ratings