footer.lisp 3.25 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 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
;;;; Register ASDF itself and all its subsystems as preloaded.
(with-upgradability ()
19
  (dolist (s '("asdf" "uiop" "asdf-package-system"))
20
    ;; Don't bother with these system names, no one relies on them anymore:
21
    ;; "asdf-utils" "asdf-bundle" "asdf-driver" "asdf-defsystem"
22 23 24
    (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
  ;; Hook into CL:REQUIRE.
29
  #-clisp (pushnew 'module-provide-asdf *module-provider-functions*)
30
  #+clisp (if-let (x (find-symbol* '#:*module-provider-functions* :custom nil))
31
            (eval `(pushnew 'module-provide-asdf ,x)))
32

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

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

62 63

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

69
  ;; Advertise the features we provide.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
70
  (dolist (f '(:asdf :asdf2 :asdf3 :asdf3.1 :asdf3.2 :asdf-package-system)) (pushnew f *features*))
71

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

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

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