Skip to content
Snippets Groups Projects
Commit a3b85c8b authored by Francois-Rene Rideau's avatar Francois-Rene Rideau
Browse files

Refactor load-asd to perform a define-op

Split asdf/system-registry away from asdf/find-system: the former defines
the internal *defined-systems* table and the search mechanism, whereas
the latter keeps the find-system methods, but also defines a new
define-op operation, on load-asd will call operate.

Reorder dependencies accordingly.

Have forcing come from the plan, so as to not force again actions from
dependencies that were already performed in a subcall to operate.

Accept asdf.asd from the same version, so asdf.asd doesn't get removed
at the very next call to operate (which may now come implicitly
at the least provocation).
parent a9c22442
No related branches found
No related tags found
No related merge requests found
......@@ -80,7 +80,7 @@ XCL ?= xcl
header_lisp := header.lisp
driver_lisp := uiop/package.lisp uiop/common-lisp.lisp uiop/utility.lisp uiop/version.lisp uiop/os.lisp uiop/pathname.lisp uiop/filesystem.lisp uiop/stream.lisp uiop/image.lisp uiop/lisp-build.lisp uiop/launch-program.lisp uiop/run-program.lisp uiop/configuration.lisp uiop/backward-driver.lisp uiop/driver.lisp
defsystem_lisp := upgrade.lisp session.lisp component.lisp operation.lisp system.lisp action.lisp find-system.lisp find-component.lisp lisp-action.lisp plan.lisp operate.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp package-inferred-system.lisp output-translations.lisp source-registry.lisp backward-internals.lisp backward-interface.lisp interface.lisp user.lisp footer.lisp
defsystem_lisp := upgrade.lisp session.lisp component.lisp operation.lisp system.lisp system-registry.lisp action.lisp lisp-action.lisp find-component.lisp plan.lisp operate.lisp find-system.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp package-inferred-system.lisp output-translations.lisp source-registry.lisp backward-internals.lisp backward-interface.lisp interface.lisp user.lisp footer.lisp
all_lisp := $(header_lisp) $(driver_lisp) $(defsystem_lisp)
print-% : ; @echo $* = $($*)
......
......@@ -48,16 +48,17 @@
(:file "component" :depends-on ("session"))
(:file "operation" :depends-on ("session"))
(:file "system" :depends-on ("component"))
(:file "system-registry" :depends-on ("system"))
(:file "action" :depends-on ("session" "system" "operation"))
(:file "find-system" :depends-on ("session" "system" "action"))
(:file "find-component" :depends-on ("find-system"))
(:file "lisp-action" :depends-on ("action" "find-system"))
(:file "lisp-action" :depends-on ("action"))
(:file "find-component" :depends-on ("component"))
(:file "plan" :depends-on ("lisp-action" "find-component"))
(:file "operate" :depends-on ("plan"))
(:file "parse-defsystem" :depends-on ("system" "lisp-action" "operate"))
(:file "find-system" :depends-on ("system-registry" "operate"))
(:file "parse-defsystem" :depends-on ("system-registry" "lisp-action" "operate"))
(:file "bundle" :depends-on ("lisp-action" "operate" "parse-defsystem"))
(:file "concatenate-source" :depends-on ("plan" "parse-defsystem" "bundle"))
(:file "package-inferred-system" :depends-on ("find-system" "parse-defsystem"))
(:file "package-inferred-system" :depends-on ("parse-defsystem"))
(:file "output-translations" :depends-on ("operate"))
(:file "source-registry" :depends-on ("find-system"))
(:file "backward-internals" :depends-on ("find-system" "parse-defsystem"))
......
......@@ -2,15 +2,15 @@
;;;; Finding components
(uiop/package:define-package :asdf/find-component
(:recycle :asdf/find-component :asdf)
(:recycle :asdf/find-component :asdf/find-system :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
:asdf/component :asdf/system :asdf/find-system)
:asdf/component :asdf/system :asdf/system-registry)
(:export
#:find-component
#:resolve-dependency-name #:resolve-dependency-spec
#:resolve-dependency-combination
;; Conditions
#:missing-component #:missing-component-of-version #:retry
#:missing-component #:missing-requires #:missing-parent #:missing-component-of-version #:retry
#:missing-dependency #:missing-dependency-of-version
#:missing-requires #:missing-parent
#:missing-required-by #:missing-version))
......@@ -19,6 +19,10 @@
;;;; Missing component conditions
(with-upgradability ()
(define-condition missing-component (system-definition-error)
((requires :initform "(unnamed)" :reader missing-requires :initarg :requires)
(parent :initform nil :reader missing-parent :initarg :parent)))
(define-condition missing-component-of-version (missing-component)
((version :initform nil :reader missing-version :initarg :version)))
......
......@@ -4,35 +4,15 @@
(uiop/package:define-package :asdf/find-system
(:recycle :asdf/find-system :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
:asdf/session :asdf/component :asdf/operation :asdf/action :asdf/system)
:asdf/session :asdf/component :asdf/system :asdf/operation :asdf/action :asdf/lisp-action
:asdf/find-component :asdf/system-registry :asdf/plan :asdf/operate)
(:export
#:remove-entry-from-registry #:coerce-entry-to-directory
#:coerce-name #:primary-system-name #:coerce-filename
#:find-system #:locate-system #:load-asd #:define-op
#:system-registered-p #:registered-system #:register-system
#:registered-systems* #:registered-systems
#:clear-system #:map-systems
#:missing-component #:missing-requires #:missing-parent
#:load-system-definition-error #:error-name #:error-pathname #:error-condition
#:*system-definition-search-functions* #:search-for-system-definition
#:*central-registry* #:probe-asd #:sysdef-central-registry-search
#:find-system-if-being-defined
#:contrib-sysdef-search #:sysdef-find-asdf ;; backward compatibility symbols, functions removed
#:sysdef-preloaded-system-search #:register-preloaded-system #:*preloaded-systems*
#:mark-component-preloaded ;; forward reference to asdf/operate
#:sysdef-immutable-system-search #:register-immutable-system #:*immutable-systems*
#:*defined-systems* #:clear-defined-systems
;; defined in source-registry, but specially mentioned here:
#:initialize-source-registry #:sysdef-source-registry-search))
))
(in-package :asdf/find-system)
(with-upgradability ()
(declaim (ftype (function (&optional t) t) initialize-source-registry)) ; forward reference
(define-condition missing-component (system-definition-error)
((requires :initform "(unnamed)" :reader missing-requires :initarg :requires)
(parent :initform nil :reader missing-parent :initarg :parent)))
(define-condition load-system-definition-error (system-definition-error)
((name :initarg :name :reader error-name)
(pathname :initarg :pathname :reader error-pathname)
......@@ -41,326 +21,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)))))
;;; Canonicalizing system names
(defun coerce-name (name)
"Given a designator for a component NAME, return the name as a string.
The designator can be a COMPONENT (designing its name; note that a SYSTEM is a component),
a SYMBOL (designing its name, downcased), or a STRING (designing itself)."
(typecase name
(component (component-name name))
(symbol (string-downcase name))
(string name)
(t (sysdef-error (compatfmt "~@<Invalid component designator: ~3i~_~A~@:>") name))))
(defun primary-system-name (name)
"Given a system designator NAME, return the name of the corresponding primary system,
after which the .asd file is named. That's the first component when dividing the name
as a string by / slashes."
(first (split-string (coerce-name name) :separator "/")))
(defun coerce-filename (name)
"Coerce a system designator NAME into a string suitable as a filename component.
The (current) transformation is to replace characters /:\\ each by --,
the former being forbidden in a filename component.
NB: The onus is unhappily on the user to avoid clashes."
(frob-substrings (coerce-name name) '("/" ":" "\\") "--"))
;;; Registry of Defined Systems
(defvar *defined-systems* (make-hash-table :test 'equal)
"This is a hash table whose keys are strings -- the
names of systems -- and whose values are pairs, the first
element of which is a universal-time indicating when the
system definition was last updated, and the second element
of which is a system object.
A system is referred to as \"registered\" if it is present
in this table.")
(defun system-registered-p (name)
"Return a generalized boolean that is true if a system of given NAME was registered already.
NAME is a system designator, to be normalized by COERCE-NAME.
The value returned if true is a pair of a timestamp and a system object."
(gethash (coerce-name name) *defined-systems*))
(defun registered-system (name)
"Return a system of given NAME that was registered already,
if such a system exists. NAME is a system designator, to be
normalized by COERCE-NAME. The value returned is a system object,
or NIL if not found."
(cdr (system-registered-p name)))
(defun registered-systems* ()
"Return a list containing every registered system (as a system object)."
(loop :for registered :being :the :hash-values :of *defined-systems*
:collect (cdr registered)))
(defun registered-systems ()
"Return a list of the names of every registered system."
(mapcar 'coerce-name (registered-systems*)))
(defun register-system (system)
"Given a SYSTEM object, register it."
(check-type system system)
(let ((name (component-name system)))
(check-type name string)
(asdf-message (compatfmt "~&~@<; ~@;Registering system ~3i~_~A~@:>~%") name)
(unless (eq system (registered-system name))
(setf (gethash name *defined-systems*)
(cons (ignore-errors (get-file-stamp (system-source-file system)))
system)))))
(defun map-systems (fn)
"Apply FN to each defined system.
FN should be a function of one argument. It will be
called with an object of type asdf:system."
(loop :for registered :being :the :hash-values :of *defined-systems*
:do (funcall fn (cdr registered))))
;;; Preloaded systems: in the image even if you can't find source files backing them.
(defvar *preloaded-systems* (make-hash-table :test 'equal)
"Registration table for preloaded systems.")
(declaim (ftype (function (t) t) mark-component-preloaded)) ; defined in asdf/operate
(defun make-preloaded-system (name keys)
"Make a preloaded system of given NAME with build information from KEYS"
(let ((system (apply 'make-instance (getf keys :class 'system)
:name name :source-file (getf keys :source-file)
(remove-plist-keys '(:class :name :source-file) keys))))
(mark-component-preloaded system)
system))
(defun sysdef-preloaded-system-search (requested)
"If REQUESTED names a system registered as preloaded, return a new system
with its registration information."
(let ((name (coerce-name requested)))
(multiple-value-bind (keys foundp) (gethash name *preloaded-systems*)
(when foundp
(make-preloaded-system name keys)))))
(defun ensure-preloaded-system-registered (name)
"If there isn't a registered _defined_ system of given NAME,
and a there is a registered _preloaded_ system of given NAME,
then define and register said preloaded system."
(if-let (system (and (not (registered-system name)) (sysdef-preloaded-system-search name)))
(register-system system)))
(defun register-preloaded-system (system-name &rest keys &key (version t) &allow-other-keys)
"Register a system as being preloaded. If the system has not been loaded from the filesystem
yet, or if its build information is later cleared with CLEAR-SYSTEM, a dummy system will be
registered without backing filesystem information, based on KEYS (e.g. to provide a VERSION).
If VERSION is the default T, and a system was already loaded, then its version will be preserved."
(let ((name (coerce-name system-name)))
(when (eql version t)
(if-let (system (registered-system name))
(setf (getf keys :version) (component-version system))))
(setf (gethash name *preloaded-systems*) keys)
(ensure-preloaded-system-registered system-name)))
;;; Immutable systems: in the image and can't be reloaded from source.
(defvar *immutable-systems* nil
"A hash-set (equal hash-table mapping keys to T) of systems that are immutable,
i.e. already loaded in memory and not to be refreshed from the filesystem.
They will be treated specially by find-system, and passed as :force-not argument to make-plan.
For instance, to can deliver an image with many systems precompiled, that *will not* check the
filesystem for them every time a user loads an extension, what more risk a problematic upgrade
or catastrophic downgrade, before you dump an image, you may use:
(map () 'asdf:register-immutable-system (asdf:already-loaded-systems))
Note that direct access to this variable from outside ASDF is not supported.
Please call REGISTER-IMMUTABLE-SYSTEM to add new immutable systems, and
contact maintainers if you need a stable API to do more than that.")
(defun sysdef-immutable-system-search (requested)
(let ((name (coerce-name requested)))
(when (and *immutable-systems* (gethash name *immutable-systems*))
(or (registered-system requested)
(error 'formatted-system-definition-error
:format-control "Requested system ~A registered as an immutable-system, ~
but not even registered as defined"
:format-arguments (list name))))))
(defun register-immutable-system (system-name &rest keys)
"Register SYSTEM-NAME as preloaded and immutable.
It will automatically be considered as passed to FORCE-NOT in a plan."
(let ((system-name (coerce-name system-name)))
(apply 'register-preloaded-system system-name keys)
(unless *immutable-systems*
(setf *immutable-systems* (list-to-hash-set nil)))
(setf (gethash system-name *immutable-systems*) t)))
;;; Making systems undefined.
(defun clear-system (system)
"Clear the entry for a SYSTEM in the database of systems previously defined.
However if the system was registered as PRELOADED (which it is if it is IMMUTABLE),
then a new system with the same name will be defined and registered in its place
from which build details will have been cleared.
Note that this does NOT in any way cause any of the code of the system to be unloaded.
Returns T if system was or is now undefined, NIL if a new preloaded system was redefined."
;; There is no "unload" operation in Common Lisp, and
;; a general such operation cannot be portably written,
;; considering how much CL relies on side-effects to global data structures.
(let ((name (coerce-name system)))
(remhash name *defined-systems*)
(unset-asdf-cache-entry `(find-system ,name))
(not (ensure-preloaded-system-registered name))))
(defun clear-defined-systems ()
"Clear all currently registered defined systems.
Preloaded systems (including immutable ones) will be reset, other systems will be de-registered."
(loop :for name :being :the :hash-keys :of *defined-systems*
:unless (member name '("asdf" "uiop") :test 'equal) :do (clear-system name)))
;;; Searching for system definitions
;; For the sake of keeping things reasonably neat, we adopt a convention that
;; only symbols are to be pushed to this list (rather than e.g. function objects),
;; which makes upgrade easier. Also, the name of these symbols shall start with SYSDEF-
(defvar *system-definition-search-functions* '()
"A list that controls the ways that ASDF looks for system definitions.
It contains symbols to be funcalled in order, with a requested system name as argument,
until one returns a non-NIL result (if any), which must then be a fully initialized system object
with that name.")
;; Initialize and/or upgrade the *system-definition-search-functions*
;; so it doesn't contain obsolete symbols, and does contain the current ones.
(defun cleanup-system-definition-search-functions ()
(setf *system-definition-search-functions*
(append
;; Remove known-incompatible sysdef functions from old versions of asdf.
;; Order matters, so we can't just use set-difference.
(let ((obsolete
'(contrib-sysdef-search sysdef-find-asdf sysdef-preloaded-system-search)))
(remove-if #'(lambda (x) (member x obsolete)) *system-definition-search-functions*))
;; Tuck our defaults at the end of the list if they were absent.
;; This is imperfect, in case they were removed on purpose,
;; but then it will be the responsibility of whoever removes these symmbols
;; to upgrade asdf before he does such a thing rather than after.
(remove-if #'(lambda (x) (member x *system-definition-search-functions*))
'(sysdef-central-registry-search
sysdef-source-registry-search)))))
(cleanup-system-definition-search-functions)
;; This (private) function does the search for a system definition using *s-d-s-f*;
;; it is to be called by locate-system.
(defun search-for-system-definition (system)
;; Search for valid definitions of the system available in the current session.
;; Previous definitions as registered in *defined-systems* MUST NOT be considered;
;; they will be reconciled by locate-system then find-system.
;; There are two special treatments: first, specially search for objects being defined
;; in the current session, to avoid definition races between several files;
;; second, specially search for immutable systems, so they cannot be redefined.
;; Finally, use the search functions specified in *system-definition-search-functions*.
(let ((name (coerce-name system)))
(flet ((try (f) (if-let ((x (funcall f name))) (return-from search-for-system-definition x))))
(try 'find-system-if-being-defined)
(try 'sysdef-immutable-system-search)
(map () #'try *system-definition-search-functions*))))
;;; The legacy way of finding a system: the *central-registry*
;; This variable contains a list of directories to be lazily searched for the requested asd
;; by sysdef-central-registry-search.
(defvar *central-registry* nil
"A list of 'system directory designators' ASDF uses to find systems.
A 'system directory designator' is a pathname or an expression
which evaluates to a pathname. For example:
(setf asdf:*central-registry*
(list '*default-pathname-defaults*
#p\"/home/me/cl/systems/\"
#p\"/usr/share/common-lisp/systems/\"))
This variable is for backward compatibility.
Going forward, we recommend new users should be using the source-registry.")
;; Function to look for an asd file of given NAME under a directory provided by DEFAULTS.
;; Return the truename of that file if it is found and TRUENAME is true.
;; Return NIL if the file is not found.
;; On Windows, follow shortcuts to .asd files.
(defun probe-asd (name defaults &key truename)
(block nil
(when (directory-pathname-p defaults)
(if-let (file (probe-file*
(ensure-absolute-pathname
(parse-unix-namestring name :type "asd")
#'(lambda () (ensure-absolute-pathname defaults 'get-pathname-defaults nil))
nil)
:truename truename))
(return file))
#-(or clisp genera) ; clisp doesn't need it, plain genera doesn't have read-sequence(!)
(os-cond
((os-windows-p)
(when (physical-pathname-p defaults)
(let ((shortcut
(make-pathname
:defaults defaults :case :local
:name (strcat name ".asd")
:type "lnk")))
(when (probe-file* shortcut)
(ensure-pathname (parse-windows-shortcut shortcut) :namestring :native)))))))))
;; Function to push onto *s-d-s-f* to use the *central-registry*
(defun sysdef-central-registry-search (system)
(let ((name (primary-system-name system))
(to-remove nil)
(to-replace nil))
(block nil
(unwind-protect
(dolist (dir *central-registry*)
(let ((defaults (eval dir))
directorized)
(when defaults
(cond ((directory-pathname-p defaults)
(let* ((file (probe-asd name defaults :truename *resolve-symlinks*)))
(when file
(return file))))
(t
(restart-case
(let* ((*print-circle* nil)
(message
(format nil
(compatfmt "~@<While searching for system ~S: ~3i~_~S evaluated to ~S which is not an absolute directory.~@:>")
system dir defaults)))
(error message))
(remove-entry-from-registry ()
:report "Remove entry from *central-registry* and continue"
(push dir to-remove))
(coerce-entry-to-directory ()
:test (lambda (c) (declare (ignore c))
(and (not (directory-pathname-p defaults))
(directory-pathname-p
(setf directorized
(ensure-directory-pathname defaults)))))
:report (lambda (s)
(format s (compatfmt "~@<Coerce entry to ~a, replace ~a and continue.~@:>")
directorized dir))
(push (cons dir directorized) to-replace))))))))
;; cleanup
(dolist (dir to-remove)
(setf *central-registry* (remove dir *central-registry*)))
(dolist (pair to-replace)
(let* ((current (car pair))
(new (cdr pair))
(position (position current *central-registry*)))
(setf *central-registry*
(append (subseq *central-registry* 0 position)
(list new)
(subseq *central-registry* (1+ position))))))))))
;;; Methods for find-system
......@@ -386,52 +46,90 @@ Going forward, we recommend new users should be using the source-registry.")
(defclass define-op (non-propagating-operation) ()
(:documentation "An operation to record dependencies on loading a .asd file."))
(defmethod record-dependency ((plan null) (operation t) (component t))
(unless (or (typep operation 'define-op)
(and (typep operation 'load-op)
(typep component 'system)
(equal "asdf" (coerce-name component))))
(let* ((action (first (visiting-action-list *asdf-session*)))
(parent-operation (car action))
(parent-component (cdr action)))
(when (and parent-operation parent-component)
(unless (and (typep parent-operation 'define-op) (typep parent-component 'system))
(error "Invalid recursive use of (OPERATE ~S ~S) while visiting ~S ~
- please use proper dependencies instead."
operation component action))
(push action (definition-dependencies parent-component))))))
(defmethod component-depends-on ((o define-op) (s system))
`((load-op ,@(system-defsystem-depends-on s))
,@(loop* :for (o . c) :in (definition-dependencies s) :collect (list o c))
`(;;NB: 1- ,@(system-defsystem-depends-on s)) ; Should be already included in the below.
;; 2- We don't call-next-method to avoid other methods
,@(loop* :for (o . c) :in (definition-dependencies s) :collect (list o c))))
(defmethod component-depends-on ((o operation) (s system))
`(,@(when (and (not (typep o 'define-op))
(or (system-source-file s) (definition-dependencies s)))
`((define-op ,(primary-system-name s))))
,@(call-next-method)))
(defmethod component-depends-on ((o operation) (c undefined-system))
(defmethod perform ((o operation) (c undefined-system))
(sysdef-error "Trying to use undefined or incompletely defined system ~A" (coerce-name c)))
(defun load-asd (pathname
&key name (external-format (encoding-external-format (detect-encoding pathname)))
&aux (readtable *readtable*) (print-pprint-dispatch *print-pprint-dispatch*))
"Load system definitions from PATHNAME.
NAME if supplied is the name of a system expected to be defined in that file.
;; TODO: could this file be refactored so that locate-system is merely
;; the cache-priming call to input-files here?
(defmethod input-files ((o define-op) (s system))
(assert (equal (coerce-name s) (primary-system-name s)))
(if-let ((asd (system-source-file s))) (list asd)))
Do NOT try to load a .asd file directly with CL:LOAD. Always use ASDF:LOAD-ASD."
(defmethod perform ((o define-op) (s system))
(assert (equal (coerce-name s) (primary-system-name s)))
(nest
(with-asdf-session ())
(if-let ((pathname (first (input-files o s)))))
(with-standard-io-syntax)
(let* ((primary-name (primary-system-name (or name (pathname-name pathname))))
(*package* (find-package :asdf-user))
;; Note that our backward-compatible *readtable* is
;; a global readtable that gets globally side-effected. Ouch.
;; Same for the *print-pprint-dispatch* table.
;; We should do something about that for ASDF3 if possible, or else ASDF4.
(*readtable* readtable)
(*print-pprint-dispatch* print-pprint-dispatch)
(*print-readably* nil)
(*default-pathname-defaults*
;; resolve logical-pathnames so they won't wreak havoc in parsing namestrings.
(pathname-directory-pathname (physicalize-pathname pathname)))
(operation (make-operation 'define-op))
(system (or (registered-system primary-name)
(let ((system
(make-instance 'undefined-system
:name primary-name :source-file pathname)))
(register-system system)
system)))))
(while-visiting-action (operation system))
(let ((*print-readably* nil)
;; Note that our backward-compatible *readtable* is
;; a global readtable that gets globally side-effected. Ouch.
;; Same for the *print-pprint-dispatch* table.
;; We should do something about that for ASDF3 if possible, or else ASDF4.
(*readtable* *readtable*)
(*print-pprint-dispatch* *print-pprint-dispatch*)
(*package* (find-package :asdf-user))
(*default-pathname-defaults*
;; resolve logical-pathnames so they won't wreak havoc in parsing namestrings.
(pathname-directory-pathname (physicalize-pathname pathname)))))
(handler-bind
(((and error (not missing-component))
#'(lambda (condition)
(error 'load-system-definition-error
:name name :pathname pathname :condition condition))))
:name (coerce-name s) :pathname pathname :condition condition))))
(asdf-message (compatfmt "~&~@<; ~@;Loading system definition~@[ for ~A~] from ~A~@:>~%")
name pathname)
(load* pathname :external-format external-format))))
(coerce-name s) pathname)
;; dependencies will depend on what's loaded via definition-dependencies
(unset-asdf-cache-entry `(component-depends-on ,o ,s))
(load* pathname :external-format (encoding-external-format (detect-encoding pathname))))))
(defun load-asd (pathname &key name)
"Load system definitions from PATHNAME.
NAME if supplied is the name of a system expected to be defined in that file.
Do NOT try to load a .asd file directly with CL:LOAD. Always use ASDF:LOAD-ASD."
(with-asdf-session ()
;; TODO: use OPERATE, so we consult the cache and only load once per session.
(flet ((do-it (o c) (operate o c)))
(let ((primary-name (primary-system-name (or name (pathname-name pathname))))
(operation (make-operation 'define-op)))
(if-let (system (registered-system primary-name))
(progn
;; 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)
(do-it operation system))
(let ((system (make-instance 'undefined-system
:name primary-name :source-file pathname)))
(register-system system)
(unwind-protect (do-it operation system)
(when (typep system 'undefined-system)
(clear-system system)))))))))
(defvar *old-asdf-systems* (make-hash-table :test 'equal))
......@@ -446,8 +144,7 @@ Do NOT try to load a .asd file directly with CL:LOAD. Always use ASDF:LOAD-ASD."
(read-file-form version-pathname)))
(old-version (asdf-version)))
(cond
((version< old-version version) t) ;; newer version: good!
((equal old-version version) nil) ;; same version: don't load, but don't warn
((version<= old-version version) t) ;; newer or same version: good!
(t ;; old version: bad
(ensure-gethash
(list (namestring pathname) version) *old-asdf-systems*
......@@ -511,7 +208,7 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(values foundp found-system pathname previous previous-time))))
;; Main method for find-system: first, make sure the computation is memoized in a session cache.
;; unless the system is immutable, use locate-system to find the primary system;
;; Unless the system is immutable, use locate-system to find the primary system;
;; 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.
......@@ -530,26 +227,22 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(register-system found-system))
(when (and system pathname)
(setf (system-source-file system) pathname))
(when (and pathname
(let ((stamp (get-file-stamp pathname)))
(and stamp
(not (and previous
(or (pathname-equal pathname previous-pathname)
(and pathname previous-pathname
(pathname-equal
(physicalize-pathname pathname)
(physicalize-pathname previous-pathname))))
(stamp<= stamp previous-time))))))
;; Only load when it's a pathname that is different or has newer content.
(load-asd pathname :name name)))
(if-let ((stamp (get-file-stamp pathname)))
(let ((up-to-date-p
(and previous
(or (pathname-equal pathname previous-pathname)
(and pathname previous-pathname
(pathname-equal
(physicalize-pathname pathname)
(physicalize-pathname previous-pathname))))
(stamp<= stamp previous-time)
;; TODO: check that all dependencies are up-to-date.
;; This necessitates traversing them without triggering
;; the adding of nodes to the plan.
)))
(unless up-to-date-p
(load-asd pathname :name name)))))
;; Try again after having loaded from disk if needed
(let ((in-memory (system-registered-p name)))
(cond
(in-memory
(when pathname
(setf (car in-memory) (get-file-stamp pathname)))
(cdr in-memory))
(error-p
(error 'missing-component :requires name))
(t
(return-from find-system nil)))))))))
(or (registered-system name)
(when error-p (error 'missing-component :requires name))))))))
......@@ -4,7 +4,7 @@
(uiop/package:define-package :asdf/footer
(:recycle :asdf/footer :asdf)
(:use :uiop/common-lisp :uiop
:asdf/upgrade :asdf/find-system :asdf/operate :asdf/bundle)
:asdf/upgrade :asdf/system-registry :asdf/operate :asdf/bundle)
;; Happily, all those implementations all have the same module-provider hook interface.
#+(or abcl clasp cmucl clozure ecl mkcl sbcl)
(:import-from #+abcl :sys #+(or clasp cmucl ecl) :ext #+clozure :ccl #+mkcl :mk-ext #+sbcl sb-ext
......
......@@ -8,7 +8,7 @@
#:loaded-systems ; makes for annoying SLIME completion
#:output-files-for-system-and-operation) ; ASDF-BINARY-LOCATION function we use to detect ABL
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
:asdf/component :asdf/system :asdf/find-system :asdf/find-component
:asdf/component :asdf/system :asdf/system-registry :asdf/find-system :asdf/find-component
:asdf/operation :asdf/action :asdf/lisp-action
:asdf/output-translations :asdf/source-registry
:asdf/plan :asdf/operate :asdf/parse-defsystem :asdf/bundle :asdf/concatenate-source
......
......@@ -4,8 +4,7 @@
(uiop/package:define-package :asdf/lisp-action
(:recycle :asdf/lisp-action :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
:asdf/component :asdf/system :asdf/find-system
:asdf/operation :asdf/action)
:asdf/component :asdf/system :asdf/operation :asdf/action)
(:export
#:try-recompiling
#:cl-source-file #:cl-source-file.cl #:cl-source-file.lsp
......
......@@ -5,7 +5,7 @@
set here=%~dp0
set header_lisp=header.lisp
set driver_lisp=uiop\package.lisp + uiop\common-lisp.lisp + uiop\utility.lisp + uiop\version.lisp + uiop\os.lisp + uiop\pathname.lisp + uiop\filesystem.lisp + uiop\stream.lisp + uiop\image.lisp + uiop\lisp-build.lisp + uiop\launch-program.lisp + uiop\run-program.lisp + uiop\configuration.lisp + uiop\backward-driver.lisp + uiop\driver.lisp
set defsystem_lisp=upgrade.lisp + session.lisp + component.lisp + operation.lisp + system.lisp + action.lisp + find-system.lisp + find-component.lisp + lisp-action.lisp + plan.lisp + operate.lisp + parse-defsystem.lisp + bundle.lisp + concatenate-source.lisp + package-inferred-system.lisp + output-translations.lisp + source-registry.lisp + backward-internals.lisp + backward-interface.lisp + interface.lisp + user.lisp + footer.lisp
set defsystem_lisp=upgrade.lisp + session.lisp + component.lisp + operation.lisp + system.lisp + system-registry.lisp + action.lisp + lisp-action.lisp + find-component.lisp + plan.lisp + operate.lisp + find-system.lisp + parse-defsystem.lisp + bundle.lisp + concatenate-source.lisp + package-inferred-system.lisp + output-translations.lisp + source-registry.lisp + backward-internals.lisp + backward-interface.lisp + interface.lisp + user.lisp + footer.lisp
%~d0
cd "%~p0"
......
......@@ -6,7 +6,7 @@ here="$(dirname $0)"
header_lisp="header.lisp"
driver_lisp="uiop/package.lisp uiop/common-lisp.lisp uiop/utility.lisp uiop/version.lisp uiop/os.lisp uiop/pathname.lisp uiop/filesystem.lisp uiop/stream.lisp uiop/image.lisp uiop/lisp-build.lisp uiop/launch-program.lisp uiop/run-program.lisp uiop/configuration.lisp uiop/backward-driver.lisp uiop/driver.lisp"
defsystem_lisp="upgrade.lisp session.lisp component.lisp operation.lisp system.lisp action.lisp find-system.lisp find-component.lisp lisp-action.lisp plan.lisp operate.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp package-inferred-system.lisp output-translations.lisp source-registry.lisp backward-internals.lisp backward-interface.lisp interface.lisp user.lisp footer.lisp"
defsystem_lisp="upgrade.lisp session.lisp component.lisp operation.lisp system.lisp system-registry.lisp action.lisp lisp-action.lisp find-component.lisp plan.lisp operate.lisp find-system.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp package-inferred-system.lisp output-translations.lisp source-registry.lisp backward-internals.lisp backward-interface.lisp interface.lisp user.lisp footer.lisp"
all () {
# Default action: bootstrap asdf.lisp
......
......@@ -4,14 +4,12 @@
(uiop/package:define-package :asdf/operate
(:recycle :asdf/operate :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
:asdf/component :asdf/system :asdf/operation :asdf/action
:asdf/find-system :asdf/find-component :asdf/lisp-action :asdf/plan)
:asdf/component :asdf/system :asdf/system-registry :asdf/find-component
:asdf/operation :asdf/action :asdf/lisp-action :asdf/plan)
(:export
#:operate #:oos
#:build-op #:make
#:operate #:oos #:build-op #:make
#:load-system #:load-systems #:load-systems*
#:compile-system #:test-system #:require-system
#:module-provide-asdf
#:compile-system #:test-system #:require-system #:module-provide-asdf
#:component-loaded-p #:already-loaded-systems))
(in-package :asdf/operate)
......
......@@ -5,7 +5,7 @@
(:recycle :asdf/package-inferred-system :asdf/package-system :asdf)
(:use :uiop/common-lisp :uiop
:asdf/upgrade :asdf/session
:asdf/component :asdf/system :asdf/find-system :asdf/lisp-action
:asdf/component :asdf/system :asdf/system-registry :asdf/lisp-action
:asdf/parse-defsystem)
(:export
#:package-inferred-system #:sysdef-package-inferred-system-search
......
......@@ -5,8 +5,8 @@
(:recycle :asdf/parse-defsystem :asdf/defsystem :asdf)
(:nicknames :asdf/defsystem) ;; previous name, to be compatible with, in case anyone cares
(:use :uiop/common-lisp :asdf/driver :asdf/upgrade
:asdf/session :asdf/component :asdf/system
:asdf/find-system :asdf/find-component :asdf/action :asdf/lisp-action :asdf/operate)
:asdf/session :asdf/component :asdf/system :asdf/system-registry
:asdf/find-component :asdf/action :asdf/lisp-action :asdf/operate)
(:import-from :asdf/system #:depends-on #:weakly-depends-on)
(:export
#:defsystem #:register-system-definition
......
......@@ -6,8 +6,8 @@
;; that used to live there before 3.2.0.
(:recycle :asdf/plan :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
:asdf/component :asdf/operation :asdf/action :asdf/lisp-action :asdf/system
:asdf/find-component :asdf/find-system)
:asdf/component :asdf/operation :asdf/action :asdf/lisp-action
:asdf/system :asdf/system-registry :asdf/find-component)
(:export
#:component-operation-time
#:plan #:plan-traversal #:sequential-plan #:*plan-class*
......@@ -48,7 +48,7 @@
(:documentation "Returns the ACTION-STATUS associated to
the action of OPERATION on COMPONENT in the PLAN"))
(defgeneric (setf action-status) (new-status session operation component)
(defgeneric (setf action-status) (new-status plan operation component)
(:documentation "Sets the ACTION-STATUS associated to
the action of OPERATION on COMPONENT in the PLAN"))
......@@ -285,17 +285,7 @@ initialized with SEED."
(values (gethash (cons o c) (visited-actions *asdf-session*)))))
(defgeneric record-dependency (plan operation component)
(:documentation "Record an action as a dependency in the current plan"))
(defmethod record-dependency ((plan null) (operation t) (component t))
(let* ((action (first (visiting-action-list *asdf-session*)))
(parent-operation (action-operation action))
(parent-component (action-component action)))
(when (and parent-operation parent-component)
(unless (and (typep parent-operation 'define-op) (typep parent-component 'system))
(cerror "Invalid recursive use of (OPERATE ~S ~S) while visiting ~S"
operation component action))
(push action (definition-dependencies parent-component))))))
(:documentation "Record an action as a dependency in the current plan")))
;;;; Actual traversal: traverse-action
......@@ -420,15 +410,12 @@ initialized with SEED."
(with-compilation-unit () ;; backward-compatibility.
(call-next-method)))) ;; Going forward, see deferred-warning support in lisp-build.
(defmethod perform-plan ((plan t) &rest keys &key &allow-other-keys)
(apply 'perform-plan (plan-actions plan) keys))
(defmethod perform-plan ((steps list) &key force &allow-other-keys)
(loop :for action :in steps
(defmethod perform-plan ((plan t) &key &allow-other-keys)
(loop :for action :in (plan-actions plan)
:as o = (action-operation action)
:as c = (action-component action)
:when (or force (not (nth-value 1 (compute-action-stamp nil o c))))
:do (perform-with-restarts o c)))
:as c = (action-component action) :do
(unless (nth-value 1 (compute-action-stamp plan o c))
(perform-with-restarts o c))))
(defmethod plan-operates-on-p ((plan plan-traversal) (component-path list))
(plan-operates-on-p (plan-actions plan) component-path))
......
......@@ -4,7 +4,7 @@
(uiop/package:define-package :asdf/source-registry
(:recycle :asdf/source-registry :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/find-system)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/system :asdf/system-registry)
(:export
#:*source-registry-parameter* #:*default-source-registries*
#:invalid-source-registry
......
;;;; -------------------------------------------------------------------------
;;;; Finding systems
(uiop/package:define-package :asdf/system-registry
(:recycle :asdf/system-registry :asdf/find-system :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
:asdf/session :asdf/component :asdf/system)
(:export
#:remove-entry-from-registry #:coerce-entry-to-directory
#:system-registered-p #:registered-system #:register-system
#:registered-systems* #:registered-systems
#:clear-system #:map-systems
#:*system-definition-search-functions* #:search-for-system-definition
#:*central-registry* #:probe-asd #:sysdef-central-registry-search
#:find-system-if-being-defined
#:contrib-sysdef-search #:sysdef-find-asdf ;; backward compatibility symbols, functions removed
#:sysdef-preloaded-system-search #:register-preloaded-system #:*preloaded-systems*
#:mark-component-preloaded ;; forward reference to asdf/operate
#:sysdef-immutable-system-search #:register-immutable-system #:*immutable-systems*
#:*defined-systems* #:clear-defined-systems
;; defined in source-registry, but specially mentioned here:
#:sysdef-source-registry-search))
(in-package :asdf/system-registry)
(with-upgradability ()
;;; Registry of Defined Systems
(defvar *defined-systems* (make-hash-table :test 'equal)
"This is a hash table whose keys are strings -- the
names of systems -- and whose values are pairs, the first
element of which is a universal-time indicating when the
system definition was last updated, and the second element
of which is a system object.
A system is referred to as \"registered\" if it is present
in this table.")
(defun system-registered-p (name)
"Return a generalized boolean that is true if a system of given NAME was registered already.
NAME is a system designator, to be normalized by COERCE-NAME.
The value returned if true is a pair of a timestamp and a system object."
(gethash (coerce-name name) *defined-systems*))
(defun registered-system (name)
"Return a system of given NAME that was registered already,
if such a system exists. NAME is a system designator, to be
normalized by COERCE-NAME. The value returned is a system object,
or NIL if not found."
(cdr (system-registered-p name)))
(defun registered-systems* ()
"Return a list containing every registered system (as a system object)."
(loop :for registered :being :the :hash-values :of *defined-systems*
:collect (cdr registered)))
(defun registered-systems ()
"Return a list of the names of every registered system."
(mapcar 'coerce-name (registered-systems*)))
(defun register-system (system)
"Given a SYSTEM object, register it."
(check-type system system)
(let ((name (component-name system)))
(check-type name string)
(asdf-message (compatfmt "~&~@<; ~@;Registering system ~3i~_~A~@:>~%") name)
(unless (eq system (registered-system name))
(setf (gethash name *defined-systems*)
(cons (ignore-errors (get-file-stamp (system-source-file system)))
system)))))
(defun map-systems (fn)
"Apply FN to each defined system.
FN should be a function of one argument. It will be
called with an object of type asdf:system."
(loop :for registered :being :the :hash-values :of *defined-systems*
:do (funcall fn (cdr registered))))
;;; Preloaded systems: in the image even if you can't find source files backing them.
(defvar *preloaded-systems* (make-hash-table :test 'equal)
"Registration table for preloaded systems.")
(declaim (ftype (function (t) t) mark-component-preloaded)) ; defined in asdf/operate
(defun make-preloaded-system (name keys)
"Make a preloaded system of given NAME with build information from KEYS"
(let ((system (apply 'make-instance (getf keys :class 'system)
:name name :source-file (getf keys :source-file)
(remove-plist-keys '(:class :name :source-file) keys))))
(mark-component-preloaded system)
system))
(defun sysdef-preloaded-system-search (requested)
"If REQUESTED names a system registered as preloaded, return a new system
with its registration information."
(let ((name (coerce-name requested)))
(multiple-value-bind (keys foundp) (gethash name *preloaded-systems*)
(when foundp
(make-preloaded-system name keys)))))
(defun ensure-preloaded-system-registered (name)
"If there isn't a registered _defined_ system of given NAME,
and a there is a registered _preloaded_ system of given NAME,
then define and register said preloaded system."
(if-let (system (and (not (registered-system name)) (sysdef-preloaded-system-search name)))
(register-system system)))
(defun register-preloaded-system (system-name &rest keys &key (version t) &allow-other-keys)
"Register a system as being preloaded. If the system has not been loaded from the filesystem
yet, or if its build information is later cleared with CLEAR-SYSTEM, a dummy system will be
registered without backing filesystem information, based on KEYS (e.g. to provide a VERSION).
If VERSION is the default T, and a system was already loaded, then its version will be preserved."
(let ((name (coerce-name system-name)))
(when (eql version t)
(if-let (system (registered-system name))
(setf (getf keys :version) (component-version system))))
(setf (gethash name *preloaded-systems*) keys)
(ensure-preloaded-system-registered system-name)))
;;; Immutable systems: in the image and can't be reloaded from source.
(defvar *immutable-systems* nil
"A hash-set (equal hash-table mapping keys to T) of systems that are immutable,
i.e. already loaded in memory and not to be refreshed from the filesystem.
They will be treated specially by find-system, and passed as :force-not argument to make-plan.
For instance, to can deliver an image with many systems precompiled, that *will not* check the
filesystem for them every time a user loads an extension, what more risk a problematic upgrade
or catastrophic downgrade, before you dump an image, you may use:
(map () 'asdf:register-immutable-system (asdf:already-loaded-systems))
Note that direct access to this variable from outside ASDF is not supported.
Please call REGISTER-IMMUTABLE-SYSTEM to add new immutable systems, and
contact maintainers if you need a stable API to do more than that.")
(defun sysdef-immutable-system-search (requested)
(let ((name (coerce-name requested)))
(when (and *immutable-systems* (gethash name *immutable-systems*))
(or (registered-system requested)
(error 'formatted-system-definition-error
:format-control "Requested system ~A registered as an immutable-system, ~
but not even registered as defined"
:format-arguments (list name))))))
(defun register-immutable-system (system-name &rest keys)
"Register SYSTEM-NAME as preloaded and immutable.
It will automatically be considered as passed to FORCE-NOT in a plan."
(let ((system-name (coerce-name system-name)))
(apply 'register-preloaded-system system-name keys)
(unless *immutable-systems*
(setf *immutable-systems* (list-to-hash-set nil)))
(setf (gethash system-name *immutable-systems*) t)))
;;; Making systems undefined.
(defun clear-system (system)
"Clear the entry for a SYSTEM in the database of systems previously defined.
However if the system was registered as PRELOADED (which it is if it is IMMUTABLE),
then a new system with the same name will be defined and registered in its place
from which build details will have been cleared.
Note that this does NOT in any way cause any of the code of the system to be unloaded.
Returns T if system was or is now undefined, NIL if a new preloaded system was redefined."
;; There is no "unload" operation in Common Lisp, and
;; a general such operation cannot be portably written,
;; considering how much CL relies on side-effects to global data structures.
(let ((name (coerce-name system)))
(remhash name *defined-systems*)
(unset-asdf-cache-entry `(find-system ,name))
(not (ensure-preloaded-system-registered name))))
(defun clear-defined-systems ()
"Clear all currently registered defined systems.
Preloaded systems (including immutable ones) will be reset, other systems will be de-registered."
(loop :for name :being :the :hash-keys :of *defined-systems* :do (clear-system name)))
;;; Searching for system definitions
;; For the sake of keeping things reasonably neat, we adopt a convention that
;; only symbols are to be pushed to this list (rather than e.g. function objects),
;; which makes upgrade easier. Also, the name of these symbols shall start with SYSDEF-
(defvar *system-definition-search-functions* '()
"A list that controls the ways that ASDF looks for system definitions.
It contains symbols to be funcalled in order, with a requested system name as argument,
until one returns a non-NIL result (if any), which must then be a fully initialized system object
with that name.")
;; Initialize and/or upgrade the *system-definition-search-functions*
;; so it doesn't contain obsolete symbols, and does contain the current ones.
(defun cleanup-system-definition-search-functions ()
(setf *system-definition-search-functions*
(append
;; Remove known-incompatible sysdef functions from old versions of asdf.
;; Order matters, so we can't just use set-difference.
(let ((obsolete
'(contrib-sysdef-search sysdef-find-asdf sysdef-preloaded-system-search)))
(remove-if #'(lambda (x) (member x obsolete)) *system-definition-search-functions*))
;; Tuck our defaults at the end of the list if they were absent.
;; This is imperfect, in case they were removed on purpose,
;; but then it will be the responsibility of whoever removes these symmbols
;; to upgrade asdf before he does such a thing rather than after.
(remove-if #'(lambda (x) (member x *system-definition-search-functions*))
'(sysdef-central-registry-search
sysdef-source-registry-search)))))
(cleanup-system-definition-search-functions)
;; This (private) function does the search for a system definition using *s-d-s-f*;
;; it is to be called by locate-system.
(defun search-for-system-definition (system)
;; Search for valid definitions of the system available in the current session.
;; Previous definitions as registered in *defined-systems* MUST NOT be considered;
;; they will be reconciled by locate-system then find-system.
;; There are two special treatments: first, specially search for objects being defined
;; in the current session, to avoid definition races between several files;
;; second, specially search for immutable systems, so they cannot be redefined.
;; Finally, use the search functions specified in *system-definition-search-functions*.
(let ((name (coerce-name system)))
(flet ((try (f) (if-let ((x (funcall f name))) (return-from search-for-system-definition x))))
(try 'find-system-if-being-defined)
(try 'sysdef-immutable-system-search)
(map () #'try *system-definition-search-functions*))))
;;; The legacy way of finding a system: the *central-registry*
;; This variable contains a list of directories to be lazily searched for the requested asd
;; by sysdef-central-registry-search.
(defvar *central-registry* nil
"A list of 'system directory designators' ASDF uses to find systems.
A 'system directory designator' is a pathname or an expression
which evaluates to a pathname. For example:
(setf asdf:*central-registry*
(list '*default-pathname-defaults*
#p\"/home/me/cl/systems/\"
#p\"/usr/share/common-lisp/systems/\"))
This variable is for backward compatibility.
Going forward, we recommend new users should be using the source-registry.")
;; Function to look for an asd file of given NAME under a directory provided by DEFAULTS.
;; Return the truename of that file if it is found and TRUENAME is true.
;; Return NIL if the file is not found.
;; On Windows, follow shortcuts to .asd files.
(defun probe-asd (name defaults &key truename)
(block nil
(when (directory-pathname-p defaults)
(if-let (file (probe-file*
(ensure-absolute-pathname
(parse-unix-namestring name :type "asd")
#'(lambda () (ensure-absolute-pathname defaults 'get-pathname-defaults nil))
nil)
:truename truename))
(return file))
#-(or clisp genera) ; clisp doesn't need it, plain genera doesn't have read-sequence(!)
(os-cond
((os-windows-p)
(when (physical-pathname-p defaults)
(let ((shortcut
(make-pathname
:defaults defaults :case :local
:name (strcat name ".asd")
:type "lnk")))
(when (probe-file* shortcut)
(ensure-pathname (parse-windows-shortcut shortcut) :namestring :native)))))))))
;; Function to push onto *s-d-s-f* to use the *central-registry*
(defun sysdef-central-registry-search (system)
(let ((name (primary-system-name system))
(to-remove nil)
(to-replace nil))
(block nil
(unwind-protect
(dolist (dir *central-registry*)
(let ((defaults (eval dir))
directorized)
(when defaults
(cond ((directory-pathname-p defaults)
(let* ((file (probe-asd name defaults :truename *resolve-symlinks*)))
(when file
(return file))))
(t
(restart-case
(let* ((*print-circle* nil)
(message
(format nil
(compatfmt "~@<While searching for system ~S: ~3i~_~S evaluated to ~S which is not an absolute directory.~@:>")
system dir defaults)))
(error message))
(remove-entry-from-registry ()
:report "Remove entry from *central-registry* and continue"
(push dir to-remove))
(coerce-entry-to-directory ()
:test (lambda (c) (declare (ignore c))
(and (not (directory-pathname-p defaults))
(directory-pathname-p
(setf directorized
(ensure-directory-pathname defaults)))))
:report (lambda (s)
(format s (compatfmt "~@<Coerce entry to ~a, replace ~a and continue.~@:>")
directorized dir))
(push (cons dir directorized) to-replace))))))))
;; cleanup
(dolist (dir to-remove)
(setf *central-registry* (remove dir *central-registry*)))
(dolist (pair to-replace)
(let* ((current (car pair))
(new (cdr pair))
(position (position current *central-registry*)))
(setf *central-registry*
(append (subseq *central-registry* 0 position)
(list new)
(subseq *central-registry* (1+ position)))))))))))
......@@ -2,8 +2,8 @@
;;;; Systems
(uiop/package:define-package :asdf/system
(:recycle :asdf :asdf/system)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/component)
(:recycle :asdf :asdf/system :asdf/find-system)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session :asdf/component)
(:export
#:system #:proto-system #:undefined-system #:reset-system
#:system-source-file #:system-source-directory #:system-relative-pathname
......@@ -18,6 +18,7 @@
#:mailto #:system-mailto
#:long-name #:system-long-name
#:source-control #:system-source-control
#:coerce-name #:primary-system-name #:coerce-filename
#:find-system #:builtin-system-p)) ;; forward-reference, defined in find-system
(in-package :asdf/system)
......@@ -106,6 +107,33 @@ based on supplied KEYS."
(apply 'reinitialize-instance system keys)))
;;; Canonicalizing system names
(with-upgradability ()
(defun coerce-name (name)
"Given a designator for a component NAME, return the name as a string.
The designator can be a COMPONENT (designing its name; note that a SYSTEM is a component),
a SYMBOL (designing its name, downcased), or a STRING (designing itself)."
(typecase name
(component (component-name name))
(symbol (string-downcase name))
(string name)
(t (sysdef-error (compatfmt "~@<Invalid component designator: ~3i~_~A~@:>") name))))
(defun primary-system-name (name)
"Given a system designator NAME, return the name of the corresponding primary system,
after which the .asd file is named. That's the first component when dividing the name
as a string by / slashes."
(first (split-string (coerce-name name) :separator "/")))
(defun coerce-filename (name)
"Coerce a system designator NAME into a string suitable as a filename component.
The (current) transformation is to replace characters /:\\ each by --,
the former being forbidden in a filename component.
NB: The onus is unhappily on the user to avoid clashes."
(frob-substrings (coerce-name name) '("/" ":" "\\") "--")))
;;;; Pathnames
(with-upgradability ()
......
;;; -*- Lisp -*-
(asdf:defsystem file3-only
:components ((:file "file3")))
(defvar *file3-only-asd-loaded* 0)
(incf *file3-only-asd-loaded*)
(in-package :test-package)
(assert *file3*)
(defparameter *file4* t)
(defpackage :test-asdf-system
(:use :cl :asdf))
(:use :cl :asdf :uiop))
(in-package :test-asdf-system)
(defvar *times-loaded* 0)
(incf *times-loaded*)
;;(format! t "Times that test-asdf.asd was loaded: ~D~%" *times-loaded*)
(defsystem :test-asdf :class package-inferred-system)
......@@ -75,7 +76,10 @@
(defsystem :test-asdf/force
:depends-on (:test-asdf/force1)
:components ((:file "file3")))
:components ((:file "file4")))
(defsystem :test-asdf/force1
;; Importantly, this depends on a system that is NOT defined in the same file,
;; so that we can check that forcing causes one file to be reloaded but not the other.
:depends-on (:file3-only)
:components ((:file "file1")))
;;; -*- Lisp -*-
;;; test to check that the cache doesn't upset error signaling from FIND-SYSTEM
;;; Test to check that the cache doesn't upset error signaling from FIND-SYSTEM
(in-package :asdf-test)
(defparameter *all-systems*
(list
"test-asdf"
"test-asdf/all"
"test-asdf/1"
"test-asdf/2"
"test-asdf/4"
"test-asdf/test9-1"
"test-asdf/test-module-depend"
"test-asdf/test9-2"
"test-asdf/test9-3"
"test-asdf/test-source-directory-1"
"test-asdf/test-source-directory-2"
"test-asdf/bundle-1"
"test-asdf/bundle-2"
"test-asdf/force"
"test-asdf/force1"))
(setf asdf::*asdf-session* nil)
(setf *central-registry* nil)
(asdf::clear-defined-systems)
(defun clear-caches-and-search ()
(setf asdf:*central-registry* nil)
(mapc #'clear-system *all-systems*))
(clear-caches-and-search)
(assert (not (asdf:find-system "test-asdf/force1" nil)))
(multiple-value-bind (ret cond)
(ignore-errors (asdf:find-system "test-asdf/force1" t))
(assert (not ret))
(assert (typep cond 'asdf:missing-component)))
(assert-equal nil (find-system "test-asdf/force1" nil))
(errors missing-component (find-system "test-asdf/force1" t))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment