Thu 12 Apr 2007

ASDF stubs

In most programming languages, deploying a library means building a shared library file ( and putting it in a known location (/usr/local/lib/). The situation is similar in Common Lisp… if you use require. Libraries that use ASDF are convenient to load during development, but it's cumbersome to distribute the whole package tree, put ASDF symlinks in the right places, and potentially have ASDF try to compile the systems on the destination machine.

We can't just rip out ASDF, though, and it's inelegant repetition to conditionalize dependency mechanisms. What we want, then, is a way to have ASDF use a single FASL for a library if one exists, and a way to build that single FASL.

A few hours of hacking later, and I've written such a thing. It consists of:
  • Two new ASDF operations. These walk the dependency tree, compiling files, and concatenating the FASLs, one per system. They also copy the ASDF file to a location, trimming it down to forget about its original files (so ASDF won't try to build them if they've changed, and won't fail if they don't exist).
  • An around method on load-op that tries require before attempting to load the ASDF system.
  • Additions to the ASDF central registry and Allegro's sys:*require-search-list* to add the output directories to the search paths.
The end result: you can call (stub-system 'my-app) to fill /usr/local/fasls/ and /usr/local/stubs/ with the libraries you need to run my-app. You can then simply issue (asdf:oos 'asdf:load-op 'my-app), and the necessary FASLs are loaded: no ASDF work takes place beyond checking that the system exists. You can use require to load these FASLs, too.

The upshot is that I can put cl-who.fasl and the stub cl-who.asd on a box, use ASDF to load it, and leave the source tree on the development machine, where it belongs.

Cool, huh? Now I just need to package it up, and deal with the expected barrage of mail from people telling me a better solution!

(No, images aren't the whole solution… there are plenty of situations where we want libraries to be supplied separately.)

Posted at 2007-04-12 13:24:47 by RichardLink to ASDF stubs