A more realistic example involves a project you're building with multiple files on disk (rather than an --eval
option passed to buildapp
), and some dependencies to pull in.
Because arbitrary things can happen during the finding and loading of asdf
systems (including loading other, potentially unrelated systems), it's not enough to just inspect the asd
files of the projects you're depending on in order to find out what you need to load. The general approach is to use quicklisp
to load the target system, then call ql:write-asdf-manifest-file
to write out a full manifest of everything that's loaded.
Here's a toy system built with hunchentoot
to illustrate how that might happen in practice:
;;;; buildapp-hello-web-world.asd
(asdf:defsystem #:buildapp-hello-web-world
:description "An example application to use when getting familiar with buildapp"
:author "inaimathi <[email protected]>"
:license "Expat"
:depends-on (#:hunchentoot)
:serial t
:components ((:file "package")
(:file "buildapp-hello-web-world"))
;;;; package.lisp
(defpackage #:buildapp-hello-web-world
(:use #:cl #:hunchentoot))
;;;; buildapp-hello-web-world.lisp
(in-package #:buildapp-hello-web-world)
(define-easy-handler (hello :uri "/") ()
(setf (hunchentoot:content-type*) "text/plain")
"Hello Web World!")
(defun main (argv)
(declare (ignore argv))
(start (make-instance 'easy-acceptor :port 4242))
(format t "Press any key to exit...~%")
(read-char))
;;;; build.lisp
(ql:quickload :buildapp-hello-web-world)
(ql:write-asdf-manifest-file "/tmp/build-hello-web-world.manifest")
(with-open-file (s "/tmp/build-hello-web-world.manifest" :direction :output :if-exists :append)
(format s "~a~%" (merge-pathnames
"buildapp-hello-web-world.asd"
(asdf/system:system-source-directory
:buildapp-hello-web-world))))
#### build.sh
sbcl --load "build.lisp" --quit
buildapp --manifest-file /tmp/build-hello-web-world.manifest --load-system hunchentoot --load-system buildapp-hello-web-world --output hello-web-world --entry buildapp-hello-web-world:main
Once you have those files saved in a directory named buildapp-hello-web-world
, you can do
$ cd buildapp-hello-web-world/
$ sh build.sh
This is SBCL 1.3.7.nixos, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
To load "cffi":
Load 1 ASDF system:
cffi
; Loading "cffi"
........
To load "buildapp-hello-web-world":
Load 1 ASDF system:
buildapp-hello-web-world
; Loading "buildapp-hello-web-world"
....
;; loading system "cffi"
;; loading system "hunchentoot"
;; loading system "buildapp-hello-web-world"
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into hello-web-world:
writing 4800 bytes from the read-only space at 0x20000000
writing 4624 bytes from the static space at 0x20100000
writing 66027520 bytes from the dynamic space at 0x1000000000
done]
$ ls -lh hello-web-world
-rwxr-xr-x 1 inaimathi inaimathi 64M Aug 13 21:17 hello-web-world
This produces a binary that does exactly what you think it should, given the above.
$ ./hello-web-world
Press any key to exit...
You should then be able to fire up another shell, do curl localhost:4242
and see the plaintext response of Hello Web World!
get printed out.