Skip to content

Colorized the short Warnings/Errors generated by the toolchains #2122

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

Merged
merged 7 commits into from
Jul 13, 2016

Conversation

theotherjimmy
Copy link
Contributor

@theotherjimmy theotherjimmy commented Jul 7, 2016

These commits add colorization to all of the short form Warning and Error messages generated by the compiler when the --color switch is provided on the command line. The default colorization will make Warnings Yellow and Errors Red, but can be changed by the user, in mbed_settings.py if they find yellow and red unreadable or ugly.
Affects these top level scripts:

  • build.py
  • make.py
  • test.py

Therefore the mbed subcommands compile, and test are also affected.

@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Jul 7, 2016

@screamerbg
Copy link
Contributor

screamerbg commented Jul 7, 2016

@theotherjimmy Don't like the colorama dependency in utils.py. Why not handle notify function/output and colorize from there?

@theotherjimmy
Copy link
Contributor Author

I could. I assumed that it could be a more general purpose colorization function and used in more than just the toolchains.

@theotherjimmy
Copy link
Contributor Author

Don't merge yet. New implementation coming.

@theotherjimmy
Copy link
Contributor Author

Implementation will be: add option to options.py to add colorization; use that option to replace the notification function within the toolchains through the constructor.

@theotherjimmy theotherjimmy force-pushed the colorized-output branch 3 times, most recently from 935c899 to 2279bda Compare July 7, 2016 20:07
@theotherjimmy
Copy link
Contributor Author

theotherjimmy commented Jul 7, 2016

The implementation is much better now, but still changes something in tools/toolchains/__init__.py, which I don't like.

@theotherjimmy theotherjimmy force-pushed the colorized-output branch 4 times, most recently from 43d3ed5 to ea9ff9f Compare July 7, 2016 22:10

import sys
import re
from colorama import init
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that @screamerbg had some issues with colorama at some point. @screamerbg, is that still the case?

@bogdanm
Copy link
Contributor

bogdanm commented Jul 8, 2016

What did you test this on? Doesn't work in my Linux console, the ANSI escapes don't seem to work:

Building project blinky (K64F, GCC_ARM)
Compile: main.cpp
�[.31m[Error] main.cpp@4: 'ds' does not name a type
�[.0m�[.33m[Warning] main.cpp@17: 'rtos::Thread::Thread(void (*)(const void*), void*, osPriority, uint32_t, unsigned char*)[...]
�[.0m./main.cpp:4:1: error: 'ds' does not name a type

My TERM is set to xterm (and is fully capable of doing color output).

@bogdanm
Copy link
Contributor

bogdanm commented Jul 8, 2016

...and the same thing happens in Windows (cmd.exe). 👎

@theotherjimmy
Copy link
Contributor Author

@bogdanm: I tested it Xterm (echo $TERM is xterm), URxvt (echo $TERM is rxvt-unicode), and windows cmd.exe (echo $TERM is $TERM 😄).
before Replace color definitions...:
URxvt gets color, xterm gets no color, cmd.exe gets no color. However, I do not see the escape codes.
After:
URxvt gets color, xterm gets color, cmd.exe still no color. I still don't see escape codes.

@PrzemekWirkus
Copy link
Contributor

PrzemekWirkus commented Jul 11, 2016

@theotherjimmy Would you be so kind and add meaningful description to this PR ? See here

@theotherjimmy
Copy link
Contributor Author

@PrzemekWirkus Thank you for the friendly reminder. Please find a description of what this PR adds to our tools in the first comment.

@screamerbg
Copy link
Contributor

Thanks, Jimmy.
+1

@bogdanm can you confirm that the latest version works for you?

@bogdanm
Copy link
Contributor

bogdanm commented Jul 12, 2016

Linux: it works partially. Warnings like the one below are shown in the proper color:

[Warning] RTX_CM_lib.h@681: implicit declaration of function 'atexit' [-Wimplicit-function-declaration]

Errors are more problematic. For the error below:

Compile: main.cpp
[Error] main.cpp@4: 'ds' does not name a type
[Warning] main.cpp@17: 'rtos::Thread::Thread(void (*)(const void*), void*, osPriority, uint32_t, unsigned char*)' is deprecated (declared at ./mbed-os/core/rtos/rtos/Thread.h:138): Thread-spawning constructors hide errors and may lead to complex program state when a thread is declared [-Wdeprecated-declarations]
[Error] main.cpp@20: 'led1' was not declared in this scope
./main.cpp:4:1: error: 'ds' does not name a type
 ds
 ^
./main.cpp: In function 'int main()':
./main.cpp:17:30: warning: 'rtos::Thread::Thread(void (*)(const void*), void*, osPriority, uint32_t, unsigned char*)' is deprecated (declared at ./mbed-os/core/rtos/rtos/Thread.h:138): Thread-spawning constructors hide errors and may lead to complex program state when a thread is declared [-Wdeprecated-declarations]
     Thread thread(led2_thread);
                              ^
./main.cpp:20:9: error: 'led1' was not declared in this scope
         led1 = !led1;
         ^
[ERROR] ./main.cpp:4:1: error: 'ds' does not name a type
 ds
 ^
./main.cpp: In function 'int main()':
./main.cpp:17:30: warning: 'rtos::Thread::Thread(void (*)(const void*), void*, osPriority, uint32_t, unsigned char*)' is deprecated (declared at ./mbed-os/core/rtos/rtos/Thread.h:138): Thread-spawning constructors hide errors and may lead to complex program state when a thread is declared [-Wdeprecated-declarations]
     Thread thread(led2_thread);
                              ^
./main.cpp:20:9: error: 'led1' was not declared in this scope
         led1 = !led1;
         ^

the first 4 lines are properly colorized, the others are shown in the regular color. Also, I have a linker error that's not being colorized at all.

I don't consider any of the above to be a blocker for merging this PR. We can improve it later.
I'm going to test in Windows and come back with the results in a separate comment.

@bogdanm
Copy link
Contributor

bogdanm commented Jul 12, 2016

I can see the exact same behaviour in Windows, which is a good thing.
Conclusion: not yet complete, but ready to be merged in as far as I'm concerned. 👍

@theotherjimmy
Copy link
Contributor Author

@bogdanm, Yep, only the short form of the Warnings/Errors are colorized at the moment. It should be possible to build on this PR to make a more complete colorization in the future.

@bogdanm bogdanm merged commit d0d023a into ARMmbed:master Jul 13, 2016
@bogdanm bogdanm deleted the colorized-output branch July 13, 2016 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants