I'm currently using the Green Hills Software (GHS) compiler to compile C code. I'm using Visual Studio Code on a Windows machine and using the workspace file to create my tasks.
My problem is that the output of the task is all in plain white on black background and it's hard for the other developers to locate warnings/errors when there are no colors.
Thus, I thought it could be possible to modify the compiler output before it's being shown in the VSCode terminal. Any thoughts on that?
My task in the workspace file looks like this :
{
"label": "Build Project",
"type": "shell",
"command": "C:/ghs/comp_202014/gbuild.exe",
"args": [
"-parallel",
"-cfg=${input:build_config}",
"-top",
"MyGHSProject.gpj"
],
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}"
}
},
I have tried using extensions such as Colorized, using the settings.json file to edit the terminal colors, the code-runner extension to output the task output in the output panel, but nothing worked.
This is what I imagine the closest to a proper solution would be :
The first step to making this work is to add the
-stderroption to the *.gpj files of your project. An example would be :As such, the output of the compiler will go in the specified file.
The reason for that is that I could not get the
problemMatcheroption to work on the raw version of the warnings (because of \r\n characters), with my current skills in regex.Instead, I made a simple powershell script (which I cannot share, sorry...) to put the warnings on a single line, instead of the current three or more, so that the
problemMatcherwouldn't have to be too long.As an example, here is a raw warning :
And for comparison, a filtered one :
Not much changed, except for the "^" character which got replaced by a column number I computed with another powershell script (which I also cannot share).
In the end, you should be left with a log file that has the "formatted" warnings.
Now, the reason I changed the
-paralleloption to-noparallelwas that this specific option doesn't support the-paralleloption, which means the warnings will be logged but only partially.Now, all that's left is to add a task that prints the content of the log file into the terminal with the right
problemMatcherand you now have successfully made your debugging a lot less painful.The "printing" task :
I reckon there might be a better way to print a log file into the terminal than to have to create a whole script for it, but I'll leave this project for the developer.
Hope this helps.