#!/usr/bin/perl # # cmake 0.3 # Derived from colormake.pl 0.2 # $Id: cmake,v 1.1 1999/12/02 07:48:11 winston Exp $ # # Copyright: (C) 1999, Bjarni R. Einarsson # http://www.mmedia.is/~bre/ # # Modified by Winston Chang to pay attention to # command-line wrapping (with '\')and to use colors I like better. # Also, now make is being run from inside the script instead of having # to be piped in. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Color codes $col_black = "\033[30m"; $col_red = "\033[31m"; $col_green = "\033[32m"; $col_yellow = "\033[33m"; $col_blue = "\033[34m"; $col_magenta = "\033[35m"; $col_purple = "\033[35m"; $col_cyan = "\033[36m"; $col_white = "\033[37m"; # Highlight codes $col_norm = "\033[00m"; $col_background = "\033[07m"; $col_brighten = "\033[01m"; $col_underline = "\033[04m"; $col_blink = "\033[05m"; # Customize colors here... # $col_default = $col_white; $col_command = $col_white . $col_brighten; $col_gcc = $col_white . $col_brighten; $col_sourcefile = $col_cyan; $col_gcc_outfile = $col_cyan . $col_underline; $col_escape = $col_yellow; $col_make = $col_cyan . $col_underline; $col_make_msg = $col_green; $col_filename = $col_yellow; $col_linenum = $col_cyan; $col_trace = $col_yellow; $col_warning = $col_green; $col_warnmsg = $col_green; $col_error = $col_red . $col_brighten; $error_highlight = $col_brighten; open (MAKE, "make @ARGV 2>&1|"); $in = 'unknown'; $lastmode = ''; while () { $thisline = $_; # make[1]: Entering directory `/blah/blah/blah' if ($thisline =~ s/^(make)/$col_make$1$col_norm/) { $thisline =~s/:(.*)/:$col_make_msg$1/; $in = 'make'; } # For gcc output elsif ( ($thisline =~ s/^(gcc|cc|g\+\+|c\+\+|javac)(.*)$/$col_gcc$1$col_norm$2/) || ($lastmode eq 'gcc') ) { $thisline =~ s/(-o\s+)(\S+)/$1$col_gcc_outfile$2$col_norm/; $thisline =~ s/(\S+(\.c|\.cc|\.cpp|\.C|\.java))(\s|$)/$col_sourcefile$1$col_norm$3/; # For line continuation if ($thisline =~ s/\\$/$col_escape\\$col_norm/) { $lastmode = 'gcc'; $in = 'gcc'; } # If the line isn't continued, move to gcc_output state for next loop. else { $lastmode = ''; $in = 'gcc_output'; } } elsif ($thisline =~ /^(echo|rm|ar|sed|find|mv|cp|install|make|perl|awk|set|for)/) { $thisline =~ s/($1)/$col_command$1$col_norm/; $in = $1; } elsif ($in eq 'gcc_output') { # Do interesting things if make is compiling something. if (($thisline !~ /[,:]$/) && ($thisline !~ /warning/)) { # error? $thisline =~ s/(\d+:\s+)/$1$col_default$col_error/; $thisline = $error_highlight . $thisline . $col_norm; } else { # warning $thisline =~ s|(warning:\s+)(.*)$|$col_warning$1$col_warnmsg$2|; } # In file included from main.cpp:38: # main.cpp: In function int main(...)': $thisline =~ s/(In f(unction|ile))/$col_trace$1/x; # /blah/blah/blah.cpp:123: $thisline =~ s|^([^:]+)|$col_filename$1$col_default|; $thisline =~ s|:(\d+)([:,])|:$col_linenum$1$col_default$2|; } if ($thisline !~ /^\s+/) { print $col_norm, $col_default; } print $thisline; } print $col_norm;