Lisp Deployment

Deployment as source (script)

The advantages of deployment as source are:

- it's open source (you may also add a free license to make it free software, but this is an orthogonal decision). - for small and simple programs, it's the quickest and easiest way to get an executable.

The inconvenients are, for bigger or more complex programs:

- speed of execution, the CL implementation may interpret source code instead of compiling it, or may have to spend time compiling it at each launch, in which case it impacts launch time; - if the program depends on external libraries, those dependencies must be resolved each time the program is launched, which takes time and is harder to get right (what if the user copies the script on some other computer?).

Add a she-bang line to your lisp source:

#!/usr/bin/clisp -ansi -q -E utf-8
;; -*- mode:lisp; coding:utf-8 -*-
;; This script is Copyright Pascal J. Bourguignon 2012, distributed under the AGPL3 license.

(defconstant ex-ok            0   "successful termination")

(defconstant ex-usage         64  "command line usage error
    The command was used incorrectly, e.g., with
    the wrong number of arguments, a bad flag, a bad
    syntax in a parameter, or whatever.")

(defconstant ex-dataerr       65  "data format error
    The input data was incorrect in some way.
    This should only be used for user's data & not
    system files.")

(defun main (args)
  (if (zerop (length args))
      (progn
         (format t "Missing arguments~%Please give me some numbers.~%")
         ex-usage)
      (let ((numargs (mapcar (lambda (arg)
                                 (let ((num (ignore-errors (let ((*read-eval* nil))
                                                             (read-from-string arg)))))
                                   (if (numberp num)
                                     num
                                     (progn
                                       (format t "Invalid syntax for argument ~S~%Please give me only numbers.~%" arg)
                                       (return-from main ex-dataerr)))))
                             args)))
        (format t "~D~%" (reduce (function +) numargs))
        ex-ok)))

(ext:exit (main ext:*args*))

and add the execute access rights to the script file:

[pjb@kuiper :0 ~]$ chmod 755 ~/bin/example
[pjb@kuiper :0 ~]$ example 
Missing arguments
Please give me some numbers.

[pjb@kuiper :0 ~]$ example 1 and 2
Invalid syntax for argument "and"
Please give me only numbers.

[pjb@kuiper :0 ~]$ example 1 2 3 '#C(0 2)' 3/4 '#C(2/5 5/7)'
#C(143/20 19/7)
[pjb@kuiper :0 ~]$ 

Deployment as binaries (FASL files)

To Be Written

(equivalent to deployment as .o used to be done on unix systems).

Deployment as a source ASDF system distributed thru Quicklisp

To Be Written

Deployment as executable image

To Be Written

cl-launch

External libraries

See also:

  • Deploy. This is a system to help you easily and quickly deploy standalone common lisp applications as binaries. Specifically it is geared towards applications with foreign library dependencies that run some kind of GUI.


Document