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

cmake: enable coloured compiler output (IDFGH-7449) #9024

Closed
wants to merge 1 commit into from

Conversation

MacDue
Copy link
Contributor

@MacDue MacDue commented May 25, 2022

This adds -fdiagnostics-color=always to the default compile_options,
without this GCC won't enabled colored output when called from
ninja (via idf.py), making errors much harder to decipher.

This adds -fdiagnostics-color=always to the default compile_options,
without this GCC won't enabled colored output when called from
ninja (via idf.py), making errors much harder to decipher.
@MacDue
Copy link
Contributor Author

MacDue commented May 25, 2022

This is something that has bugged me quite a few times when building with idf.py

@espressif-bot espressif-bot added the Status: Opened Issue is new label May 25, 2022
@github-actions github-actions bot changed the title cmake: enable coloured compiler output cmake: enable coloured compiler output (IDFGH-7449) May 25, 2022
@igrr
Copy link
Member

igrr commented May 25, 2022

Hi @MacDue, thank you for the PR.
Unfortunately this approach will enable color output also when the build system output is not a terminal which understands ANSI escape sequences.

To solve this issue, we plan to enable color diagnostic output in the following manner (ref. #4162 (comment)):

  • upgrade CMake to the version which supports CMAKE_COLOR_DIAGNOSTICS environment variable — done in 2ee43cf
  • in idf.py, check if stdout is a TTY and set CMAKE_COLOR_DIAGNOSTICS=1 if so
  • IDEs which call CMake directly without idf.py (such as CLion or Eclipse) can set CMAKE_COLOR_DIAGNOSTICS if they support ANSI escape codes. For example, CLion has recently shipped this feature: https://blog.jetbrains.com/clion/2022/05/clion-starts-the-2022-2-eap/
  • in headless builds (CI, or when output is redirected to another program or a file) color output will stay disabled.

If you have any suggestions, please leave a comment in the linked issue about color diagnostic output. Thanks again!

@MacDue
Copy link
Contributor Author

MacDue commented May 26, 2022

While I appreciate a better fix is coming, I still think it's silly this has been disabled for so long. It's trivial to remove ANSI sequences from the output after the fact with something like ansi2txt, but impossible to add them & makes for unpleasant error messages.

@igrr
Copy link
Member

igrr commented Sep 2, 2022

Support for color diagnostics is now available in master, please see #4162 (comment). I'm sorry we did not merge your PR as is.

@igrr igrr closed this Sep 2, 2022
@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: Opened Issue is new labels Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants