Package: fabricate
fabricateis a build tool that finds dependencies automatically for
any language. It’s small and just works. No hidden stuff behind your
back. It was inspired by Bill McCloskey’s make replacement, memoize, but
fabricate works onWindowsas well as Linux.Get fabricate.py
now,
learnhow it
works, see
how to getin-Python
help, or discuss
it on themailing
list.FeaturesNever have to list dependencies.Never have to specify cleanup rules.The tool is a single Python file.It uses MD5 (not timestamps) to check inputs and outputs.You can learn it all in about 10 minutes.You can still read your build scripts 3 months later.Now supportsparallel
buildingShow me an example!fromfabricateimport*sources=['program','util']defbuild():compile()link()defcompile():forsourceinsources:run('gcc','-c',source+'.c')deflink():objects=[s+'.o'forsinsources]run('gcc','-o','program',objects)defclean():autoclean()main()This isn’t the simplest build script you can make with fabricate (seeother
examples),
but it’s surprisingly close to some of the more complex scripts we use
in real life. Things to note:It’s anordinary Python file.Use the clarity and power of
Python.No implicit stufflike CCFLAGS.Explicit is better:you tell fabricate what commands to run, and
it runs them – but only if their inputs or outputs have changed.Where you’d use targets in make, you justuse Python functions–build()is the default.You caneasily “autoclean”any build outputs – fabricate finds
build outputs automatically, just like it finds dependencies.Using fabricate optionsThe best way to get started is to take one of the examples linked above
and modify it to suit your project. But you’re bound to want to use some
of the options built into fabricate. To get a list of these:from fabricate import *

help(main)
help(Builder)Using fabricate as a script, a la memoizeYou can also use fabricate.py as a script and enter commands directly on
the command line (seecommand line
options).
In the following, eachgcccommand will only be run if its
dependencies have changed:fabricate.py gcc -c program.c
fabricate.py gcc -c util.c
fabricate.py gcc -o program program.o util.oWhy not use make?For a start, fabricate won’t say “*** missing separator” if you use
spaces instead of tabs. And you’ll never need to enter dependencies
manually, like this:files.o : files.c defs.h buffer.h command.h
        cc -c files.cInstead, you just tell fabricate torun('cc','file.c')and it’ll
figure out what that command’s inputs and outputs are. Next time you
build, the command will only get run if its inputs have changed, or if
its outputs have been modified or aren’t there.And you can use Python’s readable string functions instead of producing
write-only make rules, like this one from the make docs:%.d : %.c
        @set -e; rm -f $@; $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
        sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$What about SCons?SCons tempted us at first too. It’s Python … isn’t it? But just before
it sucks you in, you realise it’s actuallyquite
hardto do simple
things explicitly.Python says thatexplicit is better than implicitfor a reason, and
with fabricate, we’ve made it so you tell it what you want. It won’t do
things behind your back based on the83 different
toolsit may or
may not know about.Creditsfabricate is inspired byBill McCloskey’s
memoize, but
fabricate works under Windows as well by using file access times instead
of strace if strace is not available on your file system. Read more
abouthow fabricate
works.fabricate was originally developed by the B Hoyts atBrush
Technologyfor in-house use, and we then
released into the wild. It now has a small but dedicated user base and
is actively being maintained and improved by Simon Alford, with help
from other fabricate users.LicenseLike memoize, fabricate is released under aNew BSD
license.
fabricate is Copyright (c) 2009 Brush Technology.