Recently Written · git

clapt

Archived: generate SBCL cores for lots of libraries.

git clone https://github.com/equwal/clapt

Log | Files | Refs


commit b70e4453246832e1fa5927857ac41717456a4e2b
Spenser Truex <web@spensertruex.com>
2019-11-02 17:54:00 -0700

Can save, cannot install.

 CONFIG-ASDF.lisp                  |  8 ++++++++
 CONFIG-QUICKLISP.lisp             |  8 ++++++++
 README.md                         | 10 ++++++++--
 code/early.lisp                   | 12 ++++++++++++
 code/install.lisp                 |  4 ++++
 package.lisp => code/package.lisp |  3 ++-
 code/save.lisp                    | 28 ++++++++++++++++++++++++++++
 sbcl-librarian.asd                | 10 +++++++---
 sbcl-librarian.lisp               |  3 ---
 9 files changed, 77 insertions(+), 9 deletions(-)
diff --git a/CONFIG-ASDF.lisp b/CONFIG-ASDF.lisp
new file mode 100644
index 0000000..3732ebd
--- /dev/null
+++ b/CONFIG-ASDF.lisp
@@ -0,0 +1,8 @@
+(in-package #:sbcl-librarian)
+
+(defparameter *asdf-packages*
+  '(
+    ;; Example:
+    ;; utils my-custom-frobber
+    )
+  "User configured Packages for ASDF. Edit this!")
diff --git a/CONFIG-QUICKLISP.lisp b/CONFIG-QUICKLISP.lisp
new file mode 100644
index 0000000..0e8c9c3
--- /dev/null
+++ b/CONFIG-QUICKLISP.lisp
@@ -0,0 +1,8 @@
+(in-package #:sbcl-librarian)
+
+(defparameter *quicklisp-packages*
+  '(
+    ;; Example:
+    ;; alexandria uiop cl-ppcre
+    )
+  "User configured Packages for Quicklisp. Edit this!")
diff --git a/README.md b/README.md
index bb0ec86..6d37dba 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,15 @@
 # sbcl-librarian
-### _Spenser Truex <web@spensertruex.com>_
 
-This is a project to do ... something.
+Instant SBCL startup with any number of ASDF libraries by loading the and
+dumping a core once.
+
+## Install
+
+We need to know which packages are needed, and whether they are from quicklisp.
+This is a lisp file. Modify `CONFIG-ASDF.lisp` and/or `CONFIG-QUICKLISP.lisp`.
 
 ## License
 
 GNU GPL v3
 
+### _Spenser Truex <web@spensertruex.com>_
diff --git a/code/early.lisp b/code/early.lisp
new file mode 100644
index 0000000..136dbbb
--- /dev/null
+++ b/code/early.lisp
@@ -0,0 +1,12 @@
+(in-package #:sbcl-librarian)
+
+(defun untilde (path)
+  "Ensure the has no tilde."
+  (if (char= #\~ (elt path 0))
+      (merge-pathnames (user-homedir-pathname)
+                       (subseq path 2))
+      path))
+
+(defparameter *core-path* (untilde "~/.sbcl-library.core")
+  "The default place to store the library core.")
+(defparameter *sbclrc-path* (untilde "~/.sbclrc"))
diff --git a/code/install.lisp b/code/install.lisp
new file mode 100644
index 0000000..9c14ce1
--- /dev/null
+++ b/code/install.lisp
@@ -0,0 +1,4 @@
+(in-package #:sbcl-librarian)
+
+(defun install (&optional (core-path *core-path*)
+                  (sbclrc-path *sbclrc-path*)))
diff --git a/package.lisp b/code/package.lisp
similarity index 52%
rename from package.lisp
rename to code/package.lisp
index e491094..a6b1c06 100644
--- a/package.lisp
+++ b/code/package.lisp
@@ -1,4 +1,5 @@
 ;;;; package.lisp
 
 (defpackage #:sbcl-librarian
-  (:use #:cl))
+  (:use #:cl)
+  (:export #:save #:install))
diff --git a/code/save.lisp b/code/save.lisp
new file mode 100644
index 0000000..56d28ff
--- /dev/null
+++ b/code/save.lisp
@@ -0,0 +1,28 @@
+(in-package #:sbcl-librarian)
+
+(defun save (&optional (core-path *core-path*))
+  (load-configs)
+  ;; Should ensure that this is friendly. ~ is not allowed, does it actually
+  ;; exist, etc.
+  (save-lisp-and-die
+   (asdf/pathname:ensure-absolute-pathname
+    (untilde core-path))))
+
+(defun load-configs ()
+  (with-open-file (q "CONFIG-QUICKLISP.lisp")
+    (with-open-file (a "CONFIG-ASDF.lisp")
+      (let ((qpack (verifying :quicklisp (read q)))
+            (apack (verifying :asdf (read a))))
+        (mapcar #'(lambda (fn lst)
+                    (mapc fn lst)
+                    (require lst))
+                `(#',ql:quickload #',asdf:load-system)
+                `(,apack ,qpack))))))
+
+(defgeneric verifying (manager packages)
+  (:documentation "Verify that packages exist for a given manager."))
+
+;;; Would be nice to have an interface here with continuations, friendly output
+;;; and warnings, etc.
+(defmethod verifying ((manager :quicklisp) packages) packages)
+(defmethod verifying ((manager :asdf) packages) packages)
diff --git a/sbcl-librarian.asd b/sbcl-librarian.asd
index 55f50db..f355534 100644
--- a/sbcl-librarian.asd
+++ b/sbcl-librarian.asd
@@ -1,10 +1,14 @@
 ;;;; sbcl-librarian.asd
 
 (asdf:defsystem #:sbcl-librarian
-  :description "Describe sbcl-librarian here"
+  :description "Load up projects and dump the core somewhere."
   :author "Spenser Truex <web@spensertruex.com>"
   :license  "GNU GPL v3"
   :version "0.0.1"
   :serial t
-  :components ((:file "package")
-               (:file "sbcl-librarian")))
+  :components ((:file "CONFIG-ASDF")
+               (:file "CONFIG-QUICKLISP")
+               (:file "code/package")
+               (:file "code/early")
+               (:file "code/save")
+               (:file "code/install")))
diff --git a/sbcl-librarian.lisp b/sbcl-librarian.lisp
deleted file mode 100644
index 27ab59c..0000000
--- a/sbcl-librarian.lisp
+++ /dev/null
@@ -1,3 +0,0 @@
-;;;; sbcl-librarian.lisp
-
-(in-package #:sbcl-librarian)