COLOR-CODE编译器输出是否有简单的方法? [英] Is there an easy way to COLOR-CODE the compiler outputs?

查看:116
本文介绍了COLOR-CODE编译器输出是否有简单的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gcc(或其他编译器)通常会生成巨大的文本输出,并且很难看到错误或错误警告。我已经做了一些搜索,但没有找到一个干净简单的解决方案来给编译器输出加上颜色代码(例如警告是黄色的,错误是红色的等等)。

解决方案

如果您正在寻找一些非常简单的方法,可以使用以下方法:

 # !/ bin / bash -e 

make $ {@} 2>& 1 | perl -wln -M'Term :: ANSIColor'-e'
m / Building | gcc | g ++ | \bCC\b | \bcc\b /并打印\e [1; 32m ,$ _,\e [0m]

m / Error / i并打印\e [1; 91m,$ _,\e [0m

m / Warning / i并打印\e [1; 93m,$ _,\e [0m

m / Linking | \\打印\e [1; 36m,$ _,\e [0m

print; '

只需将此脚本别名,并确保其可执行文件...


gcc (or other compilers) often generate huge text output and it's very difficult to see where the error is or miss warnings. I've done some search but havn't found a clean simple solution to color code the compiler output (so for instance warnings are yellow, errors are red, etc...)

解决方案

here's an alternative if you are looking for something very simple:

#!/bin/bash -e

make ${@} 2>&1 | perl -wln -M'Term::ANSIColor' -e '
m/Building|gcc|g++|\bCC\b|\bcc\b/ and print "\e[1;32m", "$_", "\e[0m"
or
m/Error/i and print "\e[1;91m", "$_", "\e[0m"
or
m/Warning/i and print "\e[1;93m", "$_", "\e[0m"
or
m/Linking|\.a\b/ and print "\e[1;36m", "$_", "\e[0m"
or
print; '

Just alias your make to this script and make sure it's executable...

这篇关于COLOR-CODE编译器输出是否有简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆