Changeset 14920
- Timestamp:
- Jul 28, 2011, 1:12:21 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/source/tools/asdf.lisp (modified) (47 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/tools/asdf.lisp
r14818 r14920 1 1 ;;; -*- mode: common-lisp; Base: 10 ; Syntax: ANSI-Common-Lisp -*- 2 ;;; This is ASDF 2.01 6: Another System Definition Facility.2 ;;; This is ASDF 2.017: Another System Definition Facility. 3 3 ;;; 4 4 ;;; Feedback, bug reports, and patches are all welcome: … … 51 51 52 52 #-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl genera lispworks mcl sbcl scl xcl) 53 (error "ASDF is not supported on your implementation. Please help us withit.")53 (error "ASDF is not supported on your implementation. Please help us port it.") 54 54 55 55 #+gcl (defpackage :asdf (:use :cl)) ;; GCL treats defpackage magically and needs this … … 63 63 :test 'equalp :key 'car)) ; need that BEFORE any mention of package ASDF as below 64 64 #+(and ecl (not ecl-bytecmp)) (require :cmp) 65 #+gcl ;; Debian's GCL 2.7 has bugs with compiling multiple-value stuff, but can run ASDF 2.011 66 (when (or (< system::*gcl-major-version* 2) ;; GCL 2.6 fails to fully compile ASDF at all 67 (and (= system::*gcl-major-version* 2) 68 (< system::*gcl-minor-version* 7))) 69 (pushnew :gcl-pre2.7 *features*)) 65 70 #+(and (or win32 windows mswindows mingw32) (not cygwin)) (pushnew :asdf-windows *features*) 66 71 #+(or unix cygwin) (pushnew :asdf-unix *features*) … … 85 90 ;; Has to be inside the eval-when to make Lispworks happy (!) 86 91 (defmacro compatfmt (format) 87 #- generaformat88 #+ genera92 #-(or gcl genera) format 93 #+(or gcl genera) 89 94 (loop :for (unsupported . replacement) :in 90 '(("~@<" . "") 91 ("; ~@;" . "; ") 92 ("~3i~_" . "") 93 ("~@:>" . "") 94 ("~:>" . "")) :do 95 `(("~3i~_" . "") 96 #+genera 97 ,@(("~@<" . "") 98 ("; ~@;" . "; ") 99 ("~@:>" . "") 100 ("~:>" . ""))) :do 95 101 (loop :for found = (search unsupported format) :while found :do 96 102 (setf format … … 107 113 ;; "2.345.0.7" would be your seventh local modification of official release 2.345 108 114 ;; "2.345.6.7" would be your seventh local modification of development version 2.345.6 109 (asdf-version "2.01 6")115 (asdf-version "2.017") 110 116 (existing-asdf (find-class 'component nil)) 111 117 (existing-version *asdf-version*) … … 195 201 (loop :for x :in newly-exported-symbols :do 196 202 (export (intern* x package))))) 197 (ensure-package (name &key nicknames use unintern fmakunbound shadow export) 203 (ensure-package (name &key nicknames use unintern fmakunbound 204 shadow export redefined-functions) 198 205 (let* ((p (ensure-exists name nicknames use))) 199 206 (ensure-unintern p unintern) 200 207 (ensure-shadow p shadow) 201 208 (ensure-export p export) 202 (ensure-fmakunbound p fmakunbound)209 (ensure-fmakunbound p (append fmakunbound redefined-functions)) 203 210 p))) 204 211 (macrolet … … 208 215 ',name :nicknames ',nicknames :use ',use :export ',export 209 216 :shadow ',shadow 210 :unintern ',(append #-(or gcl ecl) redefined-functions unintern) 211 :fmakunbound ',(append fmakunbound)))) 217 :unintern ',unintern 218 :redefined-functions ',redefined-functions 219 :fmakunbound ',fmakunbound))) 212 220 (pkgdcl 213 221 :asdf … … 343 351 #:ensure-directory-pathname 344 352 #:getenv 345 ;; #:get-uid346 353 ;; #:length=n-p 347 354 ;; #:find-symbol* … … 368 375 ;;;; User-visible parameters 369 376 ;;;; 370 (defun asdf-version ()371 "Exported interface to the version of ASDF currently installed. A string.372 You can compare this string with e.g.:373 (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSION) \"2.345.67\")."374 *asdf-version*)375 376 377 (defvar *resolve-symlinks* t 377 378 "Determine whether or not ASDF resolves symlinks when defining systems. … … 416 417 condition-format condition-location 417 418 coerce-name) 418 #- cormanlisp419 #-(or cormanlisp gcl-pre2.7) 419 420 (ftype (function (t t) t) (setf module-components-by-name))) 420 421 421 422 ;;;; ------------------------------------------------------------------------- 422 ;;;; Compatibility with Corman Lisp423 ;;;; Compatibility various implementations 423 424 #+cormanlisp 424 425 (progn 425 426 (deftype logical-pathname () nil) 426 (defun make-broadcast-stream () *error-output*)427 (defun file-namestring (p)427 (defun* make-broadcast-stream () *error-output*) 428 (defun* file-namestring (p) 428 429 (setf p (pathname p)) 429 (format nil "~@[~A~]~@[.~A~]" (pathname-name p) (pathname-type p))) 430 (defparameter *count* 3) 431 (defun dbg (&rest x) 432 (format *error-output* "~S~%" x))) 433 #+cormanlisp 434 (defun maybe-break () 435 (decf *count*) 436 (unless (plusp *count*) 437 (setf *count* 3) 438 (break))) 430 (format nil "~@[~A~]~@[.~A~]" (pathname-name p) (pathname-type p)))) 431 432 #.(or #+mcl ;; the #$ doesn't work on other lisps, even protected by #+mcl 433 (read-from-string 434 "(eval-when (:compile-toplevel :load-toplevel :execute) 435 (ccl:define-entry-point (_getenv \"getenv\") ((name :string)) :string) 436 (ccl:define-entry-point (_system \"system\") ((name :string)) :int) 437 ;; Note: ASDF may expect user-homedir-pathname to provide 438 ;; the pathname of the current user's home directory, whereas 439 ;; MCL by default provides the directory from which MCL was started. 440 ;; See http://code.google.com/p/mcl/wiki/Portability 441 (defun current-user-homedir-pathname () 442 (ccl::findfolder #$kuserdomain #$kCurrentUserFolderType)) 443 (defun probe-posix (posix-namestring) 444 \"If a file exists for the posix namestring, return the pathname\" 445 (ccl::with-cstrs ((cpath posix-namestring)) 446 (ccl::rlet ((is-dir :boolean) 447 (fsref :fsref)) 448 (when (eq #$noerr (#_fspathmakeref cpath fsref is-dir)) 449 (ccl::%path-from-fsref fsref is-dir))))))")) 439 450 440 451 ;;;; ------------------------------------------------------------------------- … … 445 456 `(defmacro ,def* (name formals &rest rest) 446 457 `(progn 447 #+(or ecl gcl) (fmakunbound ',name)458 #+(or ecl (and gcl (not gcl-pre2.7))) (fmakunbound ',name) 448 459 #-gcl ; gcl 2.7.0 notinline functions lose secondary return values :-( 449 460 ,(when (and #+ecl (symbolp name)) ; fails for setf functions on ecl … … 516 527 517 528 (defun* merge-pathnames* (specified &optional (defaults *default-pathname-defaults*)) 518 "MERGE-PATHNAMES* is like MERGE-PATHNAMES except that if the SPECIFIED pathname 519 does not have an absolute directory, then the HOST and DEVICE come from the DEFAULTS. 529 "MERGE-PATHNAMES* is like MERGE-PATHNAMES except that 530 if the SPECIFIED pathname does not have an absolute directory, 531 then the HOST and DEVICE both come from the DEFAULTS, whereas 532 if the SPECIFIED pathname does have an absolute directory, 533 then the HOST and DEVICE both come from the SPECIFIED. 520 534 Also, if either argument is NIL, then the other argument is returned unmodified." 521 535 (when (null specified) (return-from merge-pathnames* defaults)) … … 560 574 :defaults pathname))) 561 575 562 563 576 (define-modify-macro appendf (&rest args) 564 577 append "Append onto list") ;; only to be used on short lists. … … 660 673 :unless (eq k key) 661 674 :append (list k v))) 662 663 #+mcl664 (eval-when (:compile-toplevel :load-toplevel :execute)665 (ccl:define-entry-point (_getenv "getenv") ((name :string)) :string))666 675 667 676 (defun* getenv (x) … … 731 740 #+genera 732 741 (unless (fboundp 'ensure-directories-exist) 733 (defun ensure-directories-exist (path)742 (defun* ensure-directories-exist (path) 734 743 (fs:create-directories-recursively (pathname path)))) 735 744 … … 761 770 :collect form))) 762 771 763 #+asdf-unix764 (progn765 #+ecl #.(cl:and (cl:< ext:+ecl-version-number+ 100601)766 '(ffi:clines "#include <sys/types.h>" "#include <unistd.h>"))767 (defun* get-uid ()768 #+allegro (excl.osi:getuid)769 #+ccl (ccl::getuid)770 #+clisp (loop :for s :in '("posix:uid" "LINUX:getuid")771 :for f = (ignore-errors (read-from-string s))772 :when f :return (funcall f))773 #+(or cmu scl) (unix:unix-getuid)774 #+ecl #.(cl:if (cl:< ext:+ecl-version-number+ 100601)775 '(ffi:c-inline () () :int "getuid()" :one-liner t)776 '(ext::getuid))777 #+sbcl (sb-unix:unix-getuid)778 #-(or allegro ccl clisp cmu ecl sbcl scl)779 (let ((uid-string780 (with-output-to-string (*verbose-out*)781 (run-shell-command "id -ur"))))782 (with-input-from-string (stream uid-string)783 (read-line stream)784 (handler-case (parse-integer (read-line stream))785 (error () (error "Unable to find out user ID")))))))786 787 772 (defun* pathname-root (pathname) 788 773 (make-pathname :directory '(:absolute) … … 799 784 (string (probe-file* (parse-namestring p))) 800 785 (pathname (unless (wild-pathname-p p) 801 #.(or #+(or allegro clozure cmu cormanlisp ecl sbcl scl) '(probe-file p) 786 #.(or #+(or allegro clozure cmu cormanlisp ecl lispworks sbcl scl) 787 '(probe-file p) 802 788 #+clisp (aif (find-symbol* '#:probe-pathname :ext) 803 789 `(ignore-errors (,it p))) 804 790 '(ignore-errors (truename p))))))) 805 791 806 (defun* truenamize (p )792 (defun* truenamize (pathname &optional (defaults *default-pathname-defaults*)) 807 793 "Resolve as much of a pathname as possible" 808 794 (block nil 809 (when (typep p '(or null logical-pathname)) (return p)) 810 (let* ((p (merge-pathnames* p)) 811 (directory (pathname-directory p))) 795 (when (typep pathname '(or null logical-pathname)) (return pathname)) 796 (let ((p (merge-pathnames* pathname defaults))) 812 797 (when (typep p 'logical-pathname) (return p)) 813 798 (let ((found (probe-file* p))) 814 799 (when found (return found))) 815 #-(or cmu sbcl scl) (when (stringp directory) (return p)) 816 (when (not (eq :absolute (car directory))) (return p)) 800 (unless (absolute-pathname-p p) 801 (let ((true-defaults (ignore-errors (truename defaults)))) 802 (when true-defaults 803 (setf p (merge-pathnames pathname true-defaults))))) 804 (unless (absolute-pathname-p p) (return p)) 817 805 (let ((sofar (probe-file* (pathname-root p)))) 818 806 (unless sofar (return p)) … … 825 813 :version (pathname-version p)) 826 814 sofar))) 827 (loop :for component :in (cdr directory) 815 (loop :with directory = (normalize-pathname-directory-component 816 (pathname-directory p)) 817 :for component :in (cdr directory) 828 818 :for rest :on (cdr directory) 829 819 :for more = (probe-file* … … 848 838 path)) 849 839 850 (defun ensure-pathname-absolute (path)840 (defun* ensure-pathname-absolute (path) 851 841 (cond 852 842 ((absolute-pathname-p path) path) … … 878 868 879 869 #-scl 880 (defun directory-separator-for-host (&optional (pathname *default-pathname-defaults*))870 (defun* directory-separator-for-host (&optional (pathname *default-pathname-defaults*)) 881 871 (let ((foo (make-pathname :directory '(:absolute "FOO") :defaults pathname))) 882 872 (last-char (namestring foo)))) … … 962 952 (defgeneric* (setf component-property) (new-value component property)) 963 953 964 (eval-when ( :compile-toplevel :load-toplevel :execute)954 (eval-when (#-gcl :compile-toplevel :load-toplevel :execute) 965 955 (defgeneric* (setf module-components-by-name) (new-value module))) 966 956 … … 1271 1261 (let ((pathname 1272 1262 (merge-pathnames* 1273 (component-relative-pathname component)1274 (pathname-directory-pathname (component-parent-pathname component)))))1263 (component-relative-pathname component) 1264 (pathname-directory-pathname (component-parent-pathname component))))) 1275 1265 (unless (or (null pathname) (absolute-pathname-p pathname)) 1276 1266 (error (compatfmt "~@<Invalid relative pathname ~S for component ~S~@:>") … … 1313 1303 (version-satisfies (component-version c) version)) 1314 1304 1315 (defun parse-version (string &optional on-error) 1305 (defun* asdf-version () 1306 "Exported interface to the version of ASDF currently installed. A string. 1307 You can compare this string with e.g.: 1308 (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSION) \"2.345.67\")." 1309 *asdf-version*) 1310 1311 (defun* parse-version (string &optional on-error) 1316 1312 "Parse a version string as a series of natural integers separated by dots. 1317 1313 Return a (non-null) list of integers if the string is valid, NIL otherwise. … … 1428 1424 (block nil 1429 1425 (when (directory-pathname-p defaults) 1430 (let ((file 1431 (make-pathname 1432 :defaults defaults :version :newest :case :local 1433 :name name 1434 :type "asd"))) 1426 (let ((file (make-pathname 1427 :defaults defaults :name name 1428 :version :newest :case :local :type "asd"))) 1435 1429 (when (probe-file* file) 1436 1430 (return file))) … … 2114 2108 :initform nil))) 2115 2109 2116 (defun output-file (operation component)2110 (defun* output-file (operation component) 2117 2111 "The unique output file of performing OPERATION on COMPONENT" 2118 2112 (let ((files (output-files operation component))) … … 2145 2139 (*compile-file-failure-behaviour* (operation-on-failure operation))) 2146 2140 (multiple-value-bind (output warnings-p failure-p) 2147 (apply *compile-op-compile-file-function* source-file :output-file output-file2148 (compile-op-flags operation))2141 (apply *compile-op-compile-file-function* source-file 2142 :output-file output-file (compile-op-flags operation)) 2149 2143 (unless output 2150 2144 (error 'compile-error :component c :operation operation)) … … 2367 2361 (asdf-message (compatfmt "~&~@<; ~@;Changed ASDF from version ~A to incompatible version ~A~@:>~%") 2368 2362 version new-version))) 2369 (let ((asdf (f ind-system:asdf)))2363 (let ((asdf (funcall (find-symbol* 'find-system :asdf) :asdf))) 2370 2364 ;; invalidate all systems but ASDF itself 2371 2365 (setf *defined-systems* (make-defined-systems-table)) … … 2603 2597 perform explain output-files operation-done-p 2604 2598 weakly-depends-on 2605 depends-on serial in-order-to 2599 depends-on serial in-order-to do-first 2606 2600 (version nil versionp) 2607 2601 ;; list ends … … 2664 2658 `((compile-op (compile-op ,@depends-on)) 2665 2659 (load-op (load-op ,@depends-on))))) 2666 (setf (component-do-first ret) `((compile-op (load-op ,@depends-on)))) 2660 (setf (component-do-first ret) 2661 (union-of-dependencies 2662 do-first 2663 `((compile-op (load-op ,@depends-on))))) 2667 2664 2668 2665 (%refresh-component-inline-methods ret rest) … … 2748 2745 :wait t))) 2749 2746 2747 #+(or cmu scl) 2748 (ext:process-exit-code 2749 (ext:run-program 2750 "/bin/sh" 2751 (list "-c" command) 2752 :input nil :output *verbose-out*)) 2753 2750 2754 #+ecl ;; courtesy of Juan Jose Garcia Ripoll 2751 2755 (si:system command) … … 2762 2766 :output-stream *verbose-out*) 2763 2767 2768 #+mcl 2769 (ccl::with-cstrs ((%command command)) (_system %command)) 2770 2764 2771 #+sbcl 2765 2772 (sb-ext:process-exit-code … … 2770 2777 #+win32 '(:search t) #-win32 nil)) 2771 2778 2772 #+(or cmu scl)2773 (ext:process-exit-code2774 (ext:run-program2775 "/bin/sh"2776 (list "-c" command)2777 :input nil :output *verbose-out*))2778 2779 2779 #+xcl 2780 2780 (ext:run-shell-command command) 2781 2781 2782 #-(or abcl allegro clisp clozure cmu ecl gcl lispworks sbcl scl xcl)2782 #-(or abcl allegro clisp clozure cmu ecl gcl lispworks mcl sbcl scl xcl) 2783 2783 (error "RUN-SHELL-COMMAND not implemented for this Lisp"))) 2784 2784 … … 2808 2808 directory in which the system specification (.asd file) is 2809 2809 located." 2810 (make-pathname :name nil 2811 :type nil 2812 :defaults (system-source-file system-designator))) 2810 (pathname-directory-pathname (system-source-file system-designator))) 2813 2811 2814 2812 (defun* relativize-directory (directory) … … 2837 2835 ;;; 2838 2836 ;;; produce a string to identify current implementation. 2839 ;;; Initially stolen from SLIME's SWANK, hacked since. 2840 2841 (defparameter *implementation-features* 2842 '((:abcl :armedbear) 2843 (:acl :allegro) 2844 (:mcl :digitool) ; before clozure, so it won't get preempted by ccl 2845 (:ccl :clozure) 2846 (:corman :cormanlisp) 2847 (:lw :lispworks) 2848 :clisp :cmu :ecl :gcl :sbcl :scl :symbolics :xcl)) 2849 2850 (defparameter *os-features* 2851 '(:cygwin (:win :windows :mswindows :win32 :mingw32) ;; shorten things on windows 2852 (:solaris :sunos) 2853 (:linux :linux-target) ;; for GCL at least, must appear before :bsd. 2854 (:macosx :darwin :darwin-target :apple) 2855 :freebsd :netbsd :openbsd :bsd 2856 :unix 2857 :genera)) 2858 2859 (defparameter *architecture-features* 2860 '((:x64 :amd64 :x86-64 :x86_64 :x8664-target #+(and clisp word-size=64) :pc386) 2861 (:x86 :i386 :i486 :i586 :i686 :pentium3 :pentium4 :pc386 :iapx386 :x8632-target) 2862 :hppa64 :hppa 2863 (:ppc64 :ppc64-target) (:ppc32 :ppc32-target :ppc :powerpc) 2864 :sparc64 (:sparc32 :sparc) 2865 (:arm :arm-target) 2866 (:java :java-1.4 :java-1.5 :java-1.6 :java-1.7) 2867 :mipsel :mipseb :mips 2868 :alpha 2869 :imach)) 2870 2871 (defun* lisp-version-string () 2837 ;;; Initially stolen from SLIME's SWANK, rewritten since. 2838 ;;; The (car '(...)) idiom avoids unreachable code warnings. 2839 2840 (defparameter *implementation-type* 2841 (car '(#+abcl :abcl #+allegro :acl 2842 #+clozure :ccl #+clisp :clisp #+cormanlisp :corman #+cmu :cmu 2843 #+ecl :ecl #+gcl :gcl #+lispworks :lw #+mcl :mcl 2844 #+sbcl :sbcl #+scl :scl #+symbolics :symbolic #+xcl :xcl))) 2845 2846 (defparameter *operating-system* 2847 (car '(#+cygwin :cygwin #+(or windows mswindows win32 mingw32) :win 2848 #+(or linux linux-target) :linux ;; for GCL at least, must appear before :bsd. 2849 #+(or macosx darwin darwin-target apple) :macosx ; also before :bsd 2850 #+(or solaris sunos) :solaris 2851 #+(or freebsd netbsd openbsd bsd) :bsd 2852 #+unix :unix 2853 #+genera :genera))) 2854 2855 (defparameter *architecture* 2856 (car '(#+(or amd64 x86-64 x86_64 x8664-target (and word-size=64 pc386)) :x64 2857 #+(or x86 i386 i486 i586 i686 pentium3 pentium4 pc386 iapx386 x8632-target) :x86 2858 #+hppa64 :hppa64 #+hppa :hppa 2859 #+(or ppc64 ppc64-target) :ppc64 2860 #+(or ppc32 ppc32-target ppc powerpc) :ppc32 2861 #+sparc64 :sparc64 #+(or sparc32 sparc) :sparc32 2862 #+(or arm arm-target) :arm 2863 #+(or java java-1.4 java-1.5 java-1.6 java-1.7) :java 2864 #+mipsel :mispel #+mipseb :mipseb #+mips :mips 2865 #+alpha :alpha #+imach :imach))) 2866 2867 (defparameter *lisp-version-string* 2872 2868 (let ((s (lisp-implementation-version))) 2873 2869 (or 2874 #+allegro (format nil 2875 "~A~A~A" 2876 excl::*common-lisp-version-number* 2877 ;; ANSI vs MoDeRn - thanks to Robert Goldman and Charley Cox 2878 (if (eq excl:*current-case-mode* 2879 :case-sensitive-lower) "M" "A") 2880 ;; Note if not using International ACL 2881 ;; see http://www.franz.com/support/documentation/8.1/doc/operators/excl/ics-target-case.htm 2882 (excl:ics-target-case 2883 (:-ics "8") 2884 (:+ics ""))) ; redundant? (if (member :64bit *features*) "-64bit" "")) 2870 #+allegro 2871 (format nil "~A~A~@[~A~]" 2872 excl::*common-lisp-version-number* 2873 ;; ANSI vs MoDeRn - thanks to Robert Goldman and Charley Cox 2874 (if (eq excl:*current-case-mode* :case-sensitive-lower) "M" "A") 2875 ;; Note if not using International ACL 2876 ;; see http://www.franz.com/support/documentation/8.1/doc/operators/excl/ics-target-case.htm 2877 (excl:ics-target-case (:-ics "8"))) 2885 2878 #+armedbear (format nil "~a-fasl~a" s system::*fasl-version*) 2886 #+clisp (subseq s 0 (position #\space s)) ; strip build information (date, etc.) 2887 #+clozure (format nil "~d.~d-f~d" ; shorten for windows 2888 ccl::*openmcl-major-version* 2889 ccl::*openmcl-minor-version* 2890 (logand ccl::fasl-version #xFF)) 2879 #+clisp 2880 (subseq s 0 (position #\space s)) ; strip build information (date, etc.) 2881 #+clozure 2882 (format nil "~d.~d-f~d" ; shorten for windows 2883 ccl::*openmcl-major-version* 2884 ccl::*openmcl-minor-version* 2885 (logand ccl::fasl-version #xFF)) 2891 2886 #+cmu (substitute #\- #\/ s) 2892 2887 #+ecl (format nil "~A~@[-~A~]" s 2893 (let ((vcs-id (ext:lisp-implementation-vcs-id))) 2894 (when (>= (length vcs-id) 8) 2895 (subseq vcs-id 0 8)))) 2888 (let ((vcs-id (ext:lisp-implementation-vcs-id))) 2889 (subseq vcs-id 0 (min (length vcs-id) 8)))) 2896 2890 #+gcl (subseq s (1+ (position #\space s))) 2897 #+genera (multiple-value-bind (major minor) (sct:get-system-version "System")2898 (format nil "~D.~D" major minor))2899 ;; #+lispworks (format nil "~A~@[~A~]" s (when (member :lispworks-64bit *features*) "-64bit") #+mcl (subseq s 8) ; strip the leading "Version "2900 ;; #+sbcl (format nil "~a-fasl~d" s sb-fasl:+fasl-file-version+) ; f-f-v redundant w/ version2891 #+genera 2892 (multiple-value-bind (major minor) (sct:get-system-version "System") 2893 (format nil "~D.~D" major minor)) 2894 #+mcl (subseq s 8) ; strip the leading "Version " 2901 2895 s))) 2902 2896 2903 (defun* first-feature (features)2904 (labels2905 ((fp (thing)2906 (etypecase thing2907 (symbol2908 (let ((feature (find thing *features*)))2909 (when feature (return-from fp feature))))2910 ;; allows features to be lists of which the first2911 ;; member is the "main name", the rest being aliases2912 (cons2913 (dolist (subf thing)2914 (when (find subf *features*) (return-from fp (first thing))))))2915 nil))2916 (loop :for f :in features2917 :when (fp f) :return :it)))2918 2919 2897 (defun* implementation-type () 2920 (first-feature *implementation-features*))2898 *implementation-type*) 2921 2899 2922 2900 (defun* implementation-identifier () 2923 (labels 2924 ((maybe-warn (value fstring &rest args) 2925 (cond (value) 2926 (t (apply 'warn fstring args) 2927 "unknown")))) 2928 (let ((lisp (maybe-warn (implementation-type) 2929 (compatfmt "~@<No implementation feature found in ~a.~@:>") 2930 *implementation-features*)) 2931 (os (maybe-warn (first-feature *os-features*) 2932 (compatfmt "~@<No OS feature found in ~a.~@:>") *os-features*)) 2933 (arch (or #-clisp 2934 (maybe-warn (first-feature *architecture-features*) 2935 (compatfmt "~@<No architecture feature found in ~a.~@:>") 2936 *architecture-features*))) 2937 (version (maybe-warn (lisp-version-string) 2938 "Don't know how to get Lisp implementation version."))) 2939 (substitute-if 2940 #\_ #'(lambda (x) (find x " /:\\(){}[]$#`'\"")) 2941 (format nil "~(~a~@{~@[-~a~]~}~)" lisp version os arch))))) 2901 (substitute-if 2902 #\_ #'(lambda (x) (find x " /:;&^\\|?<>(){}[]$#`'\"")) 2903 (format nil "~(~a~@{~@[-~a~]~}~)" 2904 (or *implementation-type* (lisp-implementation-type)) 2905 (or *lisp-version-string* (lisp-implementation-version)) 2906 (or *operating-system* (software-type)) 2907 (or *architecture* (machine-type))))) 2942 2908 2943 2909 … … 2948 2914 #+asdf-unix #\: 2949 2915 #-asdf-unix #\;) 2950 2951 ;; Note: ASDF may expect user-homedir-pathname to provide the pathname of2952 ;; the current user's home directory, while MCL by default provides the2953 ;; directory from which MCL was started.2954 ;; See http://code.google.com/p/mcl/wiki/Portability2955 #.(or #+mcl ;; the #$ doesn't work on other implementations, even inside #+mcl2956 `(defun current-user-homedir-pathname ()2957 ,(read-from-string "(ccl::findfolder #$kuserdomain #$kCurrentUserFolderType))")))2958 2916 2959 2917 (defun* user-homedir () … … 3122 3080 "common-lisp" "cache" :implementation) 3123 3081 '(:home ".cache" "common-lisp" :implementation)))) 3124 (defvar *system-cache*3125 ;; No good default, plus there's a security problem3126 ;; with other users messing with such directories.3127 *user-cache*)3128 3082 3129 3083 (defun* output-translations () … … 3156 3110 resolve-location)) 3157 3111 3158 (defun* resolve-relative-location-component (super x &key directory wilden) 3159 (let* ((r (etypecase x 3160 (pathname x) 3161 (string x) 3162 (cons 3163 (return-from resolve-relative-location-component 3164 (if (null (cdr x)) 3112 (defun* resolve-relative-location-component (x &key directory wilden) 3113 (let ((r (etypecase x 3114 (pathname x) 3115 (string (coerce-pathname x :type (when directory :directory))) 3116 (cons 3117 (if (null (cdr x)) 3118 (resolve-relative-location-component 3119 (car x) :directory directory :wilden wilden) 3120 (let* ((car (resolve-relative-location-component 3121 (car x) :directory t :wilden nil))) 3122 (merge-pathnames* 3165 3123 (resolve-relative-location-component 3166 super (car x) :directory directory :wilden wilden) 3167 (let* ((car (resolve-relative-location-component 3168 super (car x) :directory t :wilden nil)) 3169 (cdr (resolve-relative-location-component 3170 (merge-pathnames* car super) (cdr x) 3171 :directory directory :wilden wilden))) 3172 (merge-pathnames* cdr car))))) 3173 ((eql :default-directory) 3174 (relativize-pathname-directory (default-directory))) 3175 ((eql :*/) *wild-directory*) 3176 ((eql :**/) *wild-inferiors*) 3177 ((eql :*.*.*) *wild-file*) 3178 ((eql :implementation) (implementation-identifier)) 3179 ((eql :implementation-type) (string-downcase (implementation-type))) 3180 #+asdf-unix 3181 ((eql :uid) (princ-to-string (get-uid))))) 3182 (d (if (or (pathnamep x) (not directory)) r (ensure-directory-pathname r))) 3183 (s (if (or (pathnamep x) (not wilden)) d (wilden d)))) 3184 (when (and (absolute-pathname-p s) (not (pathname-match-p s (wilden super)))) 3185 (error (compatfmt "~@<Pathname ~S is not relative to ~S~@:>") s super)) 3186 (merge-pathnames* s super))) 3124 (cdr x) :directory directory :wilden wilden) 3125 car)))) 3126 ((eql :default-directory) 3127 (relativize-pathname-directory (default-directory))) 3128 ((eql :*/) *wild-directory*) 3129 ((eql :**/) *wild-inferiors*) 3130 ((eql :*.*.*) *wild-file*) 3131 ((eql :implementation) 3132 (coerce-pathname (implementation-identifier) :type :directory)) 3133 ((eql :implementation-type) 3134 (coerce-pathname (string-downcase (implementation-type)) :type :directory))))) 3135 (when (absolute-pathname-p r) 3136 (error (compatfmt "~@<pathname ~S is not relative~@:>") x)) 3137 (if (or (pathnamep x) (not wilden)) r (wilden r)))) 3187 3138 3188 3139 (defvar *here-directory* nil … … 3195 3146 (etypecase x 3196 3147 (pathname x) 3197 (string (if directory (ensure-directory-pathname x) (parse-namestring x))) 3148 (string (let ((p (#+mcl probe-posix #-mcl parse-namestring x))) 3149 #+mcl (unless p (error "POSIX pathname ~S does not exist" x)) 3150 (if directory (ensure-directory-pathname p) p))) 3198 3151 (cons 3199 3152 (return-from resolve-absolute-location-component … … 3201 3154 (resolve-absolute-location-component 3202 3155 (car x) :directory directory :wilden wilden) 3203 ( let* ((car (resolve-absolute-location-component3204 (car x) :directory t :wilden nil))3205 (cdr (resolve-relative-location-component3206 car (cdr x) :directory directory :wilden wilden)))3207 ( merge-pathnames* cdr car))))) ; XXX why is this not just "cdr" ?3156 (merge-pathnames* 3157 (resolve-relative-location-component 3158 (cdr x) :directory directory :wilden wilden) 3159 (resolve-absolute-location-component 3160 (car x) :directory t :wilden nil))))) 3208 3161 ((eql :root) 3209 3162 ;; special magic! we encode such paths as relative pathnames, … … 3220 3173 ((eql :user-cache) (resolve-location *user-cache* :directory t :wilden nil)) 3221 3174 ((eql :system-cache) 3222 (warn "Using the :system-cache is deprecated. ~%~ 3223 Please remove it from your ASDF configuration") 3224 (resolve-location *system-cache* :directory t :wilden nil)) 3175 (error "Using the :system-cache is deprecated. ~%~ 3176 Please remove it from your ASDF configuration")) 3225 3177 ((eql :default-directory) (default-directory)))) 3226 3178 (s (if (and wilden (not (pathnamep x))) … … 3228 3180 r))) 3229 3181 (unless (absolute-pathname-p s) 3230 (error (compatfmt "~@< Not an absolute pathname: ~3i~_~S~@:>") s))3182 (error (compatfmt "~@<Invalid designator for an absolute pathname: ~3i~_~S~@:>") x)) 3231 3183 s)) 3232 3184 … … 3240 3192 :for dir = (and (or morep directory) t) 3241 3193 :for wild = (and wilden (not morep)) 3242 :do (setf path (resolve-relative-location-component 3243 path component :directory dir :wilden wild)) 3194 :do (setf path (merge-pathnames* 3195 (resolve-relative-location-component 3196 component :directory dir :wilden wild) 3197 path)) 3244 3198 :finally (return path)))) 3245 3199 … … 3524 3478 (defun* compile-file-pathname* (input-file &rest keys &key output-file &allow-other-keys) 3525 3479 (if (absolute-pathname-p output-file) 3526 (apply 'compile-file-pathname (lispize-pathname input-file) keys) 3480 ;; what cfp should be doing, w/ mp* instead of mp 3481 (let* ((type (pathname-type (apply 'compile-file-pathname "x.lisp" keys))) 3482 (defaults (make-pathname 3483 :type type :defaults (merge-pathnames* input-file)))) 3484 (merge-pathnames* output-file defaults)) 3527 3485 (apply-output-translations 3528 (apply 'compile-file-pathname 3529 (truenamize (lispize-pathname input-file)) 3530 keys)))) 3486 (apply 'compile-file-pathname input-file keys)))) 3531 3487 3532 3488 (defun* tmpize-pathname (x) … … 3729 3685 (make-pathname :directory nil :name *wild* :type "asd" :version :newest)) 3730 3686 3731 (defun directory-asd-files (directory) 3732 (ignore-errors 3733 (directory* (merge-pathnames* *wild-asd* directory)))) 3734 3735 (defun subdirectories (directory) 3687 (defun* filter-logical-directory-results (directory entries merger) 3688 (if (typep directory 'logical-pathname) 3689 ;; Try hard to not resolve logical-pathname into physical pathnames; 3690 ;; otherwise logical-pathname users/lovers will be disappointed. 3691 ;; If directory* could use some implementation-dependent magic, 3692 ;; we will have logical pathnames already; otherwise, 3693 ;; we only keep pathnames for which specifying the name and 3694 ;; translating the LPN commute. 3695 (loop :for f :in entries 3696 :for p = (or (and (typep f 'logical-pathname) f) 3697 (let* ((u (ignore-errors (funcall merger f)))) 3698 (and u (equal (ignore-errors (truename u)) f) u))) 3699 :when p :collect p) 3700 entries)) 3701 3702 (defun* directory-files (directory &optional (pattern *wild-file*)) 3703 (when (wild-pathname-p directory) 3704 (error "Invalid wild in ~S" directory)) 3705 (unless (member (pathname-directory pattern) '(() (:relative)) :test 'equal) 3706 (error "Invalid file pattern ~S" pattern)) 3707 (let ((entries (ignore-errors (directory* (merge-pathnames* pattern directory))))) 3708 (filter-logical-directory-results 3709 directory entries 3710 #'(lambda (f) 3711 (make-pathname :defaults directory :version (pathname-version f) 3712 :name (pathname-name f) :type (pathname-type f)))))) 3713 3714 (defun* directory-asd-files (directory) 3715 (directory-files directory *wild-asd*)) 3716 3717 (defun* subdirectories (directory) 3736 3718 (let* ((directory (ensure-directory-pathname directory)) 3737 3719 #-(or abcl cormanlisp genera xcl) … … 3759 3741 #+genera (ensure-directory-pathname (first x)) 3760 3742 #+(or cmu lispworks scl) x))) 3761 dirs)) 3762 3763 (defun collect-asds-in-directory (directory collect) 3743 (filter-logical-directory-results 3744 directory dirs 3745 (let ((prefix (normalize-pathname-directory-component 3746 (pathname-directory directory)))) 3747 #'(lambda (d) 3748 (let ((dir (normalize-pathname-directory-component 3749 (pathname-directory d)))) 3750 (and (consp dir) (consp (cdr dir)) 3751 (make-pathname 3752 :defaults directory :name nil :type nil :version nil 3753 :directory (append prefix (last dir)))))))))) 3754 3755 (defun* collect-asds-in-directory (directory collect) 3764 3756 (map () collect (directory-asd-files directory))) 3765 3757 3766 (defun collect-sub*directories (directory collectp recursep collector)3758 (defun* collect-sub*directories (directory collectp recursep collector) 3767 3759 (when (funcall collectp directory) 3768 3760 (funcall collector directory)) … … 3771 3763 (collect-sub*directories subdir collectp recursep collector)))) 3772 3764 3773 (defun collect-sub*directories-asd-files3765 (defun* collect-sub*directories-asd-files 3774 3766 (directory &key 3775 3767 (exclude *default-source-registry-exclusions*) … … 3986 3978 directory :recurse recurse :exclude exclude :collect 3987 3979 #'(lambda (asd) 3988 (let ((name (pathname-name asd))) 3980 (let* ((name (pathname-name asd)) 3981 (name (if (typep asd 'logical-pathname) 3982 ;; logical pathnames are upper-case, 3983 ;; at least in the CLHS and on SBCL, 3984 ;; yet (coerce-name :foo) is lower-case. 3985 ;; won't work well with (load-system "Foo") 3986 ;; instead of (load-system 'foo) 3987 (string-downcase name) 3988 name))) 3989 3989 (cond 3990 3990 ((gethash name registry) ; already shadowed by something else
Note:
See TracChangeset
for help on using the changeset viewer.
