From: Pillsy
Subject: Packaging programs using SBCL?
Date: 
Message-ID: <1169609124.032205.261190@m58g2000cwm.googlegroups.com>
So, after many months, a couple thousand lines of CL, and a lot of
learning, I finally have my simulation running at a reasonable speed
and passing tests. So me and my colleagues can start using it to do
real work, at least until I come up with more test cases. ;-)

Now, I'd prefer not to have to subject them to the indignity of setting
up Emacs, SLIME and SBCL all independently if they don't have to, which
means that I'd like to "shrinkwrap" things somehow. I don't need things
in a single file or anything, and we're all using Macs so a .app
directory could be just the thing. Or a script to install everything.
Ideally I'd want something that they can double click, or a single
command that they can type at the command line, with everything working
from there.

For that matter, an executable image wouldn't be too bad; the only
issue there is that SBCL on the command line lacks the convenience
features like tab completion and a command history. If there's a simple
way to get that functionality, that solution would work for me.

I know my desires are a bit vague. I'm mainly trying to get a sense of
what my options are.

Thanks,
Pillsy

From: D Herring
Subject: Re: Packaging programs using SBCL?
Date: 
Message-ID: <OeudnXIIjqTadivYnZ2dnUVZ_o2vnZ2d@comcast.com>
Pillsy wrote:
> So, after many months, a couple thousand lines of CL, and a lot of
> learning, I finally have my simulation running at a reasonable speed
> and passing tests. So me and my colleagues can start using it to do
> real work, at least until I come up with more test cases. ;-)

Congrats, I think.

> Now, I'd prefer not to have to subject them to the indignity of setting
> up Emacs, SLIME and SBCL all independently if they don't have to, which
> means that I'd like to "shrinkwrap" things somehow. I don't need things
> in a single file or anything, and we're all using Macs so a .app
> directory could be just the thing. Or a script to install everything.
> Ideally I'd want something that they can double click, or a single
> command that they can type at the command line, with everything working
> from there.
> 
> For that matter, an executable image wouldn't be too bad; the only
> issue there is that SBCL on the command line lacks the convenience
> features like tab completion and a command history. If there's a simple
> way to get that functionality, that solution would work for me.

I don't have a Mac, but if I were doing this on another 'nix...

I might start by putting the .app files for Slime, Emacs, and SBCL into 
one directory.  Then include your lisp sources and maybe have SBCL dump 
an image[1] of the fully-loaded application.  Adjust Emacs' 
inferior-lisp-program to pass SBCL command-line arguments that load your 
application at startup[2].  Then write an application.emacs file (Emacs 
lisp commands) that configures and starts slime[3].  Then write a simple 
shell script that starts Emacs, using command-line arguments[4] to 
auto-run application.emacs.

If you get that working, then I presume its straightforward to convert 
this directory into a .app that runs the shell script when executed...

Good luck,
Daniel

References:
[1] http://www.sbcl.org/manual/Saving-a-Core-Image.html
[2] http://www.sbcl.org/manual/Command-Line-Options.html
Maybe use --no-sysinit --no-userinit along with --core or --load
[3] http://common-lisp.net/project/slime/doc/html/Auto_002dSLIME.html
[4] See `man emacs`.  Maybe use something like
#!./emacs -q -l application.emacs -f run-app
From: Richard M Kreuter
Subject: Re: Packaging programs using SBCL?
Date: 
Message-ID: <87mz48s952.fsf@progn.net>
"Pillsy" <·········@gmail.com> writes:

> ...I'd like to "shrinkwrap" things somehow. I don't need things in a
> single file or anything, and we're all using Macs so a .app
> directory could be just the thing. Or a script to install
> everything.  Ideally I'd want something that they can double click,
> or a single command that they can type at the command line, with
> everything working from there.
>
> For that matter, an executable image wouldn't be too bad; the only
> issue there is that SBCL on the command line lacks the convenience
> features like tab completion and a command history. If there's a simple
> way to get that functionality, that solution would work for me.

(I don't know offhand whether this works on Macs, but...) SBCL has a
feature to produce single-file executables that contain both a runtime
and Lisp image; it's an option to save-lisp-and-die, which is SBCL's
image-saving routine.  For example, the following incantation will
leave an executable at /home/me/program that will invoke a function
called TOPLEVEL-FUNCTION when the executable is invoked.

* (save-lisp-and-die "/home/me/program" :executable t
                     :toplevel #'toplevel-function)

There are some caveats at present (Jan 07), which may be irrelevant
for you:

(1) the SBCL runtime prints a banner at startup, and so the executable
    will print this banner, too.  You can suppress the banner with the
    command-line argument --noinform (and of course that argument can
    be supplied via a wrapper script)

(2) if your program requires loading any foreign libraries in addition
    to the standard C library, those libraries will need to be present
    in the deployment environment (here's where Mac's bundles can help
    out, I think, though I don't know how to produce them).

As for tab completion and command line history, there's an
asdf-installable library called linedit that provides customizale
readline-like completion and history.  It works well with SBCL, and
uses uffi, osicat, and terminfo (which are also asdf-installable).
However, both osicat and linedit create tiny foreign libraries to wrap
a few C functions, and so you'll need to provide those libraries
libraries in the deployment environment, as per point (2) above.

Hope that helps...