Changeset 12765 for trunk/abcl/src/org/armedbear
- Timestamp:
- 06/25/10 10:46:06 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/asdf.lisp
r12666 r12765 48 48 #+xcvb (module ()) 49 49 50 (cl:in-package :cl-user) 51 52 (declaim (optimize (speed 2) (debug 2) (safety 3)) 53 #+sbcl (sb-ext:muffle-conditions sb-ext:compiler-note)) 54 55 #+ecl (require :cmp) 56 57 ;;;; Create packages in a way that is compatible with hot-upgrade. 58 ;;;; See https://bugs.launchpad.net/asdf/+bug/485687 59 ;;;; See more at the end of the file. 60 61 #+gcl 62 (eval-when (:compile-toplevel :load-toplevel) 63 (defpackage :asdf-utilities (:use :cl)) 64 (defpackage :asdf (:use :cl :asdf-utilities))) 65 66 (eval-when (:load-toplevel :compile-toplevel :execute) 50 (cl:in-package :cl) 51 (defpackage :asdf-bootstrap (:use :cl)) 52 (in-package :asdf-bootstrap) 53 54 ;; Implementation-dependent tweaks 55 (eval-when (:compile-toplevel :load-toplevel :execute) 56 ;; (declaim (optimize (speed 2) (debug 2) (safety 3)) ; NO: rely on the implementation defaults. 67 57 #+allegro 68 58 (setf excl::*autoload-package-name-alist* 69 59 (remove "asdf" excl::*autoload-package-name-alist* 70 60 :test 'equalp :key 'car)) 71 (let* ((asdf-version 72 ;; the 1+ helps the version bumping script discriminate 73 (subseq "VERSION:1.719" (1+ (length "VERSION")))) 61 #+ecl (require :cmp) 62 #+gcl 63 (eval-when (:compile-toplevel :load-toplevel) 64 (defpackage :asdf-utilities (:use :cl)) 65 (defpackage :asdf (:use :cl :asdf-utilities)))) 66 67 ;;;; Create packages in a way that is compatible with hot-upgrade. 68 ;;;; See https://bugs.launchpad.net/asdf/+bug/485687 69 ;;;; See more at the end of the file. 70 71 (eval-when (:load-toplevel :compile-toplevel :execute) 72 (let* ((asdf-version ;; the 1+ helps the version bumping script discriminate 73 (subseq "VERSION:2.003" (1+ (length "VERSION")))) ; NB: same as 2.105. 74 74 (existing-asdf (find-package :asdf)) 75 75 (vername '#:*asdf-version*) … … 81 81 #-gcl 82 82 (when existing-asdf 83 (format * error-output*83 (format *trace-output* 84 84 "~&Upgrading ASDF package ~@[from version ~A ~]to version ~A~%" 85 85 existing-version asdf-version)) … … 156 156 ((pkgdcl (name &key nicknames use export 157 157 redefined-functions unintern fmakunbound shadow) 158 `(ensure-package 159 ',name :nicknames ',nicknames :use ',use :export ',export 160 :shadow ',shadow 161 :unintern ',(append #-(or gcl ecl) redefined-functions 162 unintern) 163 :fmakunbound ',(append #+(or gcl ecl) redefined-functions 164 fmakunbound)))) 158 `(ensure-package 159 ',name :nicknames ',nicknames :use ',use :export ',export 160 :shadow ',shadow 161 :unintern ',(append #-(or gcl ecl) redefined-functions unintern) 162 :fmakunbound ',(append fmakunbound)))) 165 163 (pkgdcl 166 164 :asdf-utilities … … 291 289 #:ensure-output-translations 292 290 #:apply-output-translations 291 #:compile-file* 293 292 #:compile-file-pathname* 294 293 #:enable-asdf-binary-locations-compatibility … … 328 327 ((m module) added deleted plist &key) 329 328 (declare (ignorable deleted plist)) 329 (format *trace-output* "Updating ~A~%" m) 330 330 (when (member 'components-by-name added) 331 331 (compute-module-components-by-name m)))))) … … 337 337 "Exported interface to the version of ASDF currently installed. A string. 338 338 You can compare this string with e.g.: 339 (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSION) \" 1.704\")."339 (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSION) \"2.000\")." 340 340 *asdf-version*) 341 341 … … 345 345 Defaults to `t`.") 346 346 347 (defvar *compile-file-warnings-behaviour* :warn) 348 349 (defvar *compile-file-failure-behaviour* #+sbcl :error #-sbcl :warn) 347 (defvar *compile-file-warnings-behaviour* :warn 348 "How should ASDF react if it encounters a warning when compiling a 349 file? Valid values are :error, :warn, and :ignore.") 350 351 (defvar *compile-file-failure-behaviour* #+sbcl :error #-sbcl :warn 352 "How should ASDF react if it encounters a failure \(per the 353 ANSI spec of COMPILE-FILE\) when compiling a file? Valid values are 354 :error, :warn, and :ignore. Note that ASDF ALWAYS raises an error 355 if it fails to create an output file when compiling.") 350 356 351 357 (defvar *verbose-out* nil) … … 366 372 ;;;; ------------------------------------------------------------------------- 367 373 ;;;; ASDF Interface, in terms of generic functions. 368 369 (defgeneric perform-with-restarts (operation component)) 370 (defgeneric perform (operation component)) 371 (defgeneric operation-done-p (operation component)) 372 (defgeneric explain (operation component)) 373 (defgeneric output-files (operation component)) 374 (defgeneric input-files (operation component)) 374 (defmacro defgeneric* (name formals &rest options) 375 `(progn 376 #+(or gcl ecl) (fmakunbound ',name) 377 (defgeneric ,name ,formals ,@options))) 378 379 (defgeneric* perform-with-restarts (operation component)) 380 (defgeneric* perform (operation component)) 381 (defgeneric* operation-done-p (operation component)) 382 (defgeneric* explain (operation component)) 383 (defgeneric* output-files (operation component)) 384 (defgeneric* input-files (operation component)) 375 385 (defgeneric component-operation-time (operation component)) 376 386 377 (defgeneric system-source-file (system)387 (defgeneric* system-source-file (system) 378 388 (:documentation "Return the source file in which system is defined.")) 379 389 … … 397 407 (defgeneric version-satisfies (component version)) 398 408 399 (defgeneric find-component (base path)409 (defgeneric* find-component (base path) 400 410 (:documentation "Finds the component with PATH starting from BASE module; 401 411 if BASE is nil, then the component is assumed to be a system.")) … … 456 466 (defgeneric traverse (operation component) 457 467 (:documentation 458 "Generate and return a plan for performing `operation` on `component`.459 460 The plan returned is a list of dotted-pairs. Each pair is the `cons`461 of ASDF operation object and a `component`object. The pairs will be462 processed in order by `operate`."))468 "Generate and return a plan for performing OPERATION on COMPONENT. 469 470 The plan returned is a list of dotted-pairs. Each pair is the CONS 471 of ASDF operation object and a COMPONENT object. The pairs will be 472 processed in order by OPERATE.")) 463 473 464 474 … … 467 477 468 478 (defmacro while-collecting ((&rest collectors) &body body) 479 "COLLECTORS should be a list of names for collections. A collector 480 defines a function that, when applied to an argument inside BODY, will 481 add its argument to the corresponding collection. Returns multiple values, 482 a list for each collection, in order. 483 E.g., 484 \(while-collecting \(foo bar\) 485 \(dolist \(x '\(\(a 1\) \(b 2\) \(c 3\)\)\) 486 \(foo \(first x\)\) 487 \(bar \(second x\)\)\)\) 488 Returns two values: \(A B C\) and \(1 2 3\)." 469 489 (let ((vars (mapcar #'(lambda (x) (gensym (symbol-name x))) collectors)) 470 490 (initial-values (mapcar (constantly nil) collectors))) … … 480 500 "Returns a new pathname with same HOST, DEVICE, DIRECTORY as PATHNAME, 481 501 and NIL NAME, TYPE and VERSION components" 482 (make-pathname :name nil :type nil :version nil :defaults pathname)) 483 484 (defun current-directory () 485 (truenamize (pathname-directory-pathname *default-pathname-defaults*))) 502 (when pathname 503 (make-pathname :name nil :type nil :version nil :defaults pathname))) 486 504 487 505 (defun merge-pathnames* (specified &optional (defaults *default-pathname-defaults*)) … … 494 512 (defaults (pathname defaults)) 495 513 (directory (pathname-directory specified)) 496 (directory (if (stringp directory) `(:absolute ,directory) directory))514 #-sbcl (directory (if (stringp directory) `(:absolute ,directory) directory)) 497 515 (name (or (pathname-name specified) (pathname-name defaults))) 498 516 (type (or (pathname-type specified) (pathname-type defaults))) … … 517 535 (values (pathname-host defaults) 518 536 (pathname-device defaults) 519 (if ( null (pathname-directory defaults))520 directory521 (append (pathname-directory defaults) (cdr directory)))537 (if (pathname-directory defaults) 538 (append (pathname-directory defaults) (cdr directory)) 539 directory) 522 540 (unspecific-handler defaults))) 523 541 #+gcl … … 539 557 or "or a flag") 540 558 559 (defun first-char (s) 560 (and (stringp s) (plusp (length s)) (char s 0))) 561 562 (defun last-char (s) 563 (and (stringp s) (plusp (length s)) (char s (1- (length s))))) 564 541 565 (defun asdf-message (format-string &rest format-args) 542 566 (declare (dynamic-extent format-args)) … … 544 568 545 569 (defun split-string (string &key max (separator '(#\Space #\Tab))) 546 "Split STRING in components separater by any of the characters in the sequence SEPARATOR,547 return a list.570 "Split STRING into a list of components separated by 571 any of the characters in the sequence SEPARATOR. 548 572 If MAX is specified, then no more than max(1,MAX) components will be returned, 549 573 starting the separation from the end, e.g. when called with arguments … … 596 620 (multiple-value-bind (relative components) 597 621 (if (equal (first components) "") 598 (if ( and (plusp (length s)) (eql (char s 0) #\/))622 (if (equal (first-char s) #\/) 599 623 (values :absolute (cdr components)) 600 624 (values :relative nil)) 601 625 (values :relative components)) 626 (setf components (remove "" components :test #'equal)) 602 627 (cond 603 628 ((equal last-comp "") 604 (values relative (butlast components) nil))629 (values relative components nil)) ; "" already removed 605 630 (force-directory 606 631 (values relative components nil)) … … 618 643 :unless (eq k key) 619 644 :append (list k v))) 620 621 (defun resolve-symlinks (path)622 #-allegro (truenamize path)623 #+allegro (excl:pathname-resolve-symbolic-links path))624 645 625 646 (defun getenv (x) … … 629 650 (sb-ext:posix-getenv x) 630 651 #+clozure 631 (ccl: :getenv x)652 (ccl:getenv x) 632 653 #+clisp 633 654 (ext:getenv x) … … 644 665 645 666 (defun directory-pathname-p (pathname) 646 "Does `pathname`represent a directory?667 "Does PATHNAME represent a directory? 647 668 648 669 A directory-pathname is a pathname _without_ a filename. The three 649 ways that the filename components can be missing are for it to be `nil`,650 `:unspecific`or the empty string.651 652 Note that this does _not_ check to see that `pathname`points to an670 ways that the filename components can be missing are for it to be NIL, 671 :UNSPECIFIC or the empty string. 672 673 Note that this does _not_ check to see that PATHNAME points to an 653 674 actually-existing directory." 654 675 (flet ((check-one (x) … … 734 755 (when (typep p 'logical-pathname) (return p)) 735 756 (ignore-errors (return (truename p))) 736 (when (stringp directory) 737 (return p)) 738 (when (not (eq :absolute (car directory))) 739 (return p)) 757 #-sbcl (when (stringp directory) (return p)) 758 (when (not (eq :absolute (car directory))) (return p)) 740 759 (let ((sofar (ignore-errors (truename (pathname-root p))))) 741 760 (unless sofar (return p)) … … 761 780 (return (solution nil)))))))) 762 781 782 (defun resolve-symlinks (path) 783 #-allegro (truenamize path) 784 #+allegro (excl:pathname-resolve-symbolic-links path)) 785 786 (defun default-directory () 787 (truenamize (pathname-directory-pathname *default-pathname-defaults*))) 788 763 789 (defun lispize-pathname (input-file) 764 790 (make-pathname :type "lisp" :defaults input-file)) 791 792 (defparameter *wild-path* 793 (make-pathname :directory '(:relative :wild-inferiors) 794 :name :wild :type :wild :version :wild)) 795 796 (defun wilden (path) 797 (merge-pathnames* *wild-path* path)) 798 799 (defun directorize-pathname-host-device (pathname) 800 (let* ((root (pathname-root pathname)) 801 (wild-root (wilden root)) 802 (absolute-pathname (merge-pathnames* pathname root)) 803 (foo (make-pathname :directory '(:absolute "FOO") :defaults root)) 804 (separator (last-char (namestring foo))) 805 (root-namestring (namestring root)) 806 (root-string 807 (substitute-if #\/ 808 (lambda (x) (or (eql x #\:) 809 (eql x separator))) 810 root-namestring))) 811 (multiple-value-bind (relative path filename) 812 (component-name-to-pathname-components root-string t) 813 (declare (ignore relative filename)) 814 (let ((new-base 815 (make-pathname :defaults root 816 :directory `(:absolute ,@path)))) 817 (translate-pathname absolute-pathname wild-root (wilden new-base)))))) 765 818 766 819 ;;;; ------------------------------------------------------------------------- … … 775 828 ;; order to fix all conditions that build on it. -- rgr, 28-Jul-02.] 776 829 #+cmu (:report print-object)) 830 831 (declaim (ftype (function (t) t) 832 format-arguments format-control 833 error-name error-pathname error-condition 834 duplicate-names-name 835 error-component error-operation 836 module-components module-components-by-name) 837 (ftype (function (t t) t) (setf module-components-by-name))) 838 777 839 778 840 (define-condition formatted-system-definition-error (system-definition-error) … … 895 957 896 958 (defun compute-module-components-by-name (module) 897 (let ((hash (m odule-components-by-name module)))898 ( clrhashhash)959 (let ((hash (make-hash-table :test 'equal))) 960 (setf (module-components-by-name module) hash) 899 961 (loop :for c :in (module-components module) 900 962 :for name = (component-name c) … … 912 974 :accessor module-components) 913 975 (components-by-name 914 :initform (make-hash-table :test 'equal)915 976 :accessor module-components-by-name) 916 977 ;; What to do if we can't satisfy a dependency of one of this module's … … 940 1001 (merge-pathnames* 941 1002 (component-relative-pathname component) 942 ( component-parent-pathname component))))1003 (pathname-directory-pathname (component-parent-pathname component))))) 943 1004 (unless (or (null pathname) (absolute-pathname-p pathname)) 944 1005 (error "Invalid relative pathname ~S for component ~S" pathname component)) … … 1014 1075 1015 1076 (defun map-systems (fn) 1016 "Apply `fn`to each defined system.1017 1018 `fn`should be a function of one argument. It will be1077 "Apply FN to each defined system. 1078 1079 FN should be a function of one argument. It will be 1019 1080 called with an object of type asdf:system." 1020 1081 (maphash (lambda (_ datum) … … 1029 1090 1030 1091 (defparameter *system-definition-search-functions* 1031 '(sysdef-central-registry-search sysdef-source-registry-search ))1092 '(sysdef-central-registry-search sysdef-source-registry-search sysdef-find-asdf)) 1032 1093 1033 1094 (defun system-definition-pathname (system) … … 1054 1115 Going forward, we recommend new users should be using the source-registry. 1055 1116 ") 1117 1118 (defun probe-asd (name defaults) 1119 (block nil 1120 (when (directory-pathname-p defaults) 1121 (let ((file 1122 (make-pathname 1123 :defaults defaults :version :newest :case :local 1124 :name name 1125 :type "asd"))) 1126 (when (probe-file file) 1127 (return file))) 1128 #+(and (or win32 windows mswindows mingw32) (not cygwin) (not clisp)) 1129 (let ((shortcut 1130 (make-pathname 1131 :defaults defaults :version :newest :case :local 1132 :name (concatenate 'string name ".asd") 1133 :type "lnk"))) 1134 (when (probe-file shortcut) 1135 (let ((target (parse-windows-shortcut shortcut))) 1136 (when target 1137 (return (pathname target))))))))) 1056 1138 1057 1139 (defun sysdef-central-registry-search (system) … … 1073 1155 (message 1074 1156 (format nil 1075 "~@<While searching for system `~a`: `~a`evaluated ~1076 to `~a`which is not a directory.~@:>"1157 "~@<While searching for system ~S: ~S evaluated ~ 1158 to ~S which is not a directory.~@:>" 1077 1159 system dir defaults))) 1078 1160 (error message)) … … 1123 1205 1124 1206 (defun find-system (name &optional (error-p t)) 1125 (let* ((name (coerce-name name)) 1126 (in-memory (system-registered-p name)) 1127 (on-disk (system-definition-pathname name))) 1128 (when (and on-disk 1129 (or (not in-memory) 1130 (< (car in-memory) (safe-file-write-date on-disk)))) 1131 (let ((package (make-temporary-package))) 1132 (unwind-protect 1133 (handler-bind 1134 ((error (lambda (condition) 1135 (error 'load-system-definition-error 1136 :name name :pathname on-disk 1137 :condition condition)))) 1138 (let ((*package* package)) 1139 (asdf-message 1140 "~&~@<; ~@;loading system definition from ~A into ~A~@:>~%" 1141 on-disk *package*) 1142 (load on-disk))) 1143 (delete-package package)))) 1144 (let ((in-memory (system-registered-p name))) 1145 (if in-memory 1146 (progn (when on-disk (setf (car in-memory) 1147 (safe-file-write-date on-disk))) 1148 (cdr in-memory)) 1149 (when error-p (error 'missing-component :requires name)))))) 1207 (catch 'find-system 1208 (let* ((name (coerce-name name)) 1209 (in-memory (system-registered-p name)) 1210 (on-disk (system-definition-pathname name))) 1211 (when (and on-disk 1212 (or (not in-memory) 1213 (< (car in-memory) (safe-file-write-date on-disk)))) 1214 (let ((package (make-temporary-package))) 1215 (unwind-protect 1216 (handler-bind 1217 ((error (lambda (condition) 1218 (error 'load-system-definition-error 1219 :name name :pathname on-disk 1220 :condition condition)))) 1221 (let ((*package* package)) 1222 (asdf-message 1223 "~&~@<; ~@;loading system definition from ~A into ~A~@:>~%" 1224 on-disk *package*) 1225 (load on-disk))) 1226 (delete-package package)))) 1227 (let ((in-memory (system-registered-p name))) 1228 (if in-memory 1229 (progn (when on-disk (setf (car in-memory) 1230 (safe-file-write-date on-disk))) 1231 (cdr in-memory)) 1232 (when error-p (error 'missing-component :requires name))))))) 1150 1233 1151 1234 (defun register-system (name system) … … 1153 1236 (setf (gethash (coerce-name name) *defined-systems*) 1154 1237 (cons (get-universal-time) system))) 1238 1239 (defun sysdef-find-asdf (system) 1240 (let ((name (coerce-name system))) 1241 (when (equal name "asdf") 1242 (let* ((registered (cdr (gethash name *defined-systems*))) 1243 (asdf (or registered 1244 (make-instance 1245 'system :name "asdf" 1246 :source-file (or *compile-file-truename* *load-truename*))))) 1247 (unless registered 1248 (register-system "asdf" asdf)) 1249 (throw 'find-system asdf))))) 1155 1250 1156 1251 … … 1172 1267 1173 1268 (defmethod find-component ((module module) (name string)) 1174 (when (slot-boundp module 'components-by-name) 1175 (values (gethash name (module-components-by-name module))))) 1269 (unless (slot-boundp module 'components-by-name) ;; SBCL may miss the u-i-f-r-c method!!! 1270 (compute-module-components-by-name module)) 1271 (values (gethash name (module-components-by-name module)))) 1176 1272 1177 1273 (defmethod find-component ((component component) (name symbol)) … … 1603 1699 flag)) 1604 1700 1605 (defmethod traverse ((operation operation) (c component))1606 ;; cerror'ing a feature that seems to have NEVER EVER worked1607 ;; ever since danb created it in his 2003-03-16 commit e0d02781.1608 ;; It was both fixed and disabled in the 1.700 rewrite.1609 (when (consp (operation-forced operation))1610 (cerror "Continue nonetheless."1611 "Congratulations, you're the first ever user of the :force (list of system names) feature! Please contact the asdf-devel mailing-list to collect a cookie.")1612 (setf (operation-forced operation)1613 (mapcar #'coerce-name (operation-forced operation))))1614 (flatten-tree1615 (while-collecting (collect)1616 (do-traverse operation c #'collect))))1617 1618 1701 (defun flatten-tree (l) 1619 1702 ;; You collected things into a list. … … 1632 1715 (r* l)))) 1633 1716 1717 (defmethod traverse ((operation operation) (c component)) 1718 ;; cerror'ing a feature that seems to have NEVER EVER worked 1719 ;; ever since danb created it in his 2003-03-16 commit e0d02781. 1720 ;; It was both fixed and disabled in the 1.700 rewrite. 1721 (when (consp (operation-forced operation)) 1722 (cerror "Continue nonetheless." 1723 "Congratulations, you're the first ever user of the :force (list of system names) feature! Please contact the asdf-devel mailing-list to collect a cookie.") 1724 (setf (operation-forced operation) 1725 (mapcar #'coerce-name (operation-forced operation)))) 1726 (flatten-tree 1727 (while-collecting (collect) 1728 (do-traverse operation c #'collect)))) 1729 1634 1730 (defmethod perform ((operation operation) (c source-file)) 1635 1731 (sysdef-error … … 1673 1769 (get-universal-time))) 1674 1770 1771 (declaim (ftype (function ((or pathname string) &rest t &key &allow-other-keys) 1772 (values t t t)) 1773 compile-file*)) 1774 1675 1775 ;;; perform is required to check output-files to find out where to put 1676 1776 ;;; its answers, in case it has been overridden for site policy … … 1678 1778 #-:broken-fasl-loader 1679 1779 (let ((source-file (component-pathname c)) 1680 (output-file (car (output-files operation c)))) 1780 (output-file (car (output-files operation c))) 1781 (*compile-file-warnings-behaviour* (operation-on-warnings operation)) 1782 (*compile-file-failure-behaviour* (operation-on-failure operation))) 1681 1783 (multiple-value-bind (output warnings-p failure-p) 1682 (apply #'compile-file source-file :output-file output-file1784 (apply #'compile-file* source-file :output-file output-file 1683 1785 (compile-op-flags operation)) 1684 1786 (when warnings-p … … 1856 1958 ;;;; Invoking Operations 1857 1959 1858 (defgeneric operate (operation-class system &key &allow-other-keys))1960 (defgeneric* operate (operation-class system &key &allow-other-keys)) 1859 1961 1860 1962 (defmethod operate (operation-class system &rest args … … 1904 2006 "Operate does three things: 1905 2007 1906 1. It creates an instance of `operation-class`using any keyword parameters2008 1. It creates an instance of OPERATION-CLASS using any keyword parameters 1907 2009 as initargs. 1908 2. It finds the asdf-system specified by `system`(possibly loading2010 2. It finds the asdf-system specified by SYSTEM (possibly loading 1909 2011 it from disk). 1910 3. It then calls `traverse`with the operation and system as arguments1911 1912 The traverse operation is wrapped in `with-compilation-unit`and error1913 handling code. If a `version`argument is supplied, then operate also1914 ensures that the system found satisfies it using the `version-satisfies`2012 3. It then calls TRAVERSE with the operation and system as arguments 2013 2014 The traverse operation is wrapped in WITH-COMPILATION-UNIT and error 2015 handling code. If a VERSION argument is supplied, then operate also 2016 ensures that the system found satisfies it using the VERSION-SATISFIES 1915 2017 method. 1916 2018 … … 1950 2052 ;;;; Defsystem 1951 2053 2054 (defun load-pathname () 2055 (let ((pn (or *load-pathname* *compile-file-pathname*))) 2056 (if *resolve-symlinks* 2057 (and pn (resolve-symlinks pn)) 2058 pn))) 2059 1952 2060 (defun determine-system-pathname (pathname pathname-supplied-p) 1953 ;; called from the defsystem macro.1954 ;; the pathname of a system is either2061 ;; The defsystem macro calls us to determine 2062 ;; the pathname of a system as follows: 1955 2063 ;; 1. the one supplied, 1956 ;; 2. derived from the *load-truename* (see below), or 1957 ;; 3. taken from *default-pathname-defaults* 1958 ;; 1959 ;; if using *load-truename*, then we also deal with whether or not 1960 ;; to resolve symbolic links. If not resolving symlinks, then we use 1961 ;; *load-pathname* instead of *load-truename* since in some 1962 ;; implementations, the latter has *already resolved it. 1963 (let ((file-pathname 1964 (when (or *load-pathname* *compile-file-pathname*) 1965 (pathname-directory-pathname 1966 (if *resolve-symlinks* 1967 (resolve-symlinks (or *load-truename* *compile-file-truename*)) 1968 *load-pathname*))))) 1969 (or (and pathname-supplied-p (merge-pathnames* pathname file-pathname)) 2064 ;; 2. derived from *load-pathname* via load-pathname 2065 ;; 3. taken from the *default-pathname-defaults* via default-directory 2066 (let* ((file-pathname (load-pathname)) 2067 (directory-pathname (and file-pathname (pathname-directory-pathname file-pathname)))) 2068 (or (and pathname-supplied-p (merge-pathnames* pathname directory-pathname)) 1970 2069 file-pathname 1971 ( current-directory))))2070 (default-directory)))) 1972 2071 1973 2072 (defmacro defsystem (name &body options) … … 1990 2089 (register-system (quote ,name) 1991 2090 (make-instance ',class :name ',name)))) 1992 (%set-system-source-file *load-truename*2091 (%set-system-source-file (load-pathname) 1993 2092 (cdr (system-registered-p ',name)))) 1994 2093 (parse-component-form … … 1999 2098 ',component-options)))))) 2000 2099 2001 2002 2100 (defun class-for-type (parent type) 2003 (let* ((extra-symbols (list (find-symbol (symbol-name type) *package*) 2004 (find-symbol (symbol-name type) 2005 (load-time-value 2006 (package-name :asdf))))) 2007 (class (dolist (symbol (if (keywordp type) 2008 extra-symbols 2009 (cons type extra-symbols))) 2010 (when (and symbol 2011 (find-class symbol nil) 2012 (subtypep symbol 'component)) 2013 (return (find-class symbol)))))) 2014 (or class 2015 (and (eq type :file) 2016 (or (module-default-component-class parent) 2017 (find-class 'cl-source-file))) 2018 (sysdef-error "~@<don't recognize component type ~A~@:>" type)))) 2101 (or (loop :for symbol :in (list 2102 (unless (keywordp type) type) 2103 (find-symbol (symbol-name type) *package*) 2104 (find-symbol (symbol-name type) :asdf)) 2105 :for class = (and symbol (find-class symbol nil)) 2106 :when (and class (subtypep class 'component)) 2107 :return class) 2108 (and (eq type :file) 2109 (or (module-default-component-class parent) 2110 (find-class *default-component-class*))) 2111 (sysdef-error "~@<don't recognize component type ~A~@:>" type))) 2019 2112 2020 2113 (defun maybe-add-tree (tree op1 op2 c) … … 2179 2272 2180 2273 (defun run-shell-command (control-string &rest args) 2181 "Interpolate `args` into `control-string` as if by `format`, and2274 "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and 2182 2275 synchronously execute the result using a Bourne-compatible shell, with 2183 output to `*verbose-out*`. Returns the shell's exit code."2276 output to *VERBOSE-OUT*. Returns the shell's exit code." 2184 2277 (let ((command (apply #'format nil control-string args))) 2185 2278 (asdf-message "; $ ~A~%" command) … … 2334 2427 ;; #+sbcl (format nil "~a-fasl~d" s sb-fasl:+fasl-file-version+) ; fasl-f-v is redundant 2335 2428 #+armedbear (format nil "~a-fasl~a" s system::*fasl-version*) 2336 #+(or mcl sbcl scl) s2429 #+(or cormanlisp mcl sbcl scl) s 2337 2430 #-(or allegro armedbear clisp clozure cmu cormanlisp digitool 2338 2431 ecl gcl lispworks mcl sbcl scl) s)) … … 2454 2547 (funcall validator (car forms)))) 2455 2548 2549 (defun hidden-file-p (pathname) 2550 (equal (first-char (pathname-name pathname)) #\.)) 2551 2456 2552 (defun validate-configuration-directory (directory tag validator) 2457 2553 (let ((files (sort (ignore-errors 2458 (directory (make-pathname :name :wild :type :wild :defaults directory) 2459 #+sbcl :resolve-symlinks #+sbcl nil)) 2554 (remove-if 2555 'hidden-file-p 2556 (directory (make-pathname :name :wild :type "conf" :defaults directory) 2557 #+sbcl :resolve-symlinks #+sbcl nil))) 2460 2558 #'string< :key #'namestring))) 2461 2559 `(,tag … … 2514 2612 (values)) 2515 2613 2516 (defparameter *wild-path*2517 (make-pathname :directory '(:relative :wild-inferiors)2518 :name :wild :type :wild :version :wild))2519 2520 2614 (defparameter *wild-asd* 2521 2615 (make-pathname :directory '(:relative :wild-inferiors) 2522 2616 :name :wild :type "asd" :version :newest)) 2523 2617 2524 (defun wilden (path) 2525 (merge-pathnames* *wild-path* path)) 2618 2619 (declaim (ftype (function (t &optional boolean) (or null pathname)) 2620 resolve-location)) 2621 2622 (defun resolve-relative-location-component (super x &optional wildenp) 2623 (let* ((r (etypecase x 2624 (pathname x) 2625 (string x) 2626 (cons 2627 (let ((car (resolve-relative-location-component super (car x) nil))) 2628 (if (null (cdr x)) 2629 car 2630 (let ((cdr (resolve-relative-location-component 2631 (merge-pathnames* car super) (cdr x) wildenp))) 2632 (merge-pathnames* cdr car))))) 2633 ((eql :default-directory) 2634 (relativize-pathname-directory (default-directory))) 2635 ((eql :implementation) (implementation-identifier)) 2636 ((eql :implementation-type) (string-downcase (implementation-type))) 2637 #-(and (or win32 windows mswindows mingw32) (not cygwin)) 2638 ((eql :uid) (princ-to-string (get-uid))))) 2639 (d (if (pathnamep x) r (ensure-directory-pathname r))) 2640 (s (if (and wildenp (not (pathnamep x))) 2641 (wilden d) 2642 d))) 2643 (when (and (absolute-pathname-p s) (not (pathname-match-p s (wilden super)))) 2644 (error "pathname ~S is not relative to ~S" s super)) 2645 (merge-pathnames* s super))) 2526 2646 2527 2647 (defun resolve-absolute-location-component (x wildenp) … … 2545 2665 ((eql :user-cache) (resolve-location *user-cache* nil)) 2546 2666 ((eql :system-cache) (resolve-location *system-cache* nil)) 2547 ((eql : current-directory) (current-directory))))2667 ((eql :default-directory) (default-directory)))) 2548 2668 (s (if (and wildenp (not (pathnamep x))) 2549 2669 (wilden r) … … 2552 2672 (error "Not an absolute pathname ~S" s)) 2553 2673 s)) 2554 2555 (defun resolve-relative-location-component (super x &optional wildenp)2556 (let* ((r (etypecase x2557 (pathname x)2558 (string x)2559 (cons2560 (let ((car (resolve-relative-location-component super (car x) nil)))2561 (if (null (cdr x))2562 car2563 (let ((cdr (resolve-relative-location-component2564 (merge-pathnames* car super) (cdr x) wildenp)))2565 (merge-pathnames* cdr car)))))2566 ((eql :current-directory)2567 (relativize-pathname-directory (current-directory)))2568 ((eql :implementation) (implementation-identifier))2569 ((eql :implementation-type) (string-downcase (implementation-type)))2570 ((eql :uid) (princ-to-string (get-uid)))))2571 (d (if (pathnamep x) r (ensure-directory-pathname r)))2572 (s (if (and wildenp (not (pathnamep x)))2573 (wilden d)2574 d)))2575 (when (and (absolute-pathname-p s) (not (pathname-match-p s (wilden super))))2576 (error "pathname ~S is not relative to ~S" s super))2577 (merge-pathnames* s super)))2578 2674 2579 2675 (defun resolve-location (x &optional wildenp) … … 2682 2778 ;; so we must disable translations for implementation paths. 2683 2779 #+sbcl (,(getenv "SBCL_HOME") ()) 2684 #+ecl (,(translate-logical-pathname "SYS:**;*.*") ()) ; only needed if LPNs are resolved manually.2685 #+clozure (,(wilden ( ccl::ccl-directory)) ()) ; not needed: no precompiled ASDF system2780 #+ecl (,(translate-logical-pathname "SYS:**;*.*") ()) ; not needed: no precompiled ASDF system 2781 #+clozure (,(wilden (truename #p"ccl:")) ()) ; not needed: no precompiled ASDF system 2686 2782 ;; All-import, here is where we want user stuff to be: 2687 2783 :inherit-configuration … … 2707 2803 2708 2804 (defgeneric process-output-translations (spec &key inherit collect)) 2805 (declaim (ftype (function (t &key (:collect (or symbol function))) t) 2806 inherit-output-translations)) 2807 (declaim (ftype (function (t &key (:collect (or symbol function)) (:inherit list)) t) 2808 process-output-translations-directive)) 2809 2709 2810 (defmethod process-output-translations ((x symbol) &key 2710 2811 (inherit *default-output-translations*) … … 2834 2935 :finally (return p))))) 2835 2936 2836 (defun last-char (s)2837 (and (stringp s) (plusp (length s)) (char s (1- (length s)))))2838 2839 (defun directorize-pathname-host-device (pathname)2840 (let* ((root (pathname-root pathname))2841 (wild-root (wilden root))2842 (absolute-pathname (merge-pathnames* pathname root))2843 (foo (make-pathname :directory '(:absolute "FOO") :defaults root))2844 (separator (last-char (namestring foo)))2845 (root-namestring (namestring root))2846 (root-string2847 (substitute-if #\/2848 (lambda (x) (or (eql x #\:)2849 (eql x separator)))2850 root-namestring)))2851 (multiple-value-bind (relative path filename)2852 (component-name-to-pathname-components root-string t)2853 (declare (ignore relative filename))2854 (let ((new-base2855 (make-pathname :defaults root2856 :directory `(:absolute ,@path))))2857 (translate-pathname absolute-pathname wild-root (wilden new-base))))))2858 2859 2937 (defmethod output-files :around (operation component) 2860 2938 "Translate output files, unless asked not to" … … 2867 2945 t)) 2868 2946 2869 (defun compile-file-pathname* (input-file &rest keys) 2870 (apply-output-translations 2871 (apply #'compile-file-pathname 2872 (truenamize (lispize-pathname input-file)) 2873 keys))) 2947 (defun compile-file-pathname* (input-file &rest keys &key output-file &allow-other-keys) 2948 (or output-file 2949 (apply-output-translations 2950 (apply 'compile-file-pathname 2951 (truenamize (lispize-pathname input-file)) 2952 keys)))) 2953 2954 (defun tmpize-pathname (x) 2955 (make-pathname 2956 :name (format nil "ASDF-TMP-~A" (pathname-name x)) 2957 :defaults x)) 2958 2959 (defun delete-file-if-exists (x) 2960 (when (probe-file x) 2961 (delete-file x))) 2962 2963 (defun compile-file* (input-file &rest keys &key &allow-other-keys) 2964 (let* ((output-file (apply 'compile-file-pathname* input-file keys)) 2965 (tmp-file (tmpize-pathname output-file)) 2966 (status :error)) 2967 (multiple-value-bind (output-truename warnings-p failure-p) 2968 (apply 'compile-file input-file :output-file tmp-file keys) 2969 (cond 2970 (failure-p 2971 (setf status *compile-file-failure-behaviour*)) 2972 (warnings-p 2973 (setf status *compile-file-warnings-behaviour*)) 2974 (t 2975 (setf status :success))) 2976 (ecase status 2977 ((:success :warn :ignore) 2978 (delete-file-if-exists output-file) 2979 (when output-truename 2980 (rename-file output-truename output-file) 2981 (setf output-truename output-file))) 2982 (:error 2983 (delete-file-if-exists output-truename) 2984 (setf output-truename nil))) 2985 (values output-truename warnings-p failure-p)))) 2874 2986 2875 2987 #+abcl … … 2999 3111 3000 3112 ;; Using ack 1.2 exclusions 3001 (defvar *default- exclusions*3113 (defvar *default-source-registry-exclusions* 3002 3114 '(".bzr" ".cdv" "~.dep" "~.dot" "~.nib" "~.plst" 3003 3115 ".git" ".hg" ".pc" ".svn" "CVS" "RCS" "SCCS" "_darcs" 3004 3116 "_sgbak" "autom4te.cache" "cover_db" "_build")) 3117 3118 (defvar *source-registry-exclusions* *default-source-registry-exclusions*) 3005 3119 3006 3120 (defvar *source-registry* () … … 3024 3138 (setf *source-registry* '()) 3025 3139 (values)) 3026 3027 (defun probe-asd (name defaults)3028 (block nil3029 (when (directory-pathname-p defaults)3030 (let ((file3031 (make-pathname3032 :defaults defaults :version :newest :case :local3033 :name name3034 :type "asd")))3035 (when (probe-file file)3036 (return file)))3037 #+(and (or win32 windows mswindows mingw32) (not cygwin) (not clisp))3038 (let ((shortcut3039 (make-pathname3040 :defaults defaults :version :newest :case :local3041 :name (concatenate 'string name ".asd")3042 :type "lnk")))3043 (when (probe-file shortcut)3044 (let ((target (parse-windows-shortcut shortcut)))3045 (when target3046 (return (pathname target)))))))))3047 3048 (defun sysdef-source-registry-search (system)3049 (ensure-source-registry)3050 (loop :with name = (coerce-name system)3051 :for defaults :in (source-registry)3052 :for file = (probe-asd name defaults)3053 :when file :return file))3054 3140 3055 3141 (defun validate-source-registry-directive (directive) … … 3061 3147 (and (length=n-p rest 1) 3062 3148 (typep (car rest) '(or pathname string null)))) 3063 ((:exclude )3149 ((:exclude :also-exclude) 3064 3150 (every #'stringp rest)) 3065 3151 (null rest)))) … … 3147 3233 `(:source-registry 3148 3234 #+sbcl (:tree ,(getenv "SBCL_HOME")) 3149 :inherit-configuration)) 3235 :inherit-configuration 3236 #+cmu (:tree #p"modules:"))) 3150 3237 (defun default-source-registry () 3151 3238 (flet ((try (x sub) (try-directory-subpath x sub :type :directory))) … … 3186 3273 3187 3274 (defgeneric process-source-registry (spec &key inherit register)) 3275 (declaim (ftype (function (t &key (:register (or symbol function))) t) 3276 inherit-source-registry)) 3277 (declaim (ftype (function (t &key (:register (or symbol function)) (:inherit list)) t) 3278 process-source-registry-directive)) 3279 3188 3280 (defmethod process-source-registry ((x symbol) &key inherit register) 3189 3281 (process-source-registry (funcall x) :inherit inherit :register register)) … … 3205 3297 (inherit-source-registry inherit :register register)) 3206 3298 (defmethod process-source-registry ((form cons) &key inherit register) 3207 (let ((* default-exclusions* *default-exclusions*))3299 (let ((*source-registry-exclusions* *default-source-registry-exclusions*)) 3208 3300 (dolist (directive (cdr (validate-source-registry-form form))) 3209 3301 (process-source-registry-directive directive :inherit inherit :register register)))) … … 3226 3318 (destructuring-bind (pathname) rest 3227 3319 (when pathname 3228 (funcall register (ensure-directory-pathname pathname) :recurse t :exclude * default-exclusions*))))3320 (funcall register (ensure-directory-pathname pathname) :recurse t :exclude *source-registry-exclusions*)))) 3229 3321 ((:exclude) 3230 (setf *default-exclusions* rest)) 3322 (setf *source-registry-exclusions* rest)) 3323 ((:also-exclude) 3324 (appendf *source-registry-exclusions* rest)) 3231 3325 ((:default-registry) 3232 3326 (inherit-source-registry '(default-source-registry) :register register)) … … 3234 3328 (inherit-source-registry inherit :register register)) 3235 3329 ((:ignore-inherited-configuration) 3236 nil)))) 3330 nil))) 3331 nil) 3237 3332 3238 3333 (defun flatten-source-registry (&optional parameter) … … 3269 3364 (initialize-source-registry))) 3270 3365 3366 (defun sysdef-source-registry-search (system) 3367 (ensure-source-registry) 3368 (loop :with name = (coerce-name system) 3369 :for defaults :in (source-registry) 3370 :for file = (probe-asd name defaults) 3371 :when file :return file)) 3372 3271 3373 ;;;; ----------------------------------------------------------------- 3272 3374 ;;;; Hook into REQUIRE for ABCL, ClozureCL, CMUCL, ECL and SBCL … … 3279 3381 (missing-component (constantly nil)) 3280 3382 (error (lambda (e) 3281 (format *error-output* "ASDF could not load ~ Abecause ~A.~%"3383 (format *error-output* "ASDF could not load ~(~A~) because ~A.~%" 3282 3384 name e)))) 3283 3385 (let* ((*verbose-out* (make-broadcast-stream)) 3284 (system (find-system namenil)))3386 (system (find-system (string-downcase name) nil))) 3285 3387 (when system 3286 (load-system name)3388 (load-system system) 3287 3389 t)))) 3288 3390 (pushnew 'module-provide-asdf 3289 3391 #+abcl sys::*module-provider-functions* 3290 #+clozure ccl: :*module-provider-functions*3392 #+clozure ccl:*module-provider-functions* 3291 3393 #+cmu ext:*module-provider-functions* 3292 3394 #+ecl si:*module-provider-functions* … … 3313 3415 ;;;; Done! 3314 3416 (when *load-verbose* 3315 (asdf-message ";; ASDF, version ~a " (asdf-version)))3417 (asdf-message ";; ASDF, version ~a~%" (asdf-version))) 3316 3418 3317 3419 #+allegro … … 3321 3423 3322 3424 (pushnew :asdf *features*) 3323 ;; this is a release candidate for ASDF 2.03324 3425 (pushnew :asdf2 *features*) 3325 3426
Note: See TracChangeset
for help on using the changeset viewer.