Commit 40b86923 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 08ff74b1
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#:action-operation #:action-component #:make-action #:action-operation #:action-component #:make-action
#:component-operation-time #:mark-operation-done #:compute-action-stamp #:component-operation-time #:mark-operation-done #:compute-action-stamp
#:perform #:perform-with-restarts #:retry #:accept #:perform #:perform-with-restarts #:retry #:accept
#:action-path #:find-action #:stamp #:done-p #:action-path #:find-action
#:operation-definition-warning #:operation-definition-error ;; condition #:operation-definition-warning #:operation-definition-error ;; condition
#:action-valid-p #:action-valid-p
#:circular-dependency #:circular-dependency-actions #:circular-dependency #:circular-dependency-actions
...@@ -435,10 +435,13 @@ Returns two values: ...@@ -435,10 +435,13 @@ Returns two values:
(gethash o (component-operation-times c))) (gethash o (component-operation-times c)))
(defmethod (setf component-operation-time) (stamp (o operation) (c component)) (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)) (setf (gethash o (component-operation-times c)) stamp))
(defmethod mark-operation-done ((o operation) (c component)) (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 ;;;; Perform
......
This diff is collapsed.
...@@ -30,4 +30,7 @@ use a wild pathname instead." module))) ...@@ -30,4 +30,7 @@ use a wild pathname instead." module)))
(compute-children-by-name self) (compute-children-by-name self)
(values))) (values)))
(defmethod input-files ((o compile-op) (c wild-module)) ())
(defmethod input-files ((o load-op) (c wild-module)) ())
(export 'wild-module) (export 'wild-module)
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
:asdf/find-component :asdf/system-registry :asdf/plan :asdf/operate) :asdf/find-component :asdf/system-registry :asdf/plan :asdf/operate)
(:export (:export
#:find-system #:locate-system #:load-asd #:define-op #: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) (in-package :asdf/find-system)
(with-upgradability () (with-upgradability ()
...@@ -20,13 +20,6 @@ ...@@ -20,13 +20,6 @@
(format s (compatfmt "~@<Error while trying to load definition for system ~A from pathname ~A: ~3i~_~A~@:>") (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))))) (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 ;;; 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." ...@@ -130,7 +123,7 @@ Do NOT try to load a .asd file directly with CL:LOAD. Always use ASDF:LOAD-ASD."
(progn (progn
;; We already determine this to be obsolete --- ;; We already determine this to be obsolete ---
;; or should we move some tests from find-system to check for up-to-date-ness here? ;; 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-list system) nil
(definition-dependency-set system) (list-to-hash-set nil)) (definition-dependency-set system) (list-to-hash-set nil))
(do-it operation system)) (do-it operation system))
...@@ -221,11 +214,28 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded. ...@@ -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, ;; reconcile the finding (if any) with any previous definition (in a previous session,
;; preloaded, with a previous configuration, or before filesystem changes), and ;; preloaded, with a previous configuration, or before filesystem changes), and
;; load a found .asd if appropriate. Finally, update registration table and return results. ;; 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))
(handler-case
(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))
:finally
(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))
done-p)))))
(system-out-of-date () nil)))
(defmethod find-system ((name string) &optional (error-p t)) (defmethod find-system ((name string) &optional (error-p t))
(nest (nest
(with-asdf-session (:key `(find-system ,name))) (with-asdf-session (:key `(find-system ,name)))
(let* ((name-primary-p (primary-system-p name)) (let ((name-primary-p (primary-system-p name)))
(primary-system (unless name-primary-p (find-system (primary-system-name name) nil))))) (unless name-primary-p (find-system (primary-system-name name) nil)))
(or (and *immutable-systems* (gethash name *immutable-systems*) (registered-system name))) (or (and *immutable-systems* (gethash name *immutable-systems*) (registered-system name)))
(multiple-value-bind (foundp found-system pathname previous previous-time) (multiple-value-bind (foundp found-system pathname previous previous-time)
(locate-system name) (locate-system name)
...@@ -248,22 +258,8 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded. ...@@ -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. ;; TODO: check that all dependencies are up-to-date.
;; This necessitates traversing them without triggering ;; This necessitates traversing them without triggering
;; the adding of nodes to the plan. ;; the adding of nodes to the plan.
(loop :with plan = (make-instance *plan-class*) (or (not name-primary-p)
:for action :in (definition-dependency-list previous) (definition-dependencies-up-to-date-p previous)))))
:always (handler-bind
((system-out-of-date
(lambda (c) (declare (ignore c)) (return nil))))
(action-up-to-date-p plan
(action-operation action)
(action-component action)))
:finally
(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))
done-p)))))))))
(unless up-to-date-p (unless up-to-date-p
(restart-case (restart-case
(signal 'system-out-of-date :name name) (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. ...@@ -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. ;; Recurse to children, so asdf/plan will hopefully be happy.
(map () 'mark-component-preloaded (component-children component)) (map () 'mark-component-preloaded (component-children component))
;; Mark the timestamps of the common lisp-action operations as 0. ;; 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)) (dolist (o `(,@(when (primary-system-p component) '(define-op))
prepare-op compile-op load-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." ...@@ -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)? "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." Note that this returns true even if the component is not up to date."
(if-let ((component (find-component component () :registered t))) (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 () (defun already-loaded-systems ()
"return a list of the names of the systems that have been successfully loaded so far" "return a list of the names of the systems that have been successfully loaded so far"
......
This diff is collapsed.
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
;; Compute the file stamp for a normalized namestring ;; Compute the file stamp for a normalized namestring
(defun compute-file-stamp (normalized-namestring) (defun compute-file-stamp (normalized-namestring)
(with-pathname-defaults () (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. ;; 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. ;; If no STAMP is specified, recompute a new one from the filesystem.
......
...@@ -6,9 +6,21 @@ ...@@ -6,9 +6,21 @@
(assert (not (component-loaded-p 'test-asdf/force))) (assert (not (component-loaded-p 'test-asdf/force)))
(defun force-plan (&rest forcing-options) (defun force-plan (&rest forcing-options)
(asdf::plan-actions (asdf::make-plan nil 'load-op 'test-asdf/force
(asdf::make-plan nil 'load-op 'test-asdf/force :forcing (apply 'asdf::make-forcing :system 'test-asdf/force forcing-options)))
:forcing (apply 'asdf::make-forcing :system 'test-asdf/force forcing-options))))
(defvar *plan* nil)
(defun component-out-of-date-p (component)
(not
(asdf::action-up-to-date-p
*plan*
(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) (with-asdf-session (:override t :override-forcing t)
(load-system 'test-asdf/force)) (load-system 'test-asdf/force))
...@@ -28,50 +40,61 @@ ...@@ -28,50 +40,61 @@
(reset-session-visited) (reset-session-visited)
(defparameter *plan* (force-plan :force t)) (defparameter *plan* (force-plan :force t))
(DBG "Check that :force t forces the current system but not its dependencies" *plan*) (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 (component-out-of-date-p '("test-asdf/force" "file4")))
(assert (not (asdf::plan-operates-on-p *plan* '("file3-only" "file3")))) (assert (not (component-out-of-date-p '("file3-only" "file3"))))
(assert (not (asdf::plan-operates-on-p *plan* '("test-asdf/force1" "file1")))) (assert (not (component-out-of-date-p '("test-asdf/force1" "file1"))))
(reset-session-visited) (reset-session-visited)
(defparameter *plan* (force-plan :force :all)) (defparameter *plan* (force-plan :force :all))
(DBG "Check that :force :all forces the current system and its dependencies" *plan*) (DBG "Check that :force :all forces the current system and its dependencies" *plan*)
(assert *plan*) (assert (asdf::plan-actions *plan*))
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force" "file4"))) (assert (component-out-of-date-p '("test-asdf/force" "file4")))
(assert (asdf::plan-operates-on-p *plan* '("file3-only" "file3"))) (assert (component-out-of-date-p '("file3-only" "file3")))
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force1" "file1"))) (assert (component-out-of-date-p '("test-asdf/force1" "file1")))
(reset-session-visited) (reset-session-visited)
(defparameter *plan* (force-plan :force :all :force-not t)) (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*) (DBG "Check that :force-not takes precedence over :force, with t means \"all but current system\"" *plan*)
(assert *plan*) (assert (asdf::plan-actions *plan*))
(assert (asdf::plan-operates-on-p *plan* '("test-asdf/force" "file4"))) (assert (component-out-of-date-p '("test-asdf/force" "file4")))
(assert (not (asdf::plan-operates-on-p *plan* '("file3-only" "file3")))) (assert (not (component-out-of-date-p '("file3-only" "file3"))))
(assert (not (asdf::plan-operates-on-p *plan* '("test-asdf/force1" "file1")))) (assert (not (component-out-of-date-p '("test-asdf/force1" "file1"))))
(reset-session-visited) (reset-session-visited)
(defparameter *plan* (force-plan :force-not :all)) (defparameter *plan* (force-plan :force-not :all))
(DBG "Check that :force-not :all means \"all systems\"" *plan*) (DBG "Check that :force-not :all means \"all systems\"" *plan*)
(assert (null *plan*)) (assert (null (asdf::plan-actions *plan*)))
(reset-session-visited) (reset-session-visited)
(defparameter *plan* (force-plan :force :all :force-not :all)) (defparameter *plan* (force-plan :force :all :force-not :all))
(DBG "Check that :force-not :all takes precedence over :force" *plan*) (DBG "Check that :force-not :all takes precedence over :force" *plan*)
(assert (null *plan*)) (assert (null (asdf::plan-actions *plan*)))
(reset-session-visited) (reset-session-visited)
(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*) (DBG "Check that :force-not with a list takes precedence over :force" *plan*)
(assert (null *plan*)) (assert (null (asdf::plan-actions *plan*)))
(reset-session-visited)
(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"))))
(reset-session-visited) (reset-session-visited)
(let* ((asdf::*immutable-systems* (list-to-hash-set '("test-asdf/force1"))) (let* ((asdf::*immutable-systems* (list-to-hash-set '("test-asdf/force1")))
(plan (force-plan :force :all))) (*plan* (force-plan :force :all)))
(DBG "Check that immutable-systems will block forcing" plan) (DBG "Check that immutable-systems will block forcing" *plan*)
(assert plan) (assert (asdf::plan-actions *plan*))
(assert (asdf::plan-operates-on-p plan '("test-asdf/force" "file4"))) (assert (component-out-of-date-p '("test-asdf/force" "file4")))
;; transitively included via force1 test-asdf/only, which blocks the traversal ;; transitively included via force1 test-asdf/only, which blocks the traversal
(assert (not (asdf::plan-operates-on-p plan '("file3-only" "file3")))) (assert (not (plan-loads-p '("file3-only" "file3"))))
(assert (not (asdf::plan-operates-on-p plan '("test-asdf/force1" "file1"))))) (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 ;; unforced, date should stay same
(touch-file "test-asdf.asd" :timestamp date1) (touch-file "test-asdf.asd" :timestamp date1)
......
...@@ -209,8 +209,6 @@ ...@@ -209,8 +209,6 @@
'(;; slots names '(;; slots names
asdf/action:accept asdf/action:accept
asdf/action:action asdf/action:action
asdf/action:done-p
asdf/action:stamp
asdf/bundle:prologue-code asdf/bundle:prologue-code
asdf/bundle:epilogue-code asdf/bundle:epilogue-code
asdf/component:absolute-pathname asdf/component:absolute-pathname
...@@ -240,8 +238,6 @@ ...@@ -240,8 +238,6 @@
asdf/component:sideway-dependencies asdf/component:sideway-dependencies
asdf/component:version asdf/component:version
asdf/operation:feature asdf/operation:feature
asdf/plan:index
asdf/plan:planned-p
asdf/system:bug-tracker asdf/system:bug-tracker
asdf/system:build-pathname asdf/system:build-pathname
asdf/system:system-defsystem-depends-on asdf/system:system-defsystem-depends-on
......
...@@ -375,26 +375,26 @@ If optional ERROR argument is NIL, return NIL instead of an error when the symbo ...@@ -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))) (string (standard-case-symbol-name package-designator)))
error))) error)))
;;; 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) (eval-when (#-lispworks :compile-toplevel :load-toplevel :execute)
(deftype stamp () '(or real boolean))) (deftype stamp () '(or real boolean)))
(with-upgradability () (with-upgradability ()
(defun stamp< (x y) (defun stamp< (x y)
(etypecase x (etypecase x
(null (and y t)) ((eql t) (not (eql y t)))
((eql t) nil)
(real (etypecase y (real (etypecase y
(null nil) ((eql t) nil)
((eql t) t) (real (< x y))
(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 stamps< (list) (loop :for y :in list :for x = nil :then y :always (stamp< x y)))
(defun stamp*< (&rest list) (stamps< list)) (defun stamp*< (&rest list) (stamps< list))
(defun stamp<= (x y) (not (stamp< y x))) (defun stamp<= (x y) (not (stamp< y x)))
(defun earlier-stamp (x y) (if (stamp< x y) x y)) (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 earliest-stamp (&rest list) (stamps-earliest list))
(defun later-stamp (x y) (if (stamp< x y) y x)) (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)) (defun latest-stamp (&rest list) (stamps-latest list))
(define-modify-macro latest-stamp-f (&rest stamps) latest-stamp)) (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