X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fasdf%2Fasdf.lisp;h=a987d9ff501fa3812beb827d406296f2bc4ac4d1;hb=85dc70440d40a589365323c63e0dad039a578b6f;hp=4f7aff78f645102ff30559f8504e296e2ab72961;hpb=93c941d86b264637de20aa1b713757b704d4c1a6;p=sbcl.git diff --git a/contrib/asdf/asdf.lisp b/contrib/asdf/asdf.lisp index 4f7aff7..a987d9f 100644 --- a/contrib/asdf/asdf.lisp +++ b/contrib/asdf/asdf.lisp @@ -1,4 +1,4 @@ -;;; This is asdf: Another System Definition Facility. 1.68 +;;; This is asdf: Another System Definition Facility. $Revision$ ;;; ;;; Feedback, bug reports, and patches are all welcome: please mail to ;;; . But note first that the canonical @@ -48,7 +48,7 @@ #:feature ; sort-of operation #:version ; metaphorically sort-of an operation - #:output-files #:perform ; operation methods + #:input-files #:output-files #:perform ; operation methods #:operation-done-p #:explain #:component #:source-file @@ -69,17 +69,36 @@ #:component-version #:component-parent #:component-property + #:component-system #:component-depends-on + + #:system-description + #:system-long-description + #:system-author + #:system-maintainer + #:system-license + + #:operation-on-warnings + #:operation-on-failure ;#:*component-parent-pathname* + #:*system-definition-search-functions* #:*central-registry* ; variables + #:*compile-file-warnings-behaviour* + #:*compile-file-failure-behaviour* + #:*asdf-revision* #:operation-error #:compile-failed #:compile-warned #:compile-error + #:error-component #:error-operation #:system-definition-error #:missing-component #:missing-dependency #:circular-dependency ; errors + + #:retry + #:accept ; restarts + ) (:use :cl)) @@ -89,7 +108,7 @@ (in-package #:asdf) -(defvar *asdf-revision* (let* ((v "1.68") +(defvar *asdf-revision* (let* ((v "$Revision$") (colon (or (position #\: v) -1)) (dot (position #\. v))) (and v colon dot @@ -98,8 +117,10 @@ (parse-integer v :start (1+ dot) :junk-allowed t))))) -(defvar *compile-file-warnings-behaviour* :warn) -(defvar *compile-file-failure-behaviour* #+sbcl :error #-sbcl :warn) +(defvar *compile-file-warnings-behaviour* :warn) +(defvar *compile-file-failure-behaviour* #+sbcl :error #-sbcl :warn) + +(defvar *verbose-out* nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; utility stuff @@ -148,15 +169,15 @@ and NIL NAME and TYPE components" ((component :reader error-component :initarg :component) (operation :reader error-operation :initarg :operation)) (:report (lambda (c s) - (format s (formatter "~@") + (format s "~@" (error-operation c) (error-component c))))) (define-condition compile-error (operation-error) ()) (define-condition compile-failed (compile-error) ()) (define-condition compile-warned (compile-error) ()) (defclass component () - ((name :type string :accessor component-name :initarg :name :documentation - "Component name, restricted to portable pathname characters") + ((name :accessor component-name :initarg :name :documentation + "Component name: designator for a string composed of portable pathname characters") (version :accessor component-version :initarg :version) (in-order-to :initform nil :initarg :in-order-to) ;;; XXX crap name @@ -179,9 +200,8 @@ and NIL NAME and TYPE components" ;;;; methods: conditions (defmethod print-object ((c missing-dependency) s) - (format s (formatter "~@<~A, required by ~A~@:>") - (call-next-method c nil) - (missing-required-by c))) + (format s "~@<~A, required by ~A~@:>" + (call-next-method c nil) (missing-required-by c))) (defun sysdef-error (format &rest arguments) (error 'formatted-system-definition-error :format-control format :format-arguments arguments)) @@ -189,9 +209,9 @@ and NIL NAME and TYPE components" ;;;; methods: components (defmethod print-object ((c missing-component) s) - (format s (formatter "~@") + (format s "~@" (missing-requires c) (missing-version c) (when (missing-parent c) @@ -244,22 +264,21 @@ and NIL NAME and TYPE components" (defgeneric component-property (component property)) (defmethod component-property ((c component) property) - (cdr (assoc property (slot-value c 'properties)))) + (cdr (assoc property (slot-value c 'properties) :test #'equal))) (defgeneric (setf component-property) (new-value component property)) (defmethod (setf component-property) (new-value (c component) property) - (let ((a (assoc property (slot-value c 'properties)))) + (let ((a (assoc property (slot-value c 'properties) :test #'equal))) (if a (setf (cdr a) new-value) (setf (slot-value c 'properties) (acons property new-value (slot-value c 'properties)))))) - - (defclass system (module) ((description :accessor system-description :initarg :description) - (long-description :accessor long-description :initarg :long-description) + (long-description + :accessor system-long-description :initarg :long-description) (author :accessor system-author :initarg :author) (maintainer :accessor system-maintainer :initarg :maintainer) (licence :accessor system-licence :initarg :licence))) @@ -307,8 +326,7 @@ and NIL NAME and TYPE components" (component (component-name name)) (symbol (string-downcase (symbol-name name))) (string name) - (t (sysdef-error (formatter "~@") - name)))) + (t (sysdef-error "~@" name)))) ;;; for the sake of keeping things reasonably neat, we adopt a ;;; convention that functions in this list are prefixed SYSDEF- @@ -345,10 +363,10 @@ and NIL NAME and TYPE components" (when (and on-disk (or (not in-memory) (< (car in-memory) (file-write-date on-disk)))) - (let ((*package* (make-package (gensym (package-name #.*package*)) + (let ((*package* (make-package (gensym #.(package-name *package*)) :use '(:cl :asdf)))) - (format t - (formatter "~&~@<; ~@;loading system definition from ~A into ~A~@:>~%") + (format *verbose-out* + "~&~@<; ~@;loading system definition from ~A into ~A~@:>~%" ;; FIXME: This wants to be (ENOUGH-NAMESTRING ;; ON-DISK), but CMUCL barfs on that. on-disk @@ -361,7 +379,7 @@ and NIL NAME and TYPE components" (if error-p (error 'missing-component :requires name)))))) (defun register-system (name system) - (format t (formatter "~&~@<; ~@;registering ~A as ~A~@:>~%") system name) + (format *verbose-out* "~&~@<; ~@;registering ~A as ~A~@:>~%" system name) (setf (gethash (coerce-name name) *defined-systems*) (cons (get-universal-time) system))) @@ -656,16 +674,15 @@ system.")) (defmethod perform ((operation operation) (c source-file)) (sysdef-error - (formatter "~@") + "~@" (class-of operation) (class-of c))) (defmethod perform ((operation operation) (c module)) nil) (defmethod explain ((operation operation) (component component)) - (format *trace-output* "~&;;; ~A on ~A~%" - operation component)) + (format *verbose-out* "~&;;; ~A on ~A~%" operation component)) ;;; compile-op @@ -686,6 +703,7 @@ system.")) ;;; perform is required to check output-files to find out where to put ;;; its answers, in case it has been overridden for site policy (defmethod perform ((operation compile-op) (c cl-source-file)) + #-:broken-fasl-loader (let ((source-file (component-pathname c)) (output-file (car (output-files operation c)))) (multiple-value-bind (output warnings-p failure-p) @@ -694,21 +712,24 @@ system.")) ;(declare (ignore output)) (when warnings-p (case (operation-on-warnings operation) - (:warn (warn "COMPILE-FILE warned while performing ~A on ~A" - c operation)) + (:warn (warn + "~@" + operation c)) (:error (error 'compile-warned :component c :operation operation)) (:ignore nil))) (when failure-p (case (operation-on-failure operation) - (:warn (warn "COMPILE-FILE failed while performing ~A on ~A" - c operation)) + (:warn (warn + "~@" + operation c)) (:error (error 'compile-failed :component c :operation operation)) (:ignore nil))) (unless output (error 'compile-error :component c :operation operation))))) (defmethod output-files ((operation compile-op) (c cl-source-file)) - (list (compile-file-pathname (component-pathname c)))) + #-:broken-fasl-loader (list (compile-file-pathname (component-pathname c))) + #+:broken-fasl-loader (list (component-pathname c))) (defmethod perform ((operation compile-op) (c static-file)) nil) @@ -778,6 +799,10 @@ system.")) (defun operate (operation-class system &rest args) (let* ((op (apply #'make-instance operation-class :original-initargs args args)) + (*verbose-out* + (if (getf args :verbose t) + *trace-output* + (make-broadcast-stream))) (system (if (typep system 'component) system (find-system system))) (steps (traverse op system))) (with-compilation-unit () @@ -786,8 +811,22 @@ system.")) (restart-case (progn (perform op component) (return)) - (retry-component ()) - (skip-component () (return)))))))) + (retry () + :report + (lambda (s) + (format s "~@" + op component))) + (accept () + :report + (lambda (s) + (format s + "~@" + op component)) + (setf (gethash (type-of op) + (component-operation-times component)) + (get-universal-time)) + (return)))))))) (defun oos (&rest args) "Alias of OPERATE function" @@ -829,21 +868,22 @@ system.")) :pathname (or ,pathname (pathname-sans-name+type - (resolve-symlinks *load-truename*)) + (resolve-symlinks *load-truename*)) *default-pathname-defaults*) ',component-options)))))) (defun class-for-type (parent type) - (let ((class (find-class - (or (find-symbol (symbol-name type) *package*) - (find-symbol (symbol-name type) #.*package*)) nil))) + (let ((class + (find-class + (or (find-symbol (symbol-name type) *package*) + (find-symbol (symbol-name type) #.(package-name *package*))) + nil))) (or class (and (eq type :file) (or (module-default-component-class parent) (find-class 'cl-source-file))) - (sysdef-error (formatter "~@") - type)))) + (sysdef-error "~@" type)))) (defun maybe-add-tree (tree op1 op2 c) "Add the node C at /OP1/OP2 in TREE, unless it's there already. @@ -889,6 +929,7 @@ Returns the new tree (which probably shares structure with the old one)" depends-on serial in-order-to ;; list ends &allow-other-keys) options + (check-component-input type name depends-on components in-order-to) (let* ((other-args (remove-keys '(components pathname default-component-class perform explain output-files operation-done-p @@ -943,6 +984,22 @@ Returns the new tree (which probably shares structure with the old one)" (component-inline-methods ret)))) ret))) +(defun check-component-input (type name depends-on components in-order-to) + "A partial test of the values of a component." + (unless (listp depends-on) + (sysdef-error-component ":depends-on must be a list." + type name depends-on)) + (unless (listp components) + (sysdef-error-component ":components must be NIL or a list of components." + type name components)) + (unless (and (listp in-order-to) (listp (car in-order-to))) + (sysdef-error-component ":in-order-to must be NIL or a list of components." + type name in-order-to))) + +(defun sysdef-error-component (msg type name value) + (sysdef-error (concatenate 'string msg + "~&The value specified for ~(~A~) ~A is ~W") + type name value)) (defun resolve-symlinks (path) #-allegro (truename path) @@ -958,43 +1015,44 @@ Returns the new tree (which probably shares structure with the old one)" (defun run-shell-command (control-string &rest args) "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and synchronously execute the result using a Bourne-compatible shell, with -output to *trace-output*. Returns the shell's exit code." +output to *verbose-out*. Returns the shell's exit code." (let ((command (apply #'format nil control-string args))) - (format *trace-output* "; $ ~A~%" command) + (format *verbose-out* "; $ ~A~%" command) #+sbcl (sb-impl::process-exit-code (sb-ext:run-program "/bin/sh" (list "-c" command) - :input nil :output *trace-output*)) + :input nil :output *verbose-out*)) #+(or cmu scl) (ext:process-exit-code (ext:run-program "/bin/sh" (list "-c" command) - :input nil :output *trace-output*)) + :input nil :output *verbose-out*)) #+allegro - (excl:run-shell-command command :input nil :output *trace-output*) + (excl:run-shell-command command :input nil :output *verbose-out*) #+lispworks (system:call-system-showing-output command :shell-type "/bin/sh" - :output-stream *trace-output*) + :output-stream *verbose-out*) - #+clisp ;XXX not exactly *trace-output*, I know + #+clisp ;XXX not exactly *verbose-out*, I know (ext:run-shell-command command :output :terminal :wait t) #+openmcl (nth-value 1 (ccl:external-process-status (ccl:run-program "/bin/sh" (list "-c" command) - :input nil :output *trace-output* + :input nil :output *verbose-out* :wait t))) - - #-(or openmcl clisp lispworks allegro scl cmu sbcl) + #+ecl ;; courtesy of Juan Jose Garcia Ripoll + (si:system command) + #-(or openmcl clisp lispworks allegro scl cmu sbcl ecl) (error "RUN-SHELL-PROGRAM not implemented for this Lisp") )) @@ -1017,10 +1075,12 @@ output to *trace-output*. Returns the shell's exit code." #+(and sbcl sbcl-hooks-require) (progn (defun module-provide-asdf (name) - (let ((system (asdf:find-system name nil))) - (when system - (asdf:operate 'asdf:load-op name) - (provide name)))) + (handler-bind ((style-warning #'muffle-warning)) + (let* ((*verbose-out* (make-broadcast-stream)) + (system (asdf:find-system name nil))) + (when system + (asdf:operate 'asdf:load-op name) + t)))) (pushnew '(merge-pathnames "systems/" @@ -1038,3 +1098,5 @@ output to *trace-output*. Returns the shell's exit code." *central-registry*) (pushnew 'module-provide-asdf sb-ext:*module-provider-functions*)) + +(provide 'asdf)