Build smarter, not harder

I spent the past six weeks roaming around Europe with a netbook, and used that time productively to get some work done on Firefox. Part of that involved building on Windows for the first time, and experiencing the joy of pymake. However, I found the extra characters required to fire off incremental builds with pymake pushed me just past the pain point required to get me to write some sort of automation. With that in mind, I introduce smartmake, a tool to allow you to specify as little information as possible to build incrementally while still ending up with a working finished build.

Here’s how it works: I’ve encoded some basic dependencies into a python file (any changes to layout/build, netwerk/build, js/src, etc. require a rebuild of toolkit/library, any changes to layout/ or dom/ require rebuilding layout/build, etc). You pass a list of srcdir directories that have been changed to the script, and it prints out a list of of build commands joined by &&, ie:

$ smartmake ipc/ipdl dom/src/geolocation
make -C objdir/ipc/ipdl && make -C objdir/dom/src/geolocation && make -C objdir/layout/build && make -C objdir/toolkit/library

It’s a pretty dumb tool at the moment, and there are certainly lots of edge cases that don’t actually work correctly. However, I found it useful enough in Europe that when I returned home to a different machine, I missed it. It’s hardcoded for my own setup right now, but I’ll try to make it more general if people are interested (ie. the objdir and cmd variables could be read from a config file). Hit me up with any requests or if you have wonderful ideas for how to improve it.

Update: I’ve genericized it a small amount. Now, you’ll need to create .hg/.smartmake like so:
[smartmake]
objdir: objdir/
cmd: make -C

before the updated smartmake will allow you to continue. Notice that this is per tree, not global. Furthermore, smartmake.py is designed to be used as a tool that outputs a command line – I have a shell alias that pipes its output to sh.

6 Responses to “Build smarter, not harder”

  1. Any way for people working on various bits of code to add their own dependency information as they add code so that the system is self-smartening?

  2. Well, user repos are open to anyone to push to them. I’m totally cool with people making sensible changes and pushing.

  3. The build system is supposed to do this for you, dammit! Sigh.

  4. Reads funny when “smartmake” is “a pretty dumb tool at the moment” ;-)

  5. You should be able to figure out the object directory based on the .mozconfig file (or the absence of one).

  6. [...] day tracing this thing down, and I was quite fatigued. I made the addition and using a tool called "smartmake" suggested to me by a Mozillian in #introduction on Moznet, began an incremental build. I was 100% [...]

Leave a Reply