Self-Contained Common Lisp Project


when I upload code to a Git host or share it, I don't want the user to have to install anything just to compile my software. This actually happened to me: I have a game in Common Lisp that uses Quicklisp and Qlot to manage dependencies. Now I need to install Qlot and Quicklisp myself. I wish I had just vendored everything so the user could just compile it. I've also seen this kind of thing happen in web development, and I don't like it.

Right now, as I’m writing this blog, I’m creating apps that make tasks monitoring Data Center easier. I think I’m also going to do some web development with Common Lisp, using Hunchentoot, FiveAM, etc.

Common Lisp already has ASDF, I can just run asdf:make and asdf:test-system.

Usually, I create an env.lisp file on top to make things easier, manually set up dependencies in the vendor directory, and use t for tests and src for source code.

In this blog, my system is called aegis.

env.lisp:

(in-package #:cl-user)

(require "asdf")

(export 'build)
(export 'enter)
(export 'test)

(asdf:initialize-source-registry
 `(:source-registry
   :inherit-configuration
   (:directory ,(truename ""))
   (:tree ,(truename "vendor/"))))

(defun build ()
  (asdf:load-system "aegis/build")
  (asdf:make "aegis/build"))

(defun enter ()
  (asdf:load-system "aegis")
  (in-package #:aegis))

(defun test ()
  (asdf:load-system "aegis/test")
  (asdf:test-system "aegis"))

Just like that, I can create executable with:

sbcl --load env.lisp --eval '(build)'

And run some tests with:

sbcl --load env.lisp --eval '(test)'

When I want to do development, I open Emacs, go to the project directory, start SLIME, load env.lisp, and type (enter).

It’s simpler than Quicklisp or other layers on top of layers. If a user wants to compile my code, they only need a working SBCL, that’s it.