Commit 1aec9162 authored by Francois-Rene Rideau's avatar Francois-Rene Rideau

Correctly track status of actions across phases

Do not perform an action twice in a session. Introduce three status bits
that every action has in a given session, in addition to the stamp:
KEEP-P (from previous session), DONE-P (and up-to-date, in this image),
NEED-P (needed in this image as part of this session).

BACKWARD INCOMPATIBILITY: Invert the meaning of NIL and T for STAMP,
so that NIL means out-of-date. This makes our code conceptually nicer,
and no one in Quicklisp uses our stamps, anyway. Still, beware.
parent 4f276300
......@@ -17,7 +17,7 @@
#:action-operation #:action-component #:make-action
#:component-operation-time #:mark-operation-done #:compute-action-stamp
#:perform #:perform-with-restarts #:retry #:accept
#:action-path #:find-action #:stamp #:done-p
#:action-path #:find-action
#:operation-definition-warning #:operation-definition-error ;; condition
#:circular-dependency #:circular-dependency-actions
......@@ -435,10 +435,13 @@ Returns two values:
(gethash o (component-operation-times c)))
(defmethod (setf component-operation-time) (stamp (o operation) (c component))
(assert stamp () "invalid null stamp for ~A" (action-description o c))
(setf (gethash o (component-operation-times c)) stamp))
(defmethod mark-operation-done ((o operation) (c component))
(setf (component-operation-time o c) (compute-action-stamp nil o c :just-done t))))
(let ((stamp (compute-action-stamp nil o c :just-done t)))
(assert stamp () "Failed to compute a stamp for completed action ~A" (action-description o c))1
(setf (component-operation-time o c) stamp))))
;;;; Perform
This diff is collapsed.
......@@ -30,4 +30,7 @@ use a wild pathname instead." module)))
(compute-children-by-name self)
(defmethod input-files ((o compile-op) (c wild-module)) ())
(defmethod input-files ((o load-op) (c wild-module)) ())
(export 'wild-module)
......@@ -8,7 +8,7 @@
:asdf/find-component :asdf/system-registry :asdf/plan :asdf/operate)
#:find-system #:locate-system #:load-asd #:define-op
#:load-system-definition-error #:error-name #:error-pathname #:error-condition #:system-out-of-date))
#:load-system-definition-error #:error-name #:error-pathname #:error-condition))
(in-package :asdf/find-system)
(with-upgradability ()
......@@ -20,13 +20,6 @@
(format s (compatfmt "~@<Error while trying to load definition for system ~A from pathname ~A: ~3i~_~A~@:>")
(error-name c) (error-pathname c) (error-condition c)))))
(define-condition system-out-of-date (condition)
;; NB: not an error, not a warning, but a normal expected condition
((name :initarg :name :reader component-name))
(:documentation "condition signaled when a system is detected as being out of date")
(:report (lambda (c s)
(format s "system ~A is out of date" (component-name c)))))
;;; Methods for find-system
......@@ -130,7 +123,7 @@ Do NOT try to load a .asd file directly with CL:LOAD. Always use ASDF:LOAD-ASD."
;; We already determine this to be obsolete ---
;; or should we move some tests from find-system to check for up-to-date-ness here?
(setf (component-operation-time operation system) nil
(setf (component-operation-time operation system) t
(definition-dependency-list system) nil
(definition-dependency-set system) (list-to-hash-set nil))
(do-it operation system))
......@@ -221,11 +214,28 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
;; reconcile the finding (if any) with any previous definition (in a previous session,
;; preloaded, with a previous configuration, or before filesystem changes), and
;; load a found .asd if appropriate. Finally, update registration table and return results.
(defun definition-dependencies-up-to-date-p (system)
(check-type system system)
(assert (primary-system-p system))
(loop :with plan = (make-instance *plan-class*)
:for action :in (definition-dependency-list system)
:always (action-up-to-date-p
plan (action-operation action) (action-component action))
(let ((o (make-operation 'define-op)))
(multiple-value-bind (stamp done-p)
(compute-action-stamp plan o system)
(return (and (stamp<= stamp (component-operation-time o system))
(system-out-of-date () nil)))
(defmethod find-system ((name string) &optional (error-p t))
(with-asdf-session (:key `(find-system ,name)))
(let* ((name-primary-p (primary-system-p name))
(primary-system (unless name-primary-p (find-system (primary-system-name name) nil)))))
(let ((name-primary-p (primary-system-p name)))
(unless name-primary-p (find-system (primary-system-name name) nil)))
(or (and *immutable-systems* (gethash name *immutable-systems*) (registered-system name)))
(multiple-value-bind (foundp found-system pathname previous previous-time)
(locate-system name)
......@@ -248,22 +258,8 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
;; TODO: check that all dependencies are up-to-date.
;; This necessitates traversing them without triggering
;; the adding of nodes to the plan.
(loop :with plan = (make-instance *plan-class*)
:for action :in (definition-dependency-list previous)
:always (handler-bind
(lambda (c) (declare (ignore c)) (return nil))))
(action-up-to-date-p plan
(action-operation action)
(action-component action)))
(let ((o (make-operation 'define-op))
(s (if name-primary-p previous primary-system)))
(when s
(multiple-value-bind (stamp done-p)
(compute-action-stamp plan o s)
(return (and (stamp<= stamp (component-operation-time o s))
(or (not name-primary-p)
(definition-dependencies-up-to-date-p previous)))))
(unless up-to-date-p
(signal 'system-out-of-date :name name)
......@@ -280,8 +276,8 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
;; Recurse to children, so asdf/plan will hopefully be happy.
(map () 'mark-component-preloaded (component-children component))
;; Mark the timestamps of the common lisp-action operations as 0.
(let ((times (component-operation-times component)))
(let ((cot (component-operation-times component)))
(dolist (o `(,@(when (primary-system-p component) '(define-op))
prepare-op compile-op load-op))
(setf (gethash (make-operation o) times) 0))))))
(setf (gethash (make-operation o) cot) 0))))))
......@@ -163,7 +163,7 @@ defaults to LOAD-OP, to load it in current image."
"Has the given COMPONENT been successfully loaded in the current image (yet)?
Note that this returns true even if the component is not up to date."
(if-let ((component (find-component component () :registered t)))
(action-already-done-p nil (make-operation 'load-op) component)))
(nth-value 1 (component-operation-time (make-operation 'load-op) component))))
(defun already-loaded-systems ()
"return a list of the names of the systems that have been successfully loaded so far"
This diff is collapsed.
......@@ -148,7 +148,7 @@
;; Compute the file stamp for a normalized namestring
(defun compute-file-stamp (normalized-namestring)
(with-pathname-defaults ()
(safe-file-write-date normalized-namestring)))
(or (safe-file-write-date normalized-namestring) t)))
;; Override the time STAMP associated to a given FILE in the session cache.
;; If no STAMP is specified, recompute a new one from the filesystem.
......@@ -6,9 +6,21 @@
(assert (not (component-loaded-p 'test-asdf/force)))
(defun force-plan (&rest forcing-options)
(asdf::make-plan nil 'load-op 'test-asdf/force
:forcing (apply 'asdf::make-forcing :system 'test-asdf/force forcing-options))))
(asdf::make-plan nil 'load-op 'test-asdf/force
:forcing (apply 'asdf::make-forcing :system 'test-asdf/force forcing-options)))
(defvar *plan* nil)
(defun component-out-of-date-p (component)
(make-operation 'load-op)
(find-component component nil :registered t))))
(defun plan-loads-p (component)
(member (asdf::make-action (make-operation 'load-op) (find-component () component :registered t))
(asdf::plan-actions *plan*) :test 'equal))
(with-asdf-session (:override t :override-forcing t)
(load-system 'test-asdf/force))
......@@ -28,50 +40,61 @@
(defparameter *plan* (force-plan :force t))
(DBG "Check that :force t forces the current system but not its dependencies" *plan*)
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force" "file4")))
(assert (not (asdf::plan-operates-on-p *plan* '("file3-only" "file3"))))
(assert (not (asdf::plan-operates-on-p *plan* '("test-asdf/force1" "file1"))))
(assert (component-out-of-date-p '("test-asdf/force" "file4")))
(assert (not (component-out-of-date-p '("file3-only" "file3"))))
(assert (not (component-out-of-date-p '("test-asdf/force1" "file1"))))
(defparameter *plan* (force-plan :force :all))
(DBG "Check that :force :all forces the current system and its dependencies" *plan*)
(assert *plan*)
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force" "file4")))
(assert (asdf::plan-operates-on-p *plan* '("file3-only" "file3")))
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force1" "file1")))
(assert (asdf::plan-actions *plan*))
(assert (component-out-of-date-p '("test-asdf/force" "file4")))
(assert (component-out-of-date-p '("file3-only" "file3")))
(assert (component-out-of-date-p '("test-asdf/force1" "file1")))
(defparameter *plan* (force-plan :force :all :force-not t))
(DBG "Check that :force-not takes precedence over :force, with t means \"all but current system\"" *plan*)
(assert *plan*)
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force" "file4")))
(assert (not (asdf::plan-operates-on-p *plan* '("file3-only" "file3"))))
(assert (not (asdf::plan-operates-on-p *plan* '("test-asdf/force1" "file1"))))
(assert (asdf::plan-actions *plan*))
(assert (component-out-of-date-p '("test-asdf/force" "file4")))
(assert (not (component-out-of-date-p '("file3-only" "file3"))))
(assert (not (component-out-of-date-p '("test-asdf/force1" "file1"))))
(defparameter *plan* (force-plan :force-not :all))
(DBG "Check that :force-not :all means \"all systems\"" *plan*)
(assert (null *plan*))
(assert (null (asdf::plan-actions *plan*)))
(defparameter *plan* (force-plan :force :all :force-not :all))
(DBG "Check that :force-not :all takes precedence over :force" *plan*)
(assert (null *plan*))
(assert (null (asdf::plan-actions *plan*)))
(defparameter *plan* (force-plan :force :all :force-not '(:test-asdf/force :test-asdf/force1)))
(defparameter *plan* (force-plan :force :all :force-not '(:test-asdf/force)))
(DBG "Check that :force-not with a list takes precedence over :force" *plan*)
(assert (null *plan*))
(assert (null (asdf::plan-actions *plan*)))
(defparameter *plan* (force-plan :force :all :force-not '(:test-asdf/force1)))
(DBG "Check that :force-not with a list takes precedence over :force, 2" *plan*)
(assert (asdf::plan-actions *plan*))
(assert (component-out-of-date-p '("test-asdf/force" "file4")))
;; transitively included via test-asdf/force1 test-asdf/only, which blocks the traversal
(assert (not (plan-loads-p '("file3-only" "file3"))))
(assert (component-out-of-date-p '("file3-only" "file3")))
(assert (not (component-out-of-date-p '("test-asdf/force1" "file1"))))
(let* ((asdf::*immutable-systems* (list-to-hash-set '("test-asdf/force1")))
(plan (force-plan :force :all)))
(DBG "Check that immutable-systems will block forcing" plan)
(assert plan)
(assert (asdf::plan-operates-on-p plan '("test-asdf/force" "file4")))
(*plan* (force-plan :force :all)))
(DBG "Check that immutable-systems will block forcing" *plan*)
(assert (asdf::plan-actions *plan*))
(assert (component-out-of-date-p '("test-asdf/force" "file4")))
;; transitively included via force1 test-asdf/only, which blocks the traversal
(assert (not (asdf::plan-operates-on-p plan '("file3-only" "file3"))))
(assert (not (asdf::plan-operates-on-p plan '("test-asdf/force1" "file1")))))
(assert (not (plan-loads-p '("file3-only" "file3"))))
(assert (component-out-of-date-p '("file3-only" "file3")))
(assert (not (component-out-of-date-p '("test-asdf/force1" "file1")))))
;; unforced, date should stay same
(touch-file "test-asdf.asd" :timestamp date1)
......@@ -209,8 +209,6 @@
'(;; slots names
......@@ -240,8 +238,6 @@
......@@ -375,26 +375,26 @@ If optional ERROR argument is NIL, return NIL instead of an error when the symbo
(string (standard-case-symbol-name package-designator)))
;;; stamps: a REAL or a boolean where NIL=-infinity, T=+infinity
;;; stamps: a REAL or a boolean where T=-infinity, NIL=+infinity
(eval-when (#-lispworks :compile-toplevel :load-toplevel :execute)
(deftype stamp () '(or real boolean)))
(with-upgradability ()
(defun stamp< (x y)
(etypecase x
(null (and y t))
((eql t) nil)
((eql t) (not (eql y t)))
(real (etypecase y
(null nil)
((eql t) t)
(real (< x y))))))
((eql t) nil)
(real (< x y))
(null t)))
(null nil)))
(defun stamps< (list) (loop :for y :in list :for x = nil :then y :always (stamp< x y)))
(defun stamp*< (&rest list) (stamps< list))
(defun stamp<= (x y) (not (stamp< y x)))
(defun earlier-stamp (x y) (if (stamp< x y) x y))
(defun stamps-earliest (list) (reduce 'earlier-stamp list :initial-value t))
(defun stamps-earliest (list) (reduce 'earlier-stamp list :initial-value nil))
(defun earliest-stamp (&rest list) (stamps-earliest list))
(defun later-stamp (x y) (if (stamp< x y) y x))
(defun stamps-latest (list) (reduce 'later-stamp list :initial-value nil))
(defun stamps-latest (list) (reduce 'later-stamp list :initial-value t))
(defun latest-stamp (&rest list) (stamps-latest list))
(define-modify-macro latest-stamp-f (&rest stamps) latest-stamp))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment