lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Robert McLay wrote:
[...]
> It would be nice to know how long you have been using it.  Where you
> think primemover is headed?  

[Note: I seem to have lectured. Feel free to ignore me if you want...]

I wrote pm because I'd adopted a compiler suite, the Amsterdam Compiler Kit
("tack" on sourceforge, if you're interested), and its build system was a
horrible nightmare. Really. At one point I was trying to figure out how
something got built, and I spent two hours groping through a collection of
weird mutually-recursive makefiles that called shell scripts that called
makefiles, and then I realised something had to be done.

Prime Mover is fundamentally designed to fulfil my needs. I spent some time
looking at the alternatives, and they were all flawed. make loses as soon as
you start doing anything the slightest bit complicated --- recursive
makefiles, ew. Plus, it doesn't understand C dependencies. And the way it
tries (and fails) to guess what you want to do is awful. Scons loses because
it seems to me to be overly complex and requires the end user to install
Python. Ant loses because it's written in Java. All the other build systems I
looked at suffered from the same problems.

Prime Mover is supposed to be is a *simple* build tool that also offers power.
The language is designed to be accessible to people who don't know Lua, but is
supposed to be very simple and expressive:

include "c.pm"

default = cprogram {
	cfile {
		file "hello.c"
	}
}

...is a complete, working pmfile that compiles a source file into an object
into an executable. (cfile, of course, looks inside the C file and
automatically adds the header files to the dependency list.) The behaviour can
be modified by setting properties:

cfile {
	OPTIMISATION = "-Os",
	file "hello.c"
}

...sets the optimisation level for that source file. Or, you could put the
OPTIMISATION clause in the cprogram{} rule to apply it to the whole program...
or at the top level, to apply it to everything.

Rules are object oriented and subclassing a rule to make a new rule is easy.

debug_cfile = cfile {
	class = "debug_cfile",
	CDEFINES = {"DEBUG"}
}

...defines a new rule, debug_cfile, that automatically sets DEBUG for you when
it compiles something.

That's only part of it. One of the key aspects, IMO, is that it's deployed as
a single self-extracting shell script that automatically and invisibly builds
the Lua interpreter for you. This means that, unlike scons, it doesn't require
the user to install any extra software in order to use it. (The pm executable
is about 100kB.) In order to run, it needs sh, sed, head, gzip, and cc (or
gcc), which pretty much all Posix platforms have. This gives the greatest
flexibility: it'll run on bare-bones systems where traditionally all you had
was make, but with far more power.

(A not-incidental advantage is that pm, being written in Lua, has a Lua
interpreter in it. Which means that any project using pm as its build tool
also gains, automatically, the ability to write helper scripts in Lua --- for
free. This can be more valuable than you think.)

It also stores object files itself; rather than being put in with your source
code, it squirrels them away in its own cache. This means that you can build
the same source file several times and not have to worry about object file
clashes. This allows you to, for example, cross compile your application by
changing the value of CC and everything else happens automatically.

The ACK currently makes about 10000 temporary files when it builds. (Mostly
due to building the ACK's own libc once for every platform it supports.) Prime
Mover does this happily in one single pass.

[...]
> One thing that pm would have over others is the ability to run
> concurrently.   Some places with big projects find concurrent builds
> a big time saving.

Unfortunately, the one thing it doesn't do is parallel builds. Sorry; the way
the dependency system works depends on things being built in order.

-- 
+- David Given --McQ-+ "Gaping from its single obling socket was
|  dg@cowlark.com    | scintillating, many fauceted scarlet emerald..."
| (dg@tao-group.com) | --- Jim Theis, _The Eye of Argon_ (spelling
+- www.cowlark.com --+ original)


Attachment: signature.asc
Description: OpenPGP digital signature