Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rework swank.asd to produce actual compilation artifact (#760)
* Rework swank.asd to produce actual compilation artifact

Until now swank.asd compiled the system files when it was loaded. That is
roughly compatible with what slime does when loading swank, however that is not
useful for swank that is loaded as a standalone system without slime. Instead of
producing compilation artifacts that may be further processed by asdf (either in
bundle-op or otherwise) it puts fasls in ~/.slime directory.

When a system "foo" depends on "swank" then before the system "foo" is loaded
swank is loaded itself. However if we only compile systems and then try to load
a bundle then all we have is the swank-loader artifact - no "SWANK" package nor
nothing. This issue has been unnoticed because usually people dump images
instead of having separate compilation and loading steps.

This commit defines two systems "swank" and "swank-exts" - one for the core
runtime and one for contribs.

* swank.asd: inhibit loading swank only when started from emacs

This inhibition is tailored for possibly incompatible slime/swank
instances (according to the comment at the top of the file), so there is no need
to prevent loading a different swank version in the image without slime.

* Remove locking of the system "swank"

Don't prevent reloading the system "swank" even if it was previously loaded by
emacs. If the user wants to reload swank from a different directory then so be
it. Otherwise we can't compile bundles that depend on slime.

* meta: add an entry to NEWS section
  • Loading branch information
dkochmanski committed Mar 14, 2023
1 parent e193bc5 commit dd179f4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 31 deletions.
2 changes: 2 additions & 0 deletions NEWS
@@ -1,5 +1,7 @@
* SLIME News -*- mode: outline; coding: utf-8 -*-
* 2.29 (unreleased)
** Core
*** Loading the system "swank" with ASDF produces compilation artifacts
** ABCL
*** Fix missing source position from string buffer location
* 2.28 (January 2023)
Expand Down
78 changes: 47 additions & 31 deletions swank.asd
Expand Up @@ -6,17 +6,10 @@
;; This is only useful if you want to start a Swank server in a Lisp
;; processes that doesn't run under Emacs. Lisp processes created by
;; `M-x slime' automatically start the server.
;;
;; If Swank is already loaded (e.g. the Lisp is running under SLIME),
;; then attempts to load it via asdf do nothing, except for emitting a
;; warning if Swank is to be loaded from a location that's different
;; from the location where it was originally loaded from. This
;; behavior is intended to prevent loading a possibly incompatible
;; version of Swank with a running SLIME.

;; Usage:
;;
;; (require :swank)
;; (asdf:load-system "swank")
;; (swank:create-swank-server PORT) => ACTUAL-PORT
;;
;; (PORT can be zero to mean "any available port".)
Expand All @@ -26,27 +19,50 @@
;; This code has been placed in the Public Domain. All warranties
;; are disclaimed.

(defclass swank-loader-file (asdf:cl-source-file) ())

;;;; after loading run init

(defmethod asdf:perform ((o asdf:load-op) (f swank-loader-file))
(let ((var (uiop:find-symbol* '#:*source-directory* '#:swank-loader nil)))
(cond ((and var (boundp var))
(let ((loaded (truename (symbol-value var)))
(requested (truename (asdf:system-source-directory "swank"))))
(unless (equal requested loaded)
(warn "~@<Not loading SWANK from ~S because it was ~
already loaded from ~S.~:@>"
requested loaded))))
(t
;; swank-loader computes its own source/fasl relation based
;; on the TRUENAME of the loader file, so we need a "manual"
;; CL:LOAD invocation here.
(load (asdf::component-pathname f))
;; After loading, run the swank-loader init routines.
(funcall (read-from-string "swank-loader::init") :reload t)))))
(asdf:defsystem "swank"
:components ((:file "swank-loader")
(:file "packages")
(:file "xref" :if-feature :clisp)
(:file "metering" :if-feature (:or :clozure :clisp :clasp))
(:module "backend"
:pathname "swank"
:components ((:file "backend")
(:file "source-path-parser" :if-feature (:or :cmu :scl :sbcl))
(:file "source-file-cache" :if-feature (:or :cmu :scl :sbcl))
(:file "cmucl" :if-feature :cmu)
(:file "scl" :if-feature :scl)
(:file "sbcl" :if-feature :sbcl)
(:file "ccl" :if-feature :clozure)
(:file "lispworks" :if-feature :lispworks)
(:file "allegro" :if-feature :allegro)
(:file "clisp" :if-feature :clisp)
(:file "abcl" :if-feature :armedbear)
(:file "corman" :if-feature :cormanlisp)
(:file "ecl" :if-feature :ecl)
(:file "clasp" :if-feature :clasp)
(:file "mkcl" :if-feature :mkcl)
(:file "mezzano" :if-feature :mezzano)
(:file "gray" :if-feature (:not :armedbear))
(:file "match")
(:file "rpc")))
(:file "swank")))

(asdf:defsystem :swank
:default-component-class swank-loader-file
:components ((:file "swank-loader")))
(asdf:defsystem "swank/exts"
:depends-on ("swank")
:pathname "contrib"
:components ((:file "swank-util")
(:file "swank-repl")
(:file "swank-c-p-c")
(:file "swank-arglists")
(:file "swank-fuzzy")
(:file "swank-fancy-inspector")
(:file "swank-presentations")
(:file "swank-presentation-streams")
(:file "swank-asdf" :if-feature (:or :asdf2 :asdf3 :sbcl :ecl))
(:file "swank-package-fu")
(:file "swank-hyperdoc")
(:file "swank-sbcl-exts" :if-feature :sbcl)
(:file "swank-mrepl")
(:file "swank-trace-dialog")
(:file "swank-macrostep")
(:file "swank-quicklisp")))

0 comments on commit dd179f4

Please sign in to comment.