footer.lisp 3.04 KB
Newer Older
1 2 3
;;;; -----------------------------------------------------------------------
;;;; ASDF Footer: last words and cleanup

4
(uiop/package:define-package :asdf/footer
5
  (:recycle :asdf/footer :asdf)
Robert P. Goldman's avatar
Robert P. Goldman committed
6
  (:use :uiop/common-lisp :uiop
7 8 9 10 11
        :asdf/upgrade :asdf/find-system :asdf/operate :asdf/bundle)
  ;; Happily, all those implementations all have the same module-provider hook interface.
  #+(or abcl clasp cmucl clozure ecl mkcl sbcl)
  (:import-from #+abcl :sys #+(or clasp cmucl ecl) :ext #+clozure :ccl #+mkcl :mk-ext #+sbcl sb-ext
		#:*module-provider-functions*
12 13
		#+ecl #:*load-hooks*)
  #+(or clasp mkcl) (:import-from :si #:*load-hooks*))
14

15 16
(in-package :asdf/footer)

17 18 19 20 21 22 23 24
;;;; Register ASDF itself and all its subsystems as preloaded.
(with-upgradability ()
  (dolist (s '("asdf" "uiop" "asdf-defsystem" "asdf-package-system"))
    ;; Don't bother with these system names, no one relies on them anymore:
    ;; "asdf-utils" "asdf-bundle" "asdf-driver"
    (register-preloaded-system s :version *asdf-version*)))


25
;;;; Hook ASDF into the implementation's REQUIRE and other entry points.
26
#+(or abcl clasp clisp clozure cmucl ecl mkcl sbcl)
27
(with-upgradability ()
28 29 30
  #-clisp (pushnew 'module-provide-asdf *module-provider-functions*)
  #+clisp (if-let (x (and #+clisp (find-symbol* '#:*module-provider-functions* :custom nil)))
            (eval `(pushnew 'module-provide-asdf ,x)))
31

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
32
  #+(or clasp ecl mkcl)
33
  (progn
34 35 36 37 38 39 40 41 42 43 44 45 46
    (pushnew '("fasb" . si::load-binary) *load-hooks* :test 'equal :key 'car)

    #+os-windows
    (unless (assoc "asd" *load-hooks* :test 'equal)
      (appendf *load-hooks* '(("asd" . si::load-source))))

    ;; Wrap module provider functions in an idempotent, upgrade friendly way
    (defvar *wrapped-module-provider* (make-hash-table))
    (setf (gethash 'module-provide-asdf *wrapped-module-provider*) 'module-provide-asdf)
    (defun wrap-module-provider (provider name)
      (let ((results (multiple-value-list (funcall provider name))))
	(when (first results) (register-preloaded-system (coerce-name name)))
	(values-list results)))
47 48 49 50 51
    (defun wrap-module-provider-function (provider)
      (ensure-gethash provider *wrapped-module-provider*
		      (constantly
		       #'(lambda (module-name)
			   (wrap-module-provider provider module-name)))))
52
    (setf *module-provider-functions*
53
	  (mapcar #'wrap-module-provider-function *module-provider-functions*))))
54

55
#+cmucl ;; Hook into the CMUCL herald.
56 57 58
(with-upgradability ()
  (defun herald-asdf (stream)
    (format stream "    ASDF ~A" (asdf-version)))
59
  (setf (getf ext:*herald-items* :asdf) '(herald-asdf)))
60

61 62

;;;; Done!
63 64
(with-upgradability ()
  #+allegro
65
  (when (boundp 'excl:*warn-on-nested-reader-conditionals*)
66
    (setf excl:*warn-on-nested-reader-conditionals* uiop/common-lisp::*acl-warn-save*))
67

68
  (dolist (f '(:asdf :asdf2 :asdf3 :asdf3.1 :asdf-package-system)) (pushnew f *features*))
69

70 71
  ;; Provide both lowercase and uppercase, to satisfy more people, especially LispWorks users.
  (provide "asdf") (provide "ASDF")
72

73
  (cleanup-upgraded-asdf))
74

75 76
(when *load-verbose*
  (asdf-message ";; ASDF, version ~a~%" (asdf-version)))