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

4
(uiop/package:define-package :asdf/footer
5
  (:recycle :asdf/footer :asdf)
6
  (:use :uiop/common-lisp :uiop
7
        :asdf/system ;; used by ECL
8
        :asdf/upgrade :asdf/system-registry :asdf/operate :asdf/bundle)
9 10 11 12
  ;; 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*
13 14
		#+ecl #:*load-hooks*)
  #+(or clasp mkcl) (:import-from :si #:*load-hooks*))
15

16 17
(in-package :asdf/footer)

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


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

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
34
  #+(or clasp ecl mkcl)
35
  (progn
36 37 38 39 40 41 42 43 44 45 46 47 48
    (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)))
49 50 51 52 53
    (defun wrap-module-provider-function (provider)
      (ensure-gethash provider *wrapped-module-provider*
		      (constantly
		       #'(lambda (module-name)
			   (wrap-module-provider provider module-name)))))
54
    (setf *module-provider-functions*
55
	  (mapcar #'wrap-module-provider-function *module-provider-functions*))))
56

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

63 64

;;;; Done!
65
(with-upgradability ()
66
  #+allegro ;; restore *w-o-n-r-c* setting as saved in uiop/common-lisp
67
  (when (boundp 'excl:*warn-on-nested-reader-conditionals*)
68
    (setf excl:*warn-on-nested-reader-conditionals* uiop/common-lisp::*acl-warn-save*))
69

70
  ;; Advertise the features we provide.
71
  (dolist (f '(:asdf :asdf2 :asdf3 :asdf3.1 :asdf3.2 :asdf3.3)) (pushnew f *features*))
72

73 74
  ;; Provide both lowercase and uppercase, to satisfy more people, especially LispWorks users.
  (provide "asdf") (provide "ASDF")
75

76
  ;; Finally, call a function that will cleanup in case this is an upgrade of an older ASDF.
77
  (cleanup-upgraded-asdf))
78

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