Save the image. Don't use DELIVER, I want a full image with the GUI environment and the compiler and everything.
Usage:
lispworks-5-0-0-x86-linux -siteinit - -init save-image-shell-app.lisp
; save-image-shell-app.lisp
(load-all-patches); Load ASDF
(load "/my/path/to/asdf")
(setf asdf:*central-registry*
(append asdf:*central-registry*
(list "/my/home/lisp/systems/")))(toggle-source-debugging t)
(setf hcl:*load-fasl-or-lisp-file* :load-newer-no-warn)
(load "~/lisp/shell-app")
(setf lw:*init-file-name* "~/.lw-console") ; use this instead of ~/.lispworks
(sys:define-top-loop-command :q () (quit)) ; use :q at the repl (if any) to quit
(save-image "~/bin/lw-console"
:restart-function #'shell-app-main
:environment nil
:multiprocessing t
:clean-down t)
(quit)
And the loaded code:
; shell-app.lisp(in-package :cl-user)
(defvar *argv* nil)
;;; main function after save
(defun shell-app-main ()
(if (cdr sys:*line-arguments-list*)
(let* ((*argv* (cdr sys:*line-arguments-list*))
(shell-file (first *argv*)))
;; read the shell file
(read-shell-file shell-file)
(quit))
; if no cmd-line args, start a listener
(start-tty-listener)))(defun read-shell-file (name)
(let ((compiled-version (probe-file (merge-pathnames (make-pathname :type "ufasl") name))))
(if compiled-version
(load compiled-version)
(with-open-file (shell-stream name :direction :input)
;; discard 1st line (the #!)
(read-line shell-stream)
;; load rest of file and run it
(load shell-stream)))));;; ensure that load is quiet
(setf *load-verbose* nil)
; (setf sys::*demand-load-verbose* nil) ; optional