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
Support ANSI colors on Windows #1451
Comments
@Befzz what build of Windows 10? |
@Befzz What happens if you run Because now that I look at this again, I'm having the following problem (both on Windows 10 1709 and 1803): Clang with I think that I had some situation where it did work, and it that situation it still didn't work with Ninja which is why I opened this issue report. However, I don't remember what I did, and can't get it to work again. So this is primarily a problem in Clang or Windows. We should look at this issue again when it works correctly without Ninja (or could someone get it to work already?). |
We write to the console with a special Windows function that might evade however Windows 10 understands color, but looking at this code it looks like maybe in some cases with the console pool it falls back on fwrite, which might explain how you had it work at some point. |
@evmar: I never had it working with Ninja, only without Ninja. But now I can't even get it to work without Ninja ... |
Unfortunately it only does so, after a WinAPI call, see #1462. |
It would be definitely be nice to see this. We mostly use ConEmu, which supports ANSI sequences, and we do have commands that emit colors. Some of them probably are not using ANSI sequences though... |
We've finally tagged a new release of Ninja, version v1.9.0! The biggest feature of this release would be high-resolution timestamps, so timestamps with a resolution under 1 second. ninja-build/ninja#371 There are also several small quality-of-life improvements, for example ninja now enables Windows 10's ANSI color escape code support. ninja-build/ninja#1451 For a complete list of changes see: ninja-build/ninja@v1.8.2...v1.9.0
Hi, this still does not work on Mingw/Msys2. Gcc correctly outputs colors when called manually with the same args ( I tried ninja with a custom target calling a bash script :
|
Are you running ninja through mintty (MSYS2's shell)? IIRC we only detect native Windows command prompts and therefore think that we're piped in that case. That's why ANSI escape codes get stripped. Try running with |
Clang's
cl.exe
has an option-fansi-escape-codes
which makes it output ANSI colors instead of using the usual Windows console API. The console of Windows 10 in one of the updates gained the ability to show those colors correctly. This means that theoretically I could set that option and make Ninja correctly forward the colors (which can never work with the usual colors in Windows, because they are not part of the output stream).However, it doesn't work for some reason, which I was not yet able to find out. Ninja will forward the colors with
pool = console
, but otherwise it won't. Furthermore, the the mode for automatic parsing of include dependencies viadeps = msvc
will probably also need to learn to ignore, but forward the ANSI escape codes.The text was updated successfully, but these errors were encountered: