Skip to content
Snippets Groups Projects
asdf.lisp 134 KiB
Newer Older
;;; -*- mode: common-lisp; package: asdf; -*-
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
;;; This is ASDF: Another System Definition Facility.
;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <asdf-devel@common-lisp.net>.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
;;; Note first that the canonical source for ASDF is presently
;;; <URL:http://common-lisp.net/project/asdf/>.
;;;
;;; If you obtained this copy from anywhere else, and you experience
;;; trouble using it, or find bugs, you may want to check at the
;;; location above for a more recent version (and for documentation
;;; and test files, if your copy came without them) before reporting
;;; bugs.  There are usually two "supported" revisions - the git HEAD
;;; is the latest development version, whereas the revision tagged
;;; RELEASE may be slightly older but is considered `stable'

;;; -- LICENSE START
;;; (This is the MIT / X Consortium license as taken from
;;;  http://www.opensource.org/licenses/mit-license.html on or about
;;;  Monday; July 13, 2009)
;;;
;;; Copyright (c) 2001-2010 Daniel Barlow and contributors
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining
;;; a copy of this software and associated documentation files (the
;;; "Software"), to deal in the Software without restriction, including
;;; without limitation the rights to use, copy, modify, merge, publish,
;;; distribute, sublicense, and/or sell copies of the Software, and to
;;; permit persons to whom the Software is furnished to do so, subject to
;;; the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be
;;; included in all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
;;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
;;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
;;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;;;
;;; -- LICENSE END
;;; The problem with writing a defsystem replacement is bootstrapping:
;;; we can't use defsystem to compile it.  Hence, all in one file.
Daniel Barlow's avatar
Daniel Barlow committed

#+xcvb (module ())

#|(declaim (optimize (speed 2) (debug 2) (safety 3))
#+sbcl (sb-ext:muffle-conditions sb-ext:compiler-note))|#
#+ecl (require :cmp)
;;;; Create packages in a way that is compatible with hot-upgrade.
;;;; See https://bugs.launchpad.net/asdf/+bug/485687
;;;; See more at the end of the file.

#+gcl
(eval-when (:compile-toplevel :load-toplevel)
  (defpackage :asdf-utilities (:use :cl))
  (defpackage :asdf (:use :cl :asdf-utilities)))

(eval-when (:load-toplevel :compile-toplevel :execute)
  #+allegro
  (setf excl::*autoload-package-name-alist*
        (remove "asdf" excl::*autoload-package-name-alist*
                :test 'equalp :key 'car))
          ;; the 1+ helps the version bumping script discriminate
          (subseq "VERSION:1.724" (1+ (length "VERSION"))))
         (existing-asdf (find-package :asdf))
         (vername '#:*asdf-version*)
         (versym (and existing-asdf
                      (find-symbol (string vername) existing-asdf)))
         (existing-version (and versym (boundp versym) (symbol-value versym)))
         (already-there (equal asdf-version existing-version)))
    (unless (and existing-asdf already-there)
                "~&Upgrading ASDF package ~@[from version ~A ~]to version ~A~%"
                existing-version asdf-version))
      (labels
          ((rename-away (package)
             (loop :with name = (package-name package)
               :for i :from 1 :for new = (format nil "~A.~D" name i)
               :unless (find-package new) :do
               (rename-package-name package name new)))
           (rename-package-name (package old new)
             (let* ((old-names (cons (package-name package)
                                     (package-nicknames package)))
                    (new-names (subst new old old-names :test 'equal))
                    (new-name (car new-names))
                    (new-nicknames (cdr new-names)))
               (rename-package package new-name new-nicknames)))
           (ensure-exists (name nicknames use)
             (let* ((previous
                     (remove-duplicates
                      (remove-if
                       #'null
                       (mapcar #'find-package (cons name nicknames)))
                      :from-end t)))
               (cond
                 (previous
                  ;; do away with packages with conflicting (nick)names
                  (map () #'rename-away (cdr previous))
                  ;; reuse previous package with same name
                  (let ((p (car previous)))
                    (rename-package p name nicknames)
                    (ensure-use p use)
                    p))
                 (t
                  (make-package name :nicknames nicknames :use use)))))
           (find-sym (symbol package)
             (find-symbol (string symbol) package))
           (intern* (symbol package)
             (intern (string symbol) package))
           (remove-symbol (symbol package)
             (let ((sym (find-sym symbol package)))
               (when sym
                 (unexport sym package)
                 (unintern sym package))))
           (ensure-unintern (package symbols)
             (dolist (sym symbols) (remove-symbol sym package)))
           (ensure-shadow (package symbols)
             (shadow symbols package))
           (ensure-use (package use)
             (dolist (used (reverse use))
               (do-external-symbols (sym used)
                 (unless (eq sym (find-sym sym package))
                   (remove-symbol sym package)))
               (use-package used package)))
           (ensure-fmakunbound (package symbols)
             (loop :for name :in symbols
               :for sym = (find-sym name package)
               :when sym :do (fmakunbound sym)))
           (ensure-export (package export)
             (let ((syms (loop :for x :in export :collect
                           (intern* x package))))
               (do-external-symbols (sym package)
                 (unless (member sym syms)
                   (remove-symbol sym package)))
               (dolist (sym syms)
                 (export sym package))))
           (ensure-package (name &key nicknames use unintern fmakunbound shadow export)
             (let ((p (ensure-exists name nicknames use)))
               (ensure-unintern p unintern)
               (ensure-shadow p shadow)
               (ensure-export p export)
               (ensure-fmakunbound p fmakunbound)
               p)))
        (macrolet
            ((pkgdcl (name &key nicknames use export
                           redefined-functions unintern fmakunbound shadow)
               `(ensure-package
                 ',name :nicknames ',nicknames :use ',use :export ',export
                 :shadow ',shadow
                 :unintern ',(append #-(or gcl ecl) redefined-functions
                                     unintern)
                 :fmakunbound ',(append #+(or gcl ecl) redefined-functions
                                        fmakunbound))))
          (pkgdcl
           :asdf-utilities
           :nicknames (#:asdf-extensions)
           :use (#:common-lisp)
           :unintern (#:split #:make-collector)
           :export
           (#:absolute-pathname-p
            #:aif
            #:appendf
            #:asdf-message
            #:coerce-name
            #:directory-pathname-p
            #:ends-with
            #:ensure-directory-pathname
            #:getenv
            #:get-uid
            #:length=n-p
            #:merge-pathnames*
            #:pathname-directory-pathname
            #:read-file-forms
            #:remove-keys
            #:remove-keyword
            #:resolve-symlinks
            #:split-string
            #:component-name-to-pathname-components
            #:split-name-type
            #:system-registered-p
            #:truenamize
            #:while-collecting))
          (pkgdcl
           :asdf
           :use (:common-lisp :asdf-utilities)
           :redefined-functions
           (#:perform #:explain #:output-files #:operation-done-p
            #:perform-with-restarts #:component-relative-pathname
            #:system-source-file #:operate #:find-component)
Loading
Loading full blame...