Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to parse the output of a build to enable "jump to error" #2

Closed
astitcher opened this issue Apr 18, 2016 · 11 comments
Closed
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature help wanted we currently are not planning work on this and would like help from the open source community

Comments

@astitcher
Copy link

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?

@vector-of-bool
Copy link
Contributor

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.

@vector-of-bool vector-of-bool added enhancement an enhancement to the product that is either not present or an improvement to an existing feature help wanted we currently are not planning work on this and would like help from the open source community labels Apr 18, 2016
@twxs
Copy link
Contributor

twxs commented May 6, 2016

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...

@vector-of-bool
Copy link
Contributor

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

@vector-of-bool
Copy link
Contributor

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?

@twxs
Copy link
Contributor

twxs commented May 11, 2016

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.

@vector-of-bool
Copy link
Contributor

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

@db4
Copy link

db4 commented Sep 18, 2018

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?

@vector-of-bool
Copy link
Contributor

At the moment, there is not, unfortunately.

@db4
Copy link

db4 commented Sep 25, 2018

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?

@vector-of-bool
Copy link
Contributor

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.

KoeMai added a commit to KoeMai/vscode-cmake-tools that referenced this issue May 28, 2019
@xgdgsc
Copy link
Contributor

xgdgsc commented Oct 16, 2019

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

@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature help wanted we currently are not planning work on this and would like help from the open source community
Projects
None yet
Development

No branches or pull requests

5 participants