Coverage report: /home/ellis/comp/core/lib/cli/multi.lisp
Kind | Covered | All | % |
expression | 0 | 14 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; multi.lisp --- Multi-entry Lisp Cores
3
;; Busybox-style Lisp binaries
7
;; We have quite a few Lisp 'binaries' at this point, each of which
8
;; are quite bloated Lisp core images with tons of duplication.
10
;; This setup isn't ideal and while we can compress each individual
11
;; core, we are much better off if we can just share the same core
12
;; image and access multiple top-level entrypoints easily.
14
;; The problem of course is that we want to be able to execute the
15
;; single core the same as we would the individual bloated
16
;; binaries. To do this we have two options:
18
;; - build (non-lisp) trampoline programs which loads the
19
;; (non-executable) core as a shared library, and calls
20
;; foreign-symbols exposed from lisp.
22
;; - parse argv[0] and dispatch to the correct top-level
23
;; function. Control argv[0] by symlinking to the executable core.
25
;; This package currently exposes an API for the latter.
28
(in-package :cli/multi)
30
(defmacro define-multi-main (name default &rest mains)
31
"Define a MAIN function for the current package which dispatches
32
based on the value of '(ARG0)' at runtime to one of the pairs in
35
Each element of MAINS is a list of the form (NAME FUNCTION) where NAME
36
is the filename of the symlink which will be handled by the associated
39
When you save an executable lisp image with this function you should
40
arrange for symlinks for each handled value of (ARG0) to be generated
43
(case (keywordicate (string-upcase (pathname-name (cli/clap/util:arg0))))
47
(defun make-symlinks (src &optional directory &rest names)
48
"Make a set of symlinks from SRC to NAMES.
50
If DIRECTORY is non-nil each name in NAMES is considered relative to
53
(setf names (mapcar (lambda (n) (merge-pathnames n directory)) names)))
55
(sb-posix:symlink src n)))