Colorize that build!

If you’ve ever built Mozilla from source or run the unit tests, you’ll know that doing so can generate a lot of console output. When errors happen, it can take a bit of scrolling to figure out exactly what failed, and where. I recently switched to pymake (because it’s sooo much faster), and it generates even more output.

Recently Shawn mentioned he had some magic pixie dust to colorize build output (which I didn’t know was possible on Windows), and I extended what he had to do a bit more. I’m finding it hugely useful, so figured I should share!

First, the pretty picture. This particular example is a bit gaudy, but shows a lot of what it does. The mostly useless nsinstall output (of which there’s a *lot*) is dark blue. Compiler warnings are yellow, errors are red.

Oh, and xpcshell tests benefit too!

To add this to your Windows MozillaBuild environment, just add this stuff to ~/.profile, and then open a new shell window.

There’s probably a lot more that could be done with this (and I’m sure it missed all kinds of interesting cases), but it’s a good, simple start!

About Justin Dolske

Mostly harmless.
This entry was posted in PlanetMozilla. Bookmark the permalink.

5 Responses to Colorize that build!

  1. Oooh, does that mean it’ll work under Linux bash as well? I’m excited to try it out.

  2. Wouldn’t it be easier to use
    function cmake() {
    gmake ${*:+”$@”} 2>&1 | sed -f colour.txt
    }
    (replace with your favourite make program and arguments) so that you can easily experiment by editing colour.txt?

    ${*:+”$@”} is needed in case you don’t want to specify any arguments.

    What does the -r flag to sed do, my sed doesn’t have it?

  3. mak77 says:

    nice stuff! thanks for sharing.

  4. mak77 says:

    fwiw, i’ve updated sed to latest version (http://sourceforge.net/projects/mingw/files/MSYS%20sed/)and added -u (unbuffered) option, otherwise xpcshell-tests output was buffered here. That was not really good for folders having lot of xpcshell tests (like Places).

    -r should be extended regexp afaik

  5. geekboy says:

    There’s also colormake for the lazy (like me) on linux:
    http://bre.klaki.net/programs/colormake/README.txt
    (sudo apt-get install colormake)

    Not as robust as the killer python script, but it colorizes warnings and errors in the make output.

Comments are closed.