Pretty Make

From Freehackers
Revision as of 20:57, 9 February 2008 by Bluebird (talk | contribs) (New page: == Introduction == Pretty make is a very small python script that will organise and colorize your make output. I have written this because when compiling, I was sick of the endless lines ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

Pretty make is a very small python script that will organise and colorize your make output. I have written this because when compiling, I was sick of the endless lines of uninteresting options, which were hiding the gcc options I was looking for

The program analyses its specific options then runs make with all the other options. So it is compatible with make. I use it every week to compile KDE with alias make='pretty_make.py'. I use the escape codes to colorize the output.

People have been wondering about CPU usage. Starting the python interpreter takes a little CPU, but this is before you have started your compilation, so you sill have plenty of CPU anyway. The python interpreter is started only once for a make command, so it won't matter much in you overall compilation speed.

Now, the parsing of the line uses builting python functions, which are written in C. So this is fast and there is really not a lot of work: split the line, compare beginning of words, fill lists, display. And such a line is displayed when gcc choose a new file to compile, so the tiny amount of CPU taken would have probably not been used anyway (except if you use -j12) because gcc was still loading the files

at that time. When I compile, python doesn't make into 'top', so it effectively does not take CPU.


Features

All features are of course configurable.

  • Adapt the output to your terminal width
  • Hide libtool lines: the next line is the real compile line anyway.
  • Group similar options on separate lines: all -D together, all -I together, ...
  • Can hide uninteresting option: you get <-W> instead of all

the -W options.

  • Colorize options differently: makes it easier to distinguish between -L,

-I and -D

  • Colorize moc and uic lines differently: else, you tend to miss them even when looking for them
  • Enable or disable colors
  • Post-process your compilation output: compile with output to a file and

beautify it later.

  • Useable inside vim and probably other editors
  • All options configurable

The default options you might want to alter are at the beginning of the program. There is no need to know python to modify them.

Screenshot

Before After
<a href="pretty-make-before.png"><img width=387 height=418 src="pretty-make-before.png" alt="Before pretty-make"></a> <a href="pretty-make-after.png"><img width=387 height=418 src="pretty-make-after.png" alt="After pretty-make"></a>

Download

Version 1.3 : 20 july 2003

New features:

  • add more compiler names
  • add a debug option
  • handles properly argument with spaces inside
  • can now compile kernel without problems

Download: pretty_make.py

Version 1.2 : 02 april 2002

New features:

  • Argument -- passes all the remaining arguments to make (pretty-make.py --

--help yields make's help)

  • Transparancy in konsole is preserved when not altering background color.
  • Fix for arguments of type "arg=foo" that were not passed to make
  • Fix for keyboard interruption (^C) would leave the make running wild in the

background


Version 1.1 : 26 march 2002

New features:

  • Fixes for tcsh users


Version 1.0 : 26 march 2002

Initial release.


Usage

Many way to use it:

  • in your shell: alias make=pretty_make.py
  • in vim (notice the backslash in front of --no-colors):

    set makeprg=$HOME/python/pretty_make/pretty_make.py\ --no-colors

  • in compilations: export MAKE=pretty_make.py
  • with configure: MAKE=pretty_make.py ./configure
  • everywhere: it works also if you symlink to it as a make executable (i.e ln -s python/pretty-make/pretty_make.py bin/make) but you must edit pretty_make.py to have the MAKEPROG pointing to the real make program, else you have recursive calls.
  • In emacs: I don't know, but it is certainly possible.

Red Hat users, be warned: pretty make won't run on your system, because recent Red Hat distributions ship with an old version of python, python 1.5.2, which is not supported by pretty_make. It is amazing that RedHat ships with such an old version of python. It is now three years old and python has seen 8 stable releases since 1.5.2. This is one more reason for me not to use RedHat. Mandrake and Suse don't have this problem, and I think Debian doesn't too. If you want to run pretty_make, you need to upgrade your version of python.

Feedback

Bugs, suggestions, patch, I am open to feedback: <a href="mailto:phil at freehackers dot org">phil at freehackers dot org</a>

Other programs

Pretty make doesn't use these program but you may want to check them if you like coloured output.






  • LuaUnit: A unit-testing framework for the Lua language
  • Klotski: a mind-breaking game
  • Indent Finder: analyse source code indentation to set your editor automatically
  • PyTiCroque: a software to help playing at www.croquemonster.com