Created
January 1, 2012 20:33
-
-
Save kisom/1548276 to your computer and use it in GitHub Desktop.
automatically generate a quicklisp-enhanced sbcl image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sbcl --script | |
;;;; build-image.lisp | |
;;;; build a customised sbcl image | |
;;;; | |
;;;; you can modify the package list by changing the *base-packages* | |
;;;; global variable. this is useful for building a custom binary with | |
;;;; your commonly used libraries already present (at the expense of | |
;;;; some memory) but will cut down on load times. | |
;; list of packages to install - it's at the top so it's easier to change | |
(defparameter *base-packages* '(drakma cl-json cl-oauth cl-mongo cl-redis | |
cl-who flexi-streams linedit manifest | |
postmodern)) | |
;;; load quicklisp and quickload the libraries to be baked in | |
;;; taken from quicklisp's addition to my .sbclrc | |
#-quicklisp | |
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" | |
(user-homedir-pathname)))) | |
(when (probe-file quicklisp-init) | |
(load quicklisp-init))) | |
(defun load-packages (package-list) | |
(dolist (package (mapcar #'string package-list)) | |
(ql:quickload package))) | |
;; build the image | |
(defun build-image (image-name) | |
(if (stringp image-name) | |
(sb-ext:save-lisp-and-die image-name :executable t) | |
(format t "invalid image name!~%"))) | |
(defun validate-arg (arg) | |
(format t "validating ~A~%" arg) | |
(if (stringp arg) | |
arg | |
(progn | |
(format t "invalid argument: ~A!~%" arg) | |
(quit)))) | |
;; grab the image name from the command line args | |
(defvar *image-name* (validate-arg (second sb-ext:*posix-argv*))) | |
(format t "building sbcl image ~A with ~A built in...~%" | |
*base-packages* *image-name*) | |
(load-packages *base-packages*) | |
(format t "saving image...~%") | |
(build-image *image-name*) | |
(quit) ; shouldn't get this far but just in case, die |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment