mihnita / ansi-econsole

Eclipse plugin that understands ANSI escape sequences to color the Eclipse console output.
http://www.mihai-nita.net/java/
Other
90 stars 25 forks source link

Compiler output is colored only for a single project #50

Closed intractabilis closed 2 years ago

intractabilis commented 4 years ago

A while ago you've made this nice change to have the gcc compiler output colored. It works, but only for a single project, the one that was compiled first. If I have several projects opened in CDT, then switching to another one shows just bare escape codes in the console when compiling.

mihnita commented 4 years ago

I've tried to reproduce this in several ways, on different machines but I can't manage...

It is not a full project with sub-projects, but independent standalone projects, and you "switch by hand", right?

Any chance you can "trim down" the projects to a minimal example? I don't know... maybe be reducing each file to a simple "hello world"

Thanks a lot (and sorry for the delay, I didn't even realize when 18 days passed :-(

mundodisco8 commented 4 years ago

Hi, I'm having the same issue I use Simplicity Studio, the Silicon Labs IDE, which is based in Eclipse v4.5.1 (Mars, from June 2015), and try to print colour to my pre and post build scripts (using python). The first project I compile after startup will always print colour, while the rest won't. If I close and reopen, and build one of those other projects that didn't display colour, then that one shows colour, but the others don't.

Here's a gif

ANSI Console ffmpeg

I also tried on TI's Code Composer, based on a more recent Eclipse v4.8, and the problem is not present, so it might be only present on old versions of Eclipse?

lagerholm commented 4 years ago

Hi!

I just realized I have this same issue. First project i build the coloring is ok for that project. If I then build some other project the coloring is either completely off or is colored in strange ways where there is seemingly no escape sequences. image

This is in Eclipse 2020-03. With Ansi Console 1.4.2.202002090224. The project is a standalone cmake project that is run in eclipse via a python script in a build configuration.

mihnita commented 4 years ago

I've spent another couple of hours today trying to reproduce this. Tried Windows, MacOS, and Linux, and I've mixed GCC projects, makefile projects, and autoconf projects, Visual Studio on Windows. And I could not reproduce it.


@lagerholm

About the last comment (from lagerholm), it does not look like the same problem. The colors are there, but messed up. And not just the colors, but the text too. I've seen that in tools running parallel tasks (for example maven -T 2C) Several threads output in parallel, and "flows" of text get mixed, you just don't see it. The colors make that visible. See if there is some option (or tool) that is doing parallel processing, and disable that (not the tool, the parallel part :-) Or disable the color console plugin, run things "as is", and carefully inspect to see if the text makes sense, or if various messages are mixed together.


@intractabilis & @mundodisco8

Is it always the first project you run that is colored? Or it it always the same project? For instance if you build proj1, proj2, proj3, then restart Eclipse and run proj2, proj1, proj3. Do you get colored output from proj1 and proj2 respectively? Or is it always proj1?


I will also try Eclipse v4.5.1 and v4.8. It might be Eclipse... But it might also be something that Simplicity Studio does on top of Eclipse.

I looked into downloading Silicon Labs IDE, but they want me to register and create an account. Sorry, I don't feel like doing that only to test something based on a 5 years old Eclipse...

mihnita commented 4 years ago

I've tried Eclipse 4.5.1 (the "Eclipse IDE for C/C++ Developers", Linux 64bit, from https://www.eclipse.org/downloads/packages/release/mars/1) And it works. Same mixture of projects: gcc, make, autotools.

Interesting observations (not sure if relevant or not):

If you go to Window -- Preferences -- C++ -- Build -- Console you will notice that there are color settings for the build info / error / warnings.

I don't know how that is done. It might be a different console, not the standard one. Or they CDT build mechanism adds some extra "hooks"

However...

I've added messages to the makefile using both printf and info:

    @printf "\033[0;31m DEBUG \033[m\n"
    $(info ********** DEBUG **********)

In both cases the escape codes are visible, not colors. I get colors in the real console, but not the Eclipse one. But they are always visible, no matter of that build is the first after a restart or not.


Final "discovery" (for now): using the 2020-03 Eclipse (again) I've added printf with colored statements to several make files. And they show colors, until they don't :-( In some cases it shows 2 lines colored, and the 3rd one not, even if they are one after another in the makefile

Also, if I build from the top menu (Project -- Build Project) I get colors (until I don't) But if I right-click on the project in Project Explorer and select Build Project from there, I never get colors :-(


Weird... So I think I got something, but it is unpredictable, I don't see any pattern (for now?)

lagerholm commented 4 years ago

@mihnita Thanks for your support.

Here is some additional information about our environment. Windows 7. Eclipse IDE for C/C++ Developers Version: 2020-03 (4.15.0) Build id: 20200313-1211.

When building the output in presented in the CDT Build Console.

Regarding the scrambled output it only happens when Ansi Console plugin is enabled. We do not have any parallel builds. I still think it might be related.

Edit: I just found a workaround. If i switch to CDT Global Build Console the colors are fine for all projects. It's the individual consoles for projects other than the first one that are not working. Maybe this information also can help you troubleshooting.

mihnita commented 4 years ago

Thanks @lagerholm. I'll give it a few more hours this (long) week-end :-)


If by chance you can maybe send me your projects, cleaned? Of course, not real code, just enough to reproduce the problem? Maybe copy all projects (or backup), remove all c/cpp/h files except one, and replace the content of that one with a simple hello world.

I'm just nor sure what part of the build outputs the colors. It is make itself? Are there some print statements in make? Or maybe some unit test suite is doing the output?

I realize that the whole setup might be very complicated, as makefiles can me a big spaghetti monster :-) If that's the case, then forget it.

Sometimes just being able to reproduce the bug is 90% of the problem :-)

Thanks, Mihai

mattarroz commented 3 years ago

I have a similar (the same?) problem: Sometimes the Console output is scrambled when compiling cmake projects (no colors,  characters, etc.), it does not matter whether ANSI Console is enabled or disabled. If I restart eclipse, the color is back and the switch enable/disable ANSI console works. I'm using eclipse CDT 2020/09 (Build id: 20200910-1200, Linux).

dii commented 3 years ago

Same problem for me. I'm using STM32CubeIDE 1.7.0 for bare-metal software development. It is based on Eclipse C/C++ Development Tools, Version: 10.2.0.202103011047, Build id: 20210308-1557.

The console for the first project I build after startup works fine and keeps working. Even if I switch to another project and back to this one: image

If I build another project, that project's console's colours are scrambled when Ansi Colours are enabled, with escape codes showing up and overwriting normal text: image

When disabling ansi colours for the console, the output shows all the escape codes properly (but just no colours obviously): image

If I close the console when a broken one is showing, and reopen it through the menu Window->Show view->Console, then it actually interprets the ansi codes correctly (without having to rebuild): image

But then switching to the originally working project shows it now has corrupt output: image