2 (eval-when (:compile-toplevel
:load-toplevel
:execute
) (require :uiop
))
3 ;;;; -------------------------------------------------------------------------
4 ;;;; Handle upgrade as forward- and backward-compatibly as possible
5 ;; See https://bugs.launchpad.net/asdf/+bug/485687
7 (uiop/package
:define-package
:asdf
/upgrade
8 (:recycle
:asdf
/upgrade
:asdf
)
9 (:use
:uiop
/common-lisp
:uiop
)
11 #:asdf-version
#:*previous-asdf-versions
* #:*asdf-version
*
12 #:asdf-message
#:*verbose-out
*
13 #:upgrading-p
#:when-upgrading
#:upgrade-asdf
#:asdf-upgrade-error
#:defparameter
*
14 #:*post-upgrade-cleanup-hook
* #:*post-upgrade-restart-hook
* #:cleanup-upgraded-asdf
15 ;; There will be no symbol left behind!
17 (:import-from
:uiop
/package
#:intern
* #:find-symbol
*))
18 (in-package :asdf
/upgrade
)
20 ;;; Special magic to detect if this is an upgrade
22 (with-upgradability ()
23 (defun asdf-version ()
24 "Exported interface to the version of ASDF currently installed. A string.
25 You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSION) \"3.4.5.67\")."
26 (when (find-package :asdf
)
27 (or (symbol-value (find-symbol (string :*asdf-version
*) :asdf
))
28 (let* ((revsym (find-symbol (string :*asdf-revision
*) :asdf
))
29 (rev (and revsym
(boundp revsym
) (symbol-value revsym
))))
32 (cons (format nil
"~{~D~^.~}" rev
))
34 ;; Important: define *p-a-v* /before/ *a-v* so that it initializes correctly.
35 (defvar *previous-asdf-versions
* (if-let (previous (asdf-version)) (list previous
)))
36 (defvar *asdf-version
* nil
)
37 ;; We need to clear systems from versions yet older than the below:
38 (defparameter *oldest-forward-compatible-asdf-version
* "2.33") ;; 2.32.13 renames a slot in component.
39 (defvar *verbose-out
* nil
)
40 (defun asdf-message (format-string &rest format-args
)
41 (when *verbose-out
* (apply 'format
*verbose-out
* format-string format-args
)))
42 (defvar *post-upgrade-cleanup-hook
* ())
43 (defvar *post-upgrade-restart-hook
* ())
44 (defun upgrading-p (&optional
(oldest-compatible-version *oldest-forward-compatible-asdf-version
*))
45 (and *previous-asdf-versions
*
46 (version< (first *previous-asdf-versions
*) oldest-compatible-version
)))
47 (defmacro defparameter
* (var value
&optional docstring
(version *oldest-forward-compatible-asdf-version
*))
48 (let* ((name (string-trim "*" var
))
49 (valfun (intern (format nil
"%~A-~A-~A" :compute name
:value
))))
51 (defun ,valfun
() ,value
)
52 (defvar ,var
(,valfun
) ,@(ensure-list docstring
))
53 (when (upgrading-p ,version
)
54 (setf ,var
(,valfun
))))))
55 (defmacro when-upgrading
((&key
(version *oldest-forward-compatible-asdf-version
*)
56 (upgrading-p `(upgrading-p ,version
)) when
) &body body
)
57 "A wrapper macro for code that should only be run when upgrading a
58 previously-loaded version of ASDF."
59 `(with-upgradability ()
60 (when (and ,upgrading-p
,@(when when
`(,when
)))
61 (handler-bind ((style-warning #'muffle-warning
))
62 (eval '(progn ,@body
))))))
63 (let* (;; For bug reporting sanity, please always bump this version when you modify this file.
64 ;; Please also modify asdf.asd to reflect this change. make bump-version v=3.4.5.67.8
65 ;; can help you do these changes in synch (look at the source for documentation).
66 ;; Relying on its automation, the version is now redundantly present on top of asdf.lisp.
67 ;; "3.4" would be the general branch for major version 3, minor version 4.
68 ;; "3.4.5" would be an official release in the 3.4 branch.
69 ;; "3.4.5.67" would be a development version in the official branch, on top of 3.4.5.
70 ;; "3.4.5.0.8" would be your eighth local modification of official release 3.4.5
71 ;; "3.4.5.67.8" would be your eighth local modification of development version 3.4.5.67
72 (asdf-version "3.1.5")
73 (existing-version (asdf-version)))
74 (setf *asdf-version
* asdf-version
)
75 (when (and existing-version
(not (equal asdf-version existing-version
)))
76 (push existing-version
*previous-asdf-versions
*)
77 (when (or *verbose-out
* *load-verbose
*)
78 (format (or *verbose-out
* *trace-output
*)
79 (compatfmt "~&~@<; ~@;Upgrading ASDF ~@[from version ~A ~]to version ~A~@:>~%")
80 existing-version asdf-version
)))))
83 (let ((redefined-functions ;; gf signature and/or semantics changed incompatibly. Oops.
84 ;; NB: it's too late to do anything about functions in UIOP!
85 ;; If you introduce some critically incompatibility there, you must change name.
86 '(#:component-relative-pathname
#:component-parent-pathname
;; component
88 #:find-system
#:system-source-file
#:system-relative-pathname
;; system
89 #:find-component
;; find-component
90 #:explain
#:perform
#:perform-with-restarts
#:input-files
#:output-files
;; action
91 #:component-depends-on
#:operation-done-p
#:component-depends-on
92 #:traverse
;; backward-interface
93 #:map-direct-dependencies
#:reduce-direct-dependencies
#:direct-dependencies
;; plan
95 #:parse-component-form
;; defsystem
96 #:apply-output-translations
;; output-translations
97 #:process-output-translations-directive
98 #:inherit-source-registry
#:process-source-registry
;; source-registry
99 #:process-source-registry-directive
100 #:trivial-system-p
)) ;; bundle
102 ;; redefining the classes causes interim circularities
103 ;; with the old ASDF during upgrade, and many implementations bork
104 '((#:compile-concatenated-source-op
(#:operation
) ()))))
105 (loop :for name
:in redefined-functions
106 :for sym
= (find-symbol* name
:asdf nil
) :do
108 ;; On CLISP we seem to be unable to fmakunbound and define a function in the same fasl. Sigh.
109 #-clisp
(fmakunbound sym
)))
110 (labels ((asym (x) (multiple-value-bind (s p
) (if (consp x
) (values (car x
) (cadr x
)) (values x
:asdf
))
111 (find-symbol* s p nil
)))
112 (asyms (l) (mapcar #'asym l
)))
113 (loop* :for
(name superclasses slots
) :in redefined-classes
114 :for sym
= (find-symbol* name
:asdf nil
)
115 :when
(and sym
(find-class sym
))
116 :do
(eval `(defclass ,sym
,(asyms superclasses
) ,(asyms slots
)))))))
119 ;;; Self-upgrade functions
121 (with-upgradability ()
122 (defun asdf-upgrade-error ()
123 ;; Important notice for whom it concerns. The crux of the matter is that
124 ;; TRAVERSE can be completely refactored, and so after the find-system returns, it's too late.
125 (error "When a system transitively depends on ASDF, it must :defsystem-depends-on (:asdf)~%~
126 Otherwise, when you upgrade from ASDF 2, you must do it before you operate on any system.~%"))
128 (defun cleanup-upgraded-asdf (&optional
(old-version (first *previous-asdf-versions
*)))
129 (let ((new-version (asdf-version)))
130 (unless (equal old-version new-version
)
131 (push new-version
*previous-asdf-versions
*)
133 (if (version<= new-version old-version
)
134 (error (compatfmt "~&~@<; ~@;Downgraded ASDF from version ~A to version ~A~@:>~%")
135 old-version new-version
)
136 (asdf-message (compatfmt "~&~@<; ~@;Upgraded ASDF from version ~A to version ~A~@:>~%")
137 old-version new-version
))
138 ;; In case the previous version was too old to be forward-compatible, clear systems.
139 ;; TODO: if needed, we may have to define a separate hook to run
140 ;; in case of forward-compatible upgrade.
141 ;; Or to move the tests forward-compatibility test inside each hook function?
142 (unless (version<= *oldest-forward-compatible-asdf-version
* old-version
)
143 (call-functions (reverse *post-upgrade-cleanup-hook
*)))
146 (defun upgrade-asdf ()
147 "Try to upgrade of ASDF. If a different version was used, return T.
148 We need do that before we operate on anything that may possibly depend on ASDF."
149 (let ((*load-print
* nil
)
150 (*compile-print
* nil
))
151 (handler-bind (((or style-warning
) #'muffle-warning
))
152 (symbol-call :asdf
:load-system
:asdf
:verbose nil
))))
154 (register-hook-function '*post-upgrade-cleanup-hook
* 'upgrade-configuration
))
156 ;;;; -------------------------------------------------------------------------
159 (uiop/package
:define-package
:asdf
/component
160 (:recycle
:asdf
/component
:asdf
/defsystem
:asdf
/find-system
:asdf
)
161 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
)
163 #:component
#:component-find-path
164 #:component-name
#:component-pathname
#:component-relative-pathname
165 #:component-parent
#:component-system
#:component-parent-pathname
166 #:child-component
#:parent-component
#:module
168 #:source-file
#:c-source-file
#:java-source-file
169 #:static-file
#:doc-file
#:html-file
171 #:source-file-type
#:source-file-explicit-type
;; backward-compatibility
172 #:component-in-order-to
#:component-sideway-dependencies
173 #:component-if-feature
#:around-compile-hook
174 #:component-description
#:component-long-description
175 #:component-version
#:version-satisfies
176 #:component-inline-methods
;; backward-compatibility only. DO NOT USE!
177 #:component-operation-times
;; For internal use only.
178 ;; portable ASDF encoding and implementation-specific external-format
179 #:component-external-format
#:component-encoding
180 #:component-children-by-name
#:component-children
#:compute-children-by-name
181 #:component-build-operation
182 #:module-default-component-class
183 #:module-components
;; backward-compatibility. DO NOT USE.
187 #:system-definition-error
;; top level, moved here because this is the earliest place for it.
190 ;; Internals we'd like to share with the ASDF package, especially for upgrade purposes
191 #:name
#:version
#:description
#:long-description
#:author
#:maintainer
#:licence
192 #:components-by-name
#:components
#:children
#:children-by-name
193 #:default-component-class
#:source-file
194 #:defsystem-depends-on
; This symbol retained for backward compatibility.
195 #:sideway-dependencies
#:if-feature
#:in-order-to
#:inline-methods
196 #:relative-pathname
#:absolute-pathname
#:operation-times
#:around-compile
197 #:%encoding
#:properties
#:component-properties
#:parent
))
198 (in-package :asdf
/component
)
200 (with-upgradability ()
201 (defgeneric component-name
(component)
202 (:documentation
"Name of the COMPONENT, unique relative to its parent"))
203 (defgeneric component-system
(component)
204 (:documentation
"Find the top-level system containing COMPONENT"))
205 (defgeneric component-pathname
(component)
206 (:documentation
"Extracts the pathname applicable for a particular component."))
207 (defgeneric (component-relative-pathname) (component)
208 (:documentation
"Returns a pathname for the component argument intended to be
209 interpreted relative to the pathname of that component's parent.
210 Despite the function's name, the return value may be an absolute
211 pathname, because an absolute pathname may be interpreted relative to
212 another pathname in a degenerate way."))
213 (defgeneric component-external-format
(component))
214 (defgeneric component-encoding
(component))
215 (defgeneric version-satisfies
(component version
))
216 (defgeneric component-version
(component))
217 (defgeneric (setf component-version
) (new-version component
))
218 (defgeneric component-parent
(component))
219 (defmethod component-parent ((component null
)) nil
)
221 ;; Backward compatible way of computing the FILE-TYPE of a component.
222 ;; TODO: find users, have them stop using that, remove it for ASDF4.
223 (defgeneric (source-file-type) (component system
))
225 (define-condition system-definition-error
(error) ()
226 ;; [this use of :report should be redundant, but unfortunately it's not.
227 ;; cmucl's lisp::output-instance prefers the kernel:slot-class-print-function
228 ;; over print-object; this is always conditions::%print-condition for
229 ;; condition objects, which in turn does inheritance of :report options at
230 ;; run-time. fortunately, inheritance means we only need this kludge here in
231 ;; order to fix all conditions that build on it. -- rgr, 28-Jul-02.]
232 #+cmu
(:report print-object
))
234 (define-condition duplicate-names
(system-definition-error)
235 ((name :initarg
:name
:reader duplicate-names-name
))
236 (:report
(lambda (c s
)
237 (format s
(compatfmt "~@<Error while defining system: multiple components are given same name ~S~@:>")
238 (duplicate-names-name c
))))))
241 (with-upgradability ()
242 (defclass component
()
243 ((name :accessor component-name
:initarg
:name
:type string
:documentation
244 "Component name: designator for a string composed of portable pathname characters")
245 ;; We might want to constrain version with
246 ;; :type (and string (satisfies parse-version))
247 ;; but we cannot until we fix all systems that don't use it correctly!
248 (version :accessor component-version
:initarg
:version
:initform nil
)
249 (description :accessor component-description
:initarg
:description
:initform nil
)
250 (long-description :accessor component-long-description
:initarg
:long-description
:initform nil
)
251 (sideway-dependencies :accessor component-sideway-dependencies
:initform nil
)
252 (if-feature :accessor component-if-feature
:initform nil
:initarg
:if-feature
)
253 ;; In the ASDF object model, dependencies exist between *actions*,
254 ;; where an action is a pair of an operation and a component.
255 ;; Dependencies are represented as alists of operations
256 ;; to a list where each entry is a pair of an operation and a list of component specifiers.
257 ;; Up until ASDF 2.26.9, there used to be two kinds of dependencies:
258 ;; in-order-to and do-first, each stored in its own slot. Now there is only in-order-to.
259 ;; in-order-to used to represent things that modify the filesystem (such as compiling a fasl)
260 ;; and do-first things that modify the current image (such as loading a fasl).
261 ;; These are now unified because we now correctly propagate timestamps between dependencies.
262 ;; Happily, no one seems to have used do-first too much (especially since until ASDF 2.017,
263 ;; anything you specified was overridden by ASDF itself anyway), but the name in-order-to remains.
264 ;; The names are bad, but they have been the official API since Dan Barlow's ASDF 1.52!
265 ;; LispWorks's defsystem has caused-by and requires for in-order-to and do-first respectively.
266 ;; Maybe rename the slots in ASDF? But that's not very backward-compatible.
267 ;; See our ASDF 2 paper for more complete explanations.
268 (in-order-to :initform nil
:initarg
:in-order-to
269 :accessor component-in-order-to
)
270 ;; methods defined using the "inline" style inside a defsystem form:
271 ;; need to store them somewhere so we can delete them when the system
273 (inline-methods :accessor component-inline-methods
:initform nil
) ;; OBSOLETE! DELETE THIS IF NO ONE USES.
274 ;; ASDF4: rename it from relative-pathname to specified-pathname. It need not be relative.
275 ;; There is no initform and no direct accessor for this specified pathname,
276 ;; so we only access the information through appropriate methods, after it has been processed.
277 ;; Unhappily, some braindead systems directly access the slot. Make them stop before ASDF4.
278 (relative-pathname :initarg
:pathname
)
279 ;; The absolute-pathname is computed based on relative-pathname and parent pathname.
280 ;; The slot is but a cache used by component-pathname.
282 (operation-times :initform
(make-hash-table)
283 :accessor component-operation-times
)
284 (around-compile :initarg
:around-compile
)
285 ;; Properties are for backward-compatibility with ASDF2 only. DO NOT USE!
286 (properties :accessor component-properties
:initarg
:properties
288 (%encoding
:accessor %component-encoding
:initform nil
:initarg
:encoding
)
289 ;; For backward-compatibility, this slot is part of component rather than of child-component. ASDF4: stop it.
290 (parent :initarg
:parent
:initform nil
:reader component-parent
)
292 :initarg
:build-operation
:initform nil
:reader component-build-operation
)))
294 (defun component-find-path (component)
295 "Return a path from a root system to the COMPONENT.
296 The return value is a list of component NAMES; a list of strings."
297 (check-type component
(or null component
))
299 (loop :for c
= component
:then
(component-parent c
)
300 :while c
:collect
(component-name c
))))
302 (defmethod print-object ((c component
) stream
)
303 (print-unreadable-object (c stream
:type t
:identity nil
)
304 (format stream
"~{~S~^ ~}" (component-find-path c
))))
306 (defmethod component-system ((component component
))
307 (if-let (system (component-parent component
))
308 (component-system system
)
312 ;;;; Component hierarchy within a system
313 ;; The tree typically but not necessarily follows the filesystem hierarchy.
314 (with-upgradability ()
315 (defclass child-component
(component) ()
316 (:documentation
"A CHILD-COMPONENT is a component that may be part of
317 a PARENT-COMPONENT."))
319 (defclass file-component
(child-component)
320 ((type :accessor file-type
:initarg
:type
))) ; no default
321 (defclass source-file
(file-component)
322 ((type :accessor source-file-explicit-type
;; backward-compatibility
323 :initform nil
))) ;; NB: many systems have come to rely on this default.
324 (defclass c-source-file
(source-file)
325 ((type :initform
"c")))
326 (defclass java-source-file
(source-file)
327 ((type :initform
"java")))
328 (defclass static-file
(source-file)
329 ((type :initform nil
)))
330 (defclass doc-file
(static-file) ())
331 (defclass html-file
(doc-file)
332 ((type :initform
"html")))
334 (defclass parent-component
(component)
338 :reader module-components
; backward-compatibility
339 :accessor component-children
)
341 :reader module-components-by-name
; backward-compatibility
342 :accessor component-children-by-name
)
343 (default-component-class
345 :initarg
:default-component-class
346 :accessor module-default-component-class
))
347 (:documentation
"A PARENT-COMPONENT is a component that may have
350 (with-upgradability ()
351 (defun compute-children-by-name (parent &key only-if-needed-p
)
352 (unless (and only-if-needed-p
(slot-boundp parent
'children-by-name
))
353 (let ((hash (make-hash-table :test
'equal
)))
354 (setf (component-children-by-name parent
) hash
)
355 (loop :for c
:in
(component-children parent
)
356 :for name
= (component-name c
)
357 :for previous
= (gethash name hash
)
358 :do
(when previous
(error 'duplicate-names
:name name
))
359 (setf (gethash name hash
) c
))
362 (with-upgradability ()
363 (defclass module
(child-component parent-component
)
364 (#+clisp
(components)))) ;; backward compatibility during upgrade only
367 ;;;; component pathnames
368 (with-upgradability ()
369 (defgeneric* (component-parent-pathname) (component))
370 (defmethod component-parent-pathname (component)
371 (component-pathname (component-parent component
)))
373 (defmethod component-pathname ((component component
))
374 (if (slot-boundp component
'absolute-pathname
)
375 (slot-value component
'absolute-pathname
)
378 (component-relative-pathname component
)
379 (pathname-directory-pathname (component-parent-pathname component
)))))
380 (unless (or (null pathname
) (absolute-pathname-p pathname
))
381 (error (compatfmt "~@<Invalid relative pathname ~S for component ~S~@:>")
382 pathname
(component-find-path component
)))
383 (setf (slot-value component
'absolute-pathname
) pathname
)
386 (defmethod component-relative-pathname ((component component
))
387 ;; SOURCE-FILE-TYPE below is strictly for backward-compatibility with ASDF1.
388 ;; We ought to be able to extract this from the component alone with FILE-TYPE.
389 ;; TODO: track who uses it in Quicklisp, and have them not use it anymore;
390 ;; maybe issue a WARNING (then eventually CERROR) if the two methods diverge?
391 (parse-unix-namestring
392 (or (and (slot-boundp component
'relative-pathname
)
393 (slot-value component
'relative-pathname
))
394 (component-name component
))
396 :type
(source-file-type component
(component-system component
))
397 :defaults
(component-parent-pathname component
)))
399 (defmethod source-file-type ((component parent-component
) (system parent-component
))
402 (defmethod source-file-type ((component file-component
) (system parent-component
))
403 (file-type component
)))
407 (with-upgradability ()
408 (defmethod component-encoding ((c component
))
409 (or (loop :for x
= c
:then
(component-parent x
)
410 :while x
:thereis
(%component-encoding x
))
411 (detect-encoding (component-pathname c
))))
413 (defmethod component-external-format ((c component
))
414 (encoding-external-format (component-encoding c
))))
417 ;;;; around-compile-hook
418 (with-upgradability ()
419 (defgeneric around-compile-hook
(component))
420 (defmethod around-compile-hook ((c component
))
422 ((slot-boundp c
'around-compile
)
423 (slot-value c
'around-compile
))
424 ((component-parent c
)
425 (around-compile-hook (component-parent c
))))))
428 ;;;; version-satisfies
429 (with-upgradability ()
430 ;; short-circuit testing of null version specifications.
431 ;; this is an all-pass, without warning
432 (defmethod version-satisfies :around
((c t
) (version null
))
434 (defmethod version-satisfies ((c component
) version
)
435 (unless (and version
(slot-boundp c
'version
) (component-version c
))
437 (warn "Requested version ~S but ~S has no version" version c
))
438 (return-from version-satisfies nil
))
439 (version-satisfies (component-version c
) version
))
441 (defmethod version-satisfies ((cver string
) version
)
442 (version<= version cver
)))
445 ;;; all sub-components (of a given type)
446 (with-upgradability ()
447 (defun sub-components (component &key
(type t
))
448 (while-collecting (c)
449 (labels ((recurse (x)
450 (when (if-let (it (component-if-feature x
)) (featurep it
) t
)
453 (when (typep x
'parent-component
)
454 (map () #'recurse
(component-children x
))))))
455 (recurse component
)))))
457 ;;;; -------------------------------------------------------------------------
460 (uiop/package
:define-package
:asdf
/system
461 (:recycle
:asdf
:asdf
/system
)
462 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/component
)
464 #:system
#:proto-system
465 #:system-source-file
#:system-source-directory
#:system-relative-pathname
467 #:system-description
#:system-long-description
468 #:system-author
#:system-maintainer
#:system-licence
#:system-license
469 #:system-defsystem-depends-on
#:system-depends-on
#:system-weakly-depends-on
470 #:component-build-pathname
#:build-pathname
471 #:component-entry-point
#:entry-point
472 #:homepage
#:system-homepage
473 #:bug-tracker
#:system-bug-tracker
474 #:mailto
#:system-mailto
475 #:long-name
#:system-long-name
476 #:source-control
#:system-source-control
477 #:find-system
#:builtin-system-p
)) ;; forward-reference, defined in find-system
478 (in-package :asdf
/system
)
480 (with-upgradability ()
481 (defgeneric* (find-system) (system &optional error-p
))
482 (defgeneric* (system-source-file :supersede
#-clisp t
#+clisp nil
) (system)
483 (:documentation
"Return the source file in which system is defined."))
484 (defgeneric component-build-pathname
(component))
486 (defgeneric component-entry-point
(component))
487 (defmethod component-entry-point ((c component
))
491 ;;;; The system class
493 (with-upgradability ()
494 (defclass proto-system
() ; slots to keep when resetting a system
495 ;; To preserve identity for all objects, we'd need keep the components slots
496 ;; but also to modify parse-component-form to reset the recycled objects.
497 ((name) (source-file) #|
(children) (children-by-names)|
#))
499 (defclass system
(module proto-system
)
500 ;; Backward-compatibility: inherit from module. ASDF4: only inherit from parent-component.
501 (;; {,long-}description is now inherited from component, but we add the legacy accessors
502 (description :accessor system-description
)
503 (long-description :accessor system-long-description
)
504 (author :accessor system-author
:initarg
:author
:initform nil
)
505 (maintainer :accessor system-maintainer
:initarg
:maintainer
:initform nil
)
506 (licence :accessor system-licence
:initarg
:licence
507 :accessor system-license
:initarg
:license
:initform nil
)
508 (homepage :accessor system-homepage
:initarg
:homepage
:initform nil
)
509 (bug-tracker :accessor system-bug-tracker
:initarg
:bug-tracker
:initform nil
)
510 (mailto :accessor system-mailto
:initarg
:mailto
:initform nil
)
511 (long-name :accessor system-long-name
:initarg
:long-name
:initform nil
)
512 ;; Conventions for this slot aren't clear yet as of ASDF 2.27, but whenever they are, they will be enforced.
513 ;; I'm introducing the slot before the conventions are set for maximum compatibility.
514 (source-control :accessor system-source-control
:initarg
:source-control
:initform nil
)
515 (builtin-system-p :accessor builtin-system-p
:initform nil
:initarg
:builtin-system-p
)
517 :initform nil
:initarg
:build-pathname
:accessor component-build-pathname
)
519 :initform nil
:initarg
:entry-point
:accessor component-entry-point
)
520 (source-file :initform nil
:initarg
:source-file
:accessor system-source-file
)
521 (defsystem-depends-on :reader system-defsystem-depends-on
:initarg
:defsystem-depends-on
523 ;; these two are specially set in parse-component-form, so have no :INITARGs.
524 (depends-on :reader system-depends-on
:initform nil
)
525 (weakly-depends-on :reader system-weakly-depends-on
:initform nil
)))
527 (defun reset-system (system &rest keys
&key
&allow-other-keys
)
528 (change-class (change-class system
'proto-system
) 'system
)
529 (apply 'reinitialize-instance system keys
)))
534 (with-upgradability ()
535 (defmethod system-source-file ((system-name string
))
536 (system-source-file (find-system system-name
)))
537 (defmethod system-source-file ((system-name symbol
))
538 (system-source-file (find-system system-name
)))
540 (defun system-source-directory (system-designator)
541 "Return a pathname object corresponding to the directory
542 in which the system specification (.asd file) is located."
543 (pathname-directory-pathname (system-source-file system-designator
)))
545 (defun (system-relative-pathname) (system name
&key type
)
546 (subpathname (system-source-directory system
) name
:type type
))
548 (defmethod component-pathname ((system system
))
549 (let ((pathname (or (call-next-method) (system-source-directory system
))))
550 (unless (and (slot-boundp system
'relative-pathname
) ;; backward-compatibility with ASDF1-age
551 (slot-value system
'relative-pathname
)) ;; systems that directly access this slot.
552 (setf (slot-value system
'relative-pathname
) pathname
))
555 (defmethod component-relative-pathname ((system system
))
556 (parse-unix-namestring
557 (and (slot-boundp system
'relative-pathname
)
558 (slot-value system
'relative-pathname
))
562 :defaults
(system-source-directory system
)))
564 (defmethod component-parent-pathname ((system system
))
565 (system-source-directory system
))
567 (defmethod component-build-pathname ((c component
))
570 ;;;; -------------------------------------------------------------------------
573 (uiop/package
:define-package
:asdf
/cache
574 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
)
575 (:export
#:get-file-stamp
#:compute-file-stamp
#:register-file-stamp
576 #:set-asdf-cache-entry
#:unset-asdf-cache-entry
#:consult-asdf-cache
577 #:do-asdf-cache
#:normalize-namestring
578 #:call-with-asdf-cache
#:with-asdf-cache
#:*asdf-cache
*
579 #:clear-configuration-and-retry
#:retry
))
580 (in-package :asdf
/cache
)
582 ;;; This stamp cache is useful for:
583 ;; * consistency of stamps used within a single run
584 ;; * fewer accesses to the filesystem
585 ;; * the ability to test with fake timestamps, without touching files
587 (with-upgradability ()
588 (defvar *asdf-cache
* nil
)
590 (defun set-asdf-cache-entry (key value-list
)
593 (setf (gethash key
*asdf-cache
*) value-list
)
596 (defun unset-asdf-cache-entry (key)
598 (remhash key
*asdf-cache
*)))
600 (defun consult-asdf-cache (key &optional thunk
)
602 (multiple-value-bind (results foundp
) (gethash key
*asdf-cache
*)
604 (apply 'values results
)
605 (set-asdf-cache-entry key
(multiple-value-list (call-function thunk
)))))
606 (call-function thunk
)))
608 (defmacro do-asdf-cache
(key &body body
)
609 `(consult-asdf-cache ,key
#'(lambda () ,@body
)))
611 (defun call-with-asdf-cache (thunk &key override key
)
612 (let ((fun (if key
#'(lambda () (consult-asdf-cache key thunk
)) thunk
)))
613 (if (and *asdf-cache
* (not override
))
617 (let ((*asdf-cache
* (make-hash-table :test
'equal
)))
618 (return (funcall fun
)))
621 (format s
(compatfmt "~@<Retry ASDF operation.~@:>"))))
622 (clear-configuration-and-retry ()
624 (format s
(compatfmt "~@<Retry ASDF operation after resetting the configuration.~@:>")))
625 (clear-configuration)))))))
627 (defmacro with-asdf-cache
((&key key override
) &body body
)
628 `(call-with-asdf-cache #'(lambda () ,@body
) :override
,override
:key
,key
))
630 (defun normalize-namestring (pathname)
631 (let ((resolved (resolve-symlinks*
632 (ensure-absolute-pathname
633 (physicalize-pathname pathname
)
634 'get-pathname-defaults
))))
635 (with-pathname-defaults () (namestring resolved
))))
637 (defun compute-file-stamp (normalized-namestring)
638 (with-pathname-defaults ()
639 (safe-file-write-date normalized-namestring
)))
641 (defun register-file-stamp (file &optional
(stamp nil stampp
))
642 (let* ((namestring (normalize-namestring file
))
643 (stamp (if stampp stamp
(compute-file-stamp namestring
))))
644 (set-asdf-cache-entry `(get-file-stamp ,namestring
) (list stamp
))))
646 (defun get-file-stamp (file)
648 (let ((namestring (normalize-namestring file
)))
649 (do-asdf-cache `(get-file-stamp ,namestring
) (compute-file-stamp namestring
))))))
651 ;;;; -------------------------------------------------------------------------
654 (uiop/package
:define-package
:asdf
/find-system
655 (:recycle
:asdf
/find-system
:asdf
)
656 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
657 :asdf
/cache
:asdf
/component
:asdf
/system
)
659 #:remove-entry-from-registry
#:coerce-entry-to-directory
660 #:coerce-name
#:primary-system-name
#:coerce-filename
661 #:find-system
#:locate-system
#:load-asd
662 #:system-registered-p
#:register-system
#:registered-systems
#:clear-system
#:map-systems
663 #:missing-component
#:missing-requires
#:missing-parent
664 #:formatted-system-definition-error
#:format-control
#:format-arguments
#:sysdef-error
665 #:load-system-definition-error
#:error-name
#:error-pathname
#:error-condition
666 #:*system-definition-search-functions
* #:search-for-system-definition
667 #:*central-registry
* #:probe-asd
#:sysdef-central-registry-search
668 #:find-system-if-being-defined
669 #:contrib-sysdef-search
#:sysdef-find-asdf
;; backward compatibility symbols, functions removed
670 #:sysdef-preloaded-system-search
#:register-preloaded-system
#:*preloaded-systems
*
671 #:sysdef-immutable-system-search
#:register-immutable-system
#:*immutable-systems
*
672 #:*defined-systems
* #:clear-defined-systems
673 ;; defined in source-registry, but specially mentioned here:
674 #:initialize-source-registry
#:sysdef-source-registry-search
))
675 (in-package :asdf
/find-system
)
677 (with-upgradability ()
678 (declaim (ftype (function (&optional t
) t
) initialize-source-registry
)) ; forward reference
680 (define-condition missing-component
(system-definition-error)
681 ((requires :initform
"(unnamed)" :reader missing-requires
:initarg
:requires
)
682 (parent :initform nil
:reader missing-parent
:initarg
:parent
)))
684 (define-condition formatted-system-definition-error
(system-definition-error)
685 ((format-control :initarg
:format-control
:reader format-control
)
686 (format-arguments :initarg
:format-arguments
:reader format-arguments
))
687 (:report
(lambda (c s
)
688 (apply 'format s
(format-control c
) (format-arguments c
)))))
690 (define-condition load-system-definition-error
(system-definition-error)
691 ((name :initarg
:name
:reader error-name
)
692 (pathname :initarg
:pathname
:reader error-pathname
)
693 (condition :initarg
:condition
:reader error-condition
))
694 (:report
(lambda (c s
)
695 (format s
(compatfmt "~@<Error while trying to load definition for system ~A from pathname ~A: ~3i~_~A~@:>")
696 (error-name c
) (error-pathname c
) (error-condition c
)))))
698 (defun sysdef-error (format &rest arguments
)
699 (error 'formatted-system-definition-error
:format-control
700 format
:format-arguments arguments
))
702 (defun coerce-name (name)
704 (component (component-name name
))
705 (symbol (string-downcase (symbol-name name
)))
707 (t (sysdef-error (compatfmt "~@<Invalid component designator: ~3i~_~A~@:>") name
))))
709 (defun primary-system-name (name)
710 ;; When a system name has slashes, the file with defsystem is named by
711 ;; the first of the slash-separated components.
712 (first (split-string (coerce-name name
) :separator
"/")))
714 (defun coerce-filename (name)
715 (frob-substrings (coerce-name name
) '("/" ":" "\\") "--"))
717 (defvar *defined-systems
* (make-hash-table :test
'equal
)
718 "This is a hash table whose keys are strings, being the
719 names of the systems, and whose values are pairs, the first
720 element of which is a universal-time indicating when the
721 system definition was last updated, and the second element
722 of which is a system object.")
724 (defun system-registered-p (name)
725 (gethash (coerce-name name
) *defined-systems
*))
727 (defun registered-systems ()
728 (loop :for registered
:being
:the
:hash-values
:of
*defined-systems
*
729 :collect
(coerce-name (cdr registered
))))
731 (defun register-system (system)
732 (check-type system system
)
733 (let ((name (component-name system
)))
734 (check-type name string
)
735 (asdf-message (compatfmt "~&~@<; ~@;Registering ~3i~_~A~@:>~%") system
)
736 (unless (eq system
(cdr (gethash name
*defined-systems
*)))
737 (setf (gethash name
*defined-systems
*)
738 (cons (if-let (file (ignore-errors (system-source-file system
)))
739 (get-file-stamp file
))
742 (defvar *preloaded-systems
* (make-hash-table :test
'equal
))
744 (defun make-preloaded-system (name keys
)
745 (apply 'make-instance
(getf keys
:class
'system
)
746 :name name
:source-file
(getf keys
:source-file
)
747 (remove-plist-keys '(:class
:name
:source-file
) keys
)))
749 (defun sysdef-preloaded-system-search (requested)
750 (let ((name (coerce-name requested
)))
751 (multiple-value-bind (keys foundp
) (gethash name
*preloaded-systems
*)
753 (make-preloaded-system name keys
)))))
755 (defun register-preloaded-system (system-name &rest keys
)
756 (setf (gethash (coerce-name system-name
) *preloaded-systems
*) keys
))
758 (dolist (s '("asdf" "uiop" "asdf-driver" "asdf-defsystem" "asdf-package-system"))
759 ;; don't bother with these, no one relies on them: "asdf-utils" "asdf-bundle"
760 (register-preloaded-system s
:version
*asdf-version
*))
762 (defvar *immutable-systems
* nil
763 "An hash-set (equal hash-table mapping keys to T) of systems that are immutable,
764 i.e. already loaded in memory and not to be refreshed from the filesystem.
765 They will be treated specially by find-system, and passed as :force-not argument to make-plan.
767 If you deliver an image with many systems precompiled, *and* do not want to check the filesystem
768 for them every time a user loads an extension, what more risk a problematic upgrade or catastrophic
769 downgrade, before you dump an image, use:
770 (setf asdf::*immutable-systems* (uiop:list-to-hash-set (asdf:already-loaded-systems)))")
772 (defun sysdef-immutable-system-search (requested)
773 (let ((name (coerce-name requested
)))
774 (when (and *immutable-systems
* (gethash name
*immutable-systems
*))
775 (or (cdr (system-registered-p requested
))
776 (sysdef-preloaded-system-search name
)
777 (error 'formatted-system-definition-error
778 :format-control
"Requested system ~A is in the *immutable-systems* set, ~
779 but not loaded in memory"
780 :format-arguments
(list name
))))))
782 (defun register-immutable-system (system-name &key
(version t
))
783 (let* ((system-name (coerce-name system-name
))
784 (registered-system (cdr (system-registered-p system-name
)))
785 (default-version?
(eql version t
))
786 (version (cond ((and default-version? registered-system
)
787 (component-version registered-system
))
788 (default-version? nil
)
790 (unless registered-system
791 (register-system (make-preloaded-system system-name
(list :version version
))))
792 (register-preloaded-system system-name
:version version
)
793 (unless *immutable-systems
*
794 (setf *immutable-systems
* (list-to-hash-set nil
)))
795 (setf (gethash (coerce-name system-name
) *immutable-systems
*) t
)))
797 (defun clear-system (system)
798 "Clear the entry for a SYSTEM in the database of systems previously loaded,
799 unless the system appears in the table of *IMMUTABLE-SYSTEMS*.
800 Note that this does NOT in any way cause the code of the system to be unloaded.
801 Returns T if cleared or already cleared,
802 NIL if not cleared because the system was found to be immutable."
803 ;; There is no "unload" operation in Common Lisp, and
804 ;; a general such operation cannot be portably written,
805 ;; considering how much CL relies on side-effects to global data structures.
806 (let ((name (coerce-name system
)))
807 (unless (and *immutable-systems
* (gethash name
*immutable-systems
*))
808 (remhash (coerce-name name
) *defined-systems
*)
809 (unset-asdf-cache-entry `(locate-system ,name
))
810 (unset-asdf-cache-entry `(find-system ,name
))
813 (defun clear-defined-systems ()
814 ;; Invalidate all systems but ASDF itself, if registered.
815 (loop :for name
:being
:the
:hash-keys
:of
*defined-systems
*
816 :unless
(equal name
"asdf") :do
(clear-system name
)))
818 (register-hook-function '*post-upgrade-cleanup-hook
* 'clear-defined-systems nil
)
820 (defun map-systems (fn)
821 "Apply FN to each defined system.
823 FN should be a function of one argument. It will be
824 called with an object of type asdf:system."
825 (loop :for registered
:being
:the
:hash-values
:of
*defined-systems
*
826 :do
(funcall fn
(cdr registered
)))))
828 ;;; for the sake of keeping things reasonably neat, we adopt a
829 ;;; convention that functions in this list are prefixed SYSDEF-
830 (with-upgradability ()
831 (defvar *system-definition-search-functions
* '())
833 (defun cleanup-system-definition-search-functions ()
834 (setf *system-definition-search-functions
*
836 ;; Remove known-incompatible sysdef functions from old versions of asdf.
837 (remove-if #'(lambda (x) (member x
'(contrib-sysdef-search sysdef-find-asdf sysdef-preloaded-system-search
)))
838 *system-definition-search-functions
*)
839 ;; Tuck our defaults at the end of the list if they were absent.
840 ;; This is imperfect, in case they were removed on purpose,
841 ;; but then it will be the responsibility of whoever does that
842 ;; to upgrade asdf before he does such a thing rather than after.
843 (remove-if #'(lambda (x) (member x
*system-definition-search-functions
*))
844 '(sysdef-central-registry-search
845 sysdef-source-registry-search
)))))
846 (cleanup-system-definition-search-functions)
848 (defun search-for-system-definition (system)
849 (let ((name (coerce-name system
)))
850 (flet ((try (f) (if-let ((x (funcall f name
))) (return-from search-for-system-definition x
))))
851 (try 'find-system-if-being-defined
)
852 (try 'sysdef-immutable-system-search
)
853 (map () #'try
*system-definition-search-functions
*)
854 (try 'sysdef-preloaded-system-search
))))
856 (defvar *central-registry
* nil
857 "A list of 'system directory designators' ASDF uses to find systems.
859 A 'system directory designator' is a pathname or an expression
860 which evaluates to a pathname. For example:
862 (setf asdf:*central-registry*
863 (list '*default-pathname-defaults*
864 #p\"/home/me/cl/systems/\"
865 #p\"/usr/share/common-lisp/systems/\"))
867 This is for backward compatibility.
868 Going forward, we recommend new users should be using the source-registry.
871 (defun probe-asd (name defaults
&key truename
)
873 (when (directory-pathname-p defaults
)
874 (if-let (file (probe-file*
875 (ensure-absolute-pathname
876 (parse-unix-namestring name
:type
"asd")
877 #'(lambda () (ensure-absolute-pathname defaults
'get-pathname-defaults nil
))
881 #-
(or clisp genera
) ; clisp doesn't need it, plain genera doesn't have read-sequence(!)
884 (when (physical-pathname-p defaults
)
887 :defaults defaults
:case
:local
888 :name
(strcat name
".asd")
890 (when (probe-file* shortcut
)
891 (ensure-pathname (parse-windows-shortcut shortcut
) :namestring
:native
)))))))))
893 (defun sysdef-central-registry-search (system)
894 (let ((name (primary-system-name system
))
899 (dolist (dir *central-registry
*)
900 (let ((defaults (eval dir
))
903 (cond ((directory-pathname-p defaults
)
904 (let* ((file (probe-asd name defaults
:truename
*resolve-symlinks
*)))
909 (let* ((*print-circle
* nil
)
912 (compatfmt "~@<While searching for system ~S: ~3i~_~S evaluated to ~S which is not an absolute directory.~@:>")
913 system dir defaults
)))
915 (remove-entry-from-registry ()
916 :report
"Remove entry from *central-registry* and continue"
917 (push dir to-remove
))
918 (coerce-entry-to-directory ()
919 :test
(lambda (c) (declare (ignore c
))
920 (and (not (directory-pathname-p defaults
))
921 (directory-pathname-p
923 (ensure-directory-pathname defaults
)))))
925 (format s
(compatfmt "~@<Coerce entry to ~a, replace ~a and continue.~@:>")
927 (push (cons dir directorized
) to-replace
))))))))
929 (dolist (dir to-remove
)
930 (setf *central-registry
* (remove dir
*central-registry
*)))
931 (dolist (pair to-replace
)
932 (let* ((current (car pair
))
934 (position (position current
*central-registry
*)))
935 (setf *central-registry
*
936 (append (subseq *central-registry
* 0 position
)
938 (subseq *central-registry
* (1+ position
))))))))))
940 (defmethod find-system ((name null
) &optional
(error-p t
))
942 (sysdef-error (compatfmt "~@<NIL is not a valid system name~@:>"))))
944 (defmethod find-system (name &optional
(error-p t
))
945 (find-system (coerce-name name
) error-p
))
947 (defun find-system-if-being-defined (name)
948 ;; notable side effect: mark the system as being defined, to avoid infinite loops
949 (first (gethash `(find-system ,(coerce-name name
)) *asdf-cache
*)))
951 (defun load-asd (pathname
952 &key name
(external-format (encoding-external-format (detect-encoding pathname
)))
953 &aux
(readtable *readtable
*) (print-pprint-dispatch *print-pprint-dispatch
*))
954 ;; Tries to load system definition with canonical NAME from PATHNAME.
956 (with-standard-io-syntax
957 (let ((*package
* (find-package :asdf-user
))
958 ;; Note that our backward-compatible *readtable* is
959 ;; a global readtable that gets globally side-effected. Ouch.
960 ;; Same for the *print-pprint-dispatch* table.
961 ;; We should do something about that for ASDF3 if possible, or else ASDF4.
962 (*readtable
* readtable
)
963 (*print-pprint-dispatch
* print-pprint-dispatch
)
964 (*print-readably
* nil
)
965 (*default-pathname-defaults
*
966 ;; resolve logical-pathnames so they won't wreak havoc in parsing namestrings.
967 (pathname-directory-pathname (physicalize-pathname pathname
))))
969 ((error #'(lambda (condition)
970 (error 'load-system-definition-error
971 :name name
:pathname pathname
972 :condition condition
))))
973 (asdf-message (compatfmt "~&~@<; ~@;Loading system definition~@[ for ~A~] from ~A~@:>~%")
975 (load* pathname
:external-format external-format
))))))
977 (defvar *old-asdf-systems
* (make-hash-table :test
'equal
))
979 (defun check-not-old-asdf-system (name pathname
)
980 (or (not (equal name
"asdf"))
982 (let* ((version-pathname (subpathname pathname
"version.lisp-expr"))
983 (version (and (probe-file* version-pathname
:truename nil
)
984 (read-file-form version-pathname
)))
985 (old-version (asdf-version)))
987 ((version< old-version version
) t
) ;; newer version: good!
988 ((equal old-version version
) nil
) ;; same version: don't load, but don't warn
989 (t ;; old version: bad
991 (list (namestring pathname
) version
) *old-asdf-systems
*
994 (if-let (pair (system-registered-p "asdf"))
995 (system-source-file (cdr pair
)))))
997 You are using ASDF version ~A ~:[(probably from (require \"asdf\") ~
998 or loaded by quicklisp)~;from ~:*~S~] and have an older version of ASDF ~
999 ~:[(and older than 2.27 at that)~;~:*~A~] registered at ~S. ~
1000 Having an ASDF installed and registered is the normal way of configuring ASDF to upgrade itself, ~
1001 and having an old version registered is a configuration error. ~
1002 ASDF will ignore this configured system rather than downgrade itself. ~
1003 In the future, you may want to either: ~
1004 (a) upgrade this configured ASDF to a newer version, ~
1005 (b) install a newer ASDF and register it in front of the former in your configuration, or ~
1006 (c) uninstall or unregister this and any other old version of ASDF from your configuration. ~
1007 Note that the older ASDF might be registered implicitly through configuration inherited ~
1008 from your system installation, in which case you might have to specify ~
1009 :ignore-inherited-configuration in your in your ~~/.config/common-lisp/source-registry.conf ~
1010 or other source-registry configuration file, environment variable or lisp parameter. ~
1011 Indeed, a likely offender is an obsolete version of the cl-asdf debian or ubuntu package, ~
1012 that you might want to upgrade (if a recent enough version is available) ~
1013 or else remove altogether (since most implementations ship with a recent asdf); ~
1014 if you lack the system administration rights to upgrade or remove this package, ~
1015 then you might indeed want to either install and register a more recent version, ~
1016 or use :ignore-inherited-configuration to avoid registering the old one. ~
1017 Please consult ASDF documentation and/or experts.~@:>~%"
1018 old-version old-pathname version pathname
))))
1019 nil
))))) ;; only issue the warning the first time, but always return nil
1021 (defun locate-system (name)
1022 "Given a system NAME designator, try to locate where to load the system from.
1023 Returns five values: FOUNDP FOUND-SYSTEM PATHNAME PREVIOUS PREVIOUS-TIME
1024 FOUNDP is true when a system was found,
1025 either a new unregistered one or a previously registered one.
1026 FOUND-SYSTEM when not null is a SYSTEM object that may be REGISTER-SYSTEM'ed.
1027 PATHNAME when not null is a path from which to load the system,
1028 either associated with FOUND-SYSTEM, or with the PREVIOUS system.
1029 PREVIOUS when not null is a previously loaded SYSTEM object of same name.
1030 PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded."
1031 (let* ((name (coerce-name name
))
1032 (in-memory (system-registered-p name
)) ; load from disk if absent or newer on disk
1033 (previous (cdr in-memory
))
1034 (previous (and (typep previous
'system
) previous
))
1035 (previous-time (car in-memory
))
1036 (found (search-for-system-definition name
))
1037 (found-system (and (typep found
'system
) found
))
1038 (pathname (ensure-pathname
1039 (or (and (typep found
'(or pathname string
)) (pathname found
))
1040 (and found-system
(system-source-file found-system
))
1041 (and previous
(system-source-file previous
)))
1042 :want-absolute t
:resolve-symlinks
*resolve-symlinks
*))
1043 (foundp (and (or found-system pathname previous
) t
)))
1044 (check-type found
(or null pathname system
))
1045 (unless (check-not-old-asdf-system name pathname
)
1047 (previous (setf found nil pathname nil
))
1049 (setf found
(sysdef-preloaded-system-search "asdf"))
1050 (assert (typep found
'system
))
1051 (setf found-system found pathname nil
))))
1052 (values foundp found-system pathname previous previous-time
)))
1054 (defmethod find-system ((name string
) &optional
(error-p t
))
1055 (with-asdf-cache (:key
`(find-system ,name
))
1056 (let ((primary-name (primary-system-name name
)))
1057 (unless (equal name primary-name
)
1058 (find-system primary-name nil
)))
1059 (or (and *immutable-systems
* (gethash name
*immutable-systems
*)
1060 (or (cdr (system-registered-p name
))
1061 (sysdef-preloaded-system-search name
)))
1062 (multiple-value-bind (foundp found-system pathname previous previous-time
)
1063 (locate-system name
)
1064 (assert (eq foundp
(and (or found-system pathname previous
) t
)))
1065 (let ((previous-pathname (and previous
(system-source-file previous
)))
1066 (system (or previous found-system
)))
1067 (when (and found-system
(not previous
))
1068 (register-system found-system
))
1069 (when (and system pathname
)
1070 (setf (system-source-file system
) pathname
))
1072 (let ((stamp (get-file-stamp pathname
)))
1075 (or (pathname-equal pathname previous-pathname
)
1076 (and pathname previous-pathname
1078 (physicalize-pathname pathname
)
1079 (physicalize-pathname previous-pathname
))))
1080 (stamp<= stamp previous-time
))))))
1081 ;; only load when it's a pathname that is different or has newer content, and not an old asdf
1082 (load-asd pathname
:name name
)))
1083 (let ((in-memory (system-registered-p name
))) ; try again after loading from disk if needed
1087 (setf (car in-memory
) (get-file-stamp pathname
)))
1090 (error 'missing-component
:requires name
))
1091 (t ;; not found: don't keep negative cache, see lp#1335323
1092 (unset-asdf-cache-entry `(locate-system ,name
))
1093 (return-from find-system nil
)))))))))
1094 ;;;; -------------------------------------------------------------------------
1095 ;;;; Finding components
1097 (uiop/package
:define-package
:asdf
/find-component
1098 (:recycle
:asdf
/find-component
:asdf
)
1099 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/cache
1100 :asdf
/component
:asdf
/system
:asdf
/find-system
)
1103 #:resolve-dependency-name
#:resolve-dependency-spec
1104 #:resolve-dependency-combination
1106 #:missing-component
#:missing-component-of-version
#:retry
1107 #:missing-dependency
#:missing-dependency-of-version
1108 #:missing-requires
#:missing-parent
1109 #:missing-required-by
#:missing-version
))
1110 (in-package :asdf
/find-component
)
1112 ;;;; Missing component conditions
1114 (with-upgradability ()
1115 (define-condition missing-component-of-version
(missing-component)
1116 ((version :initform nil
:reader missing-version
:initarg
:version
)))
1118 (define-condition missing-dependency
(missing-component)
1119 ((required-by :initarg
:required-by
:reader missing-required-by
)))
1121 (defmethod print-object ((c missing-dependency
) s
)
1122 (format s
(compatfmt "~@<~A, required by ~A~@:>")
1123 (call-next-method c nil
) (missing-required-by c
)))
1125 (define-condition missing-dependency-of-version
(missing-dependency
1126 missing-component-of-version
)
1129 (defmethod print-object ((c missing-component
) s
)
1130 (format s
(compatfmt "~@<Component ~S not found~@[ in ~A~]~@:>")
1131 (missing-requires c
)
1132 (when (missing-parent c
)
1133 (coerce-name (missing-parent c
)))))
1135 (defmethod print-object ((c missing-component-of-version
) s
)
1136 (format s
(compatfmt "~@<Component ~S does not match version ~A~@[ in ~A~]~@:>")
1137 (missing-requires c
)
1139 (when (missing-parent c
)
1140 (coerce-name (missing-parent c
))))))
1143 ;;;; Finding components
1145 (with-upgradability ()
1146 (defgeneric* (find-component) (base path
)
1147 (:documentation
"Find a component by resolving the PATH starting from BASE parent"))
1148 (defgeneric resolve-dependency-combination
(component combinator arguments
))
1150 (defmethod find-component ((base string
) path
)
1151 (let ((s (find-system base nil
)))
1152 (and s
(find-component s path
))))
1154 (defmethod find-component ((base symbol
) path
)
1156 (base (find-component (coerce-name base
) path
))
1157 (path (find-component path nil
))
1160 (defmethod find-component ((base cons
) path
)
1161 (find-component (car base
) (cons (cdr base
) path
)))
1163 (defmethod find-component ((parent parent-component
) (name string
))
1164 (compute-children-by-name parent
:only-if-needed-p t
) ;; SBCL may miss the u-i-f-r-c method!!!
1165 (values (gethash name
(component-children-by-name parent
))))
1167 (defmethod find-component (base (name symbol
))
1169 (find-component base
(coerce-name name
))
1172 (defmethod find-component ((c component
) (name cons
))
1173 (find-component (find-component c
(car name
)) (cdr name
)))
1175 (defmethod find-component ((base t
) (actual component
))
1178 (defun resolve-dependency-name (component name
&optional version
)
1182 (let ((comp (find-component (component-parent component
) name
)))
1184 (error 'missing-dependency
1185 :required-by component
1188 (unless (version-satisfies comp version
)
1189 (error 'missing-dependency-of-version
1190 :required-by component
1196 (format s
(compatfmt "~@<Retry loading ~3i~_~A.~@:>") name
))
1200 (and (typep c
'missing-dependency
)
1201 (eq (missing-required-by c
) component
)
1202 (equal (missing-requires c
) name
))))
1203 (unless (component-parent component
)
1204 (let ((name (coerce-name name
)))
1205 (unset-asdf-cache-entry `(find-system ,name
))
1206 (unset-asdf-cache-entry `(locate-system ,name
))))))))
1209 (defun resolve-dependency-spec (component dep-spec
)
1210 (let ((component (find-component () component
)))
1212 (resolve-dependency-name component dep-spec
)
1213 (resolve-dependency-combination component
(car dep-spec
) (cdr dep-spec
)))))
1215 (defmethod resolve-dependency-combination (component combinator arguments
)
1216 (error (compatfmt "~@<Bad dependency ~S for ~S~@:>")
1217 (cons combinator arguments
) component
))
1219 (defmethod resolve-dependency-combination (component (combinator (eql :feature
)) arguments
)
1220 (when (featurep (first arguments
))
1221 (resolve-dependency-spec component
(second arguments
))))
1223 (defmethod resolve-dependency-combination (component (combinator (eql :version
)) arguments
)
1224 (resolve-dependency-name component
(first arguments
) (second arguments
)))) ;; See lp#527788
1226 ;;;; -------------------------------------------------------------------------
1229 (uiop/package
:define-package
:asdf
/operation
1230 (:recycle
:asdf
/operation
:asdf
/action
:asdf
) ;; asdf/action for FEATURE pre 2.31.5.
1231 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/find-system
)
1234 #:operation-original-initargs
#:original-initargs
;; backward-compatibility only. DO NOT USE.
1235 #:*operations
* #:make-operation
#:find-operation
1236 #:feature
)) ;; TODO: stop exporting the deprecated FEATURE feature.
1237 (in-package :asdf
/operation
)
1239 ;;; Operation Classes
1241 (when-upgrading (:when
(find-class 'operation nil
))
1242 ;; override any obsolete shared-initialize method when upgrading from ASDF2.
1243 (defmethod shared-initialize :after
((o operation
) (slot-names t
) &key
)
1246 (with-upgradability ()
1247 (defclass operation
()
1248 ((original-initargs ;; for backward-compat -- used by GBBopen and swank (via operation-forced)
1249 :initform nil
:initarg
:original-initargs
:accessor operation-original-initargs
)))
1251 ;; Cache a copy of the INITARGS in the ORIGINAL-INITARGS slot, if that slot is not
1253 (defmethod initialize-instance :after
((o operation
) &rest initargs
1254 &key force force-not system verbose
&allow-other-keys
)
1255 (declare (ignore force force-not system verbose
))
1256 (unless (slot-boundp o
'original-initargs
)
1257 (setf (operation-original-initargs o
) initargs
)))
1259 (defmethod print-object ((o operation
) stream
)
1260 (print-unreadable-object (o stream
:type t
:identity nil
)
1262 (format stream
"~{~S~^ ~}" (operation-original-initargs o
))))))
1264 ;;; make-operation, find-operation
1266 (with-upgradability ()
1267 (defparameter* *operations
* (make-hash-table :test
'equal
))
1269 (defun make-operation (operation-class &rest initargs
)
1270 (let ((class (coerce-class operation-class
1271 :package
:asdf
/interface
:super
'operation
:error
'sysdef-error
)))
1272 (ensure-gethash (cons class initargs
) *operations
*
1273 (list* 'make-instance class initargs
))))
1275 (defgeneric find-operation
(context spec
)
1276 (:documentation
"Find an operation by resolving the SPEC in the CONTEXT"))
1277 (defmethod find-operation ((context t
) (spec operation
))
1279 (defmethod find-operation (context (spec symbol
))
1280 (when spec
;; NIL designates itself, i.e. absence of operation
1281 (apply 'make-operation spec
(operation-original-initargs context
))))
1282 (defmethod find-operation (context (spec string
))
1283 (apply 'make-operation spec
(operation-original-initargs context
)))
1284 (defmethod operation-original-initargs ((context symbol
))
1285 (declare (ignorable context
))
1288 ;;;; -------------------------------------------------------------------------
1291 (uiop/package
:define-package
:asdf
/action
1292 (:nicknames
:asdf-action
)
1293 (:recycle
:asdf
/action
:asdf
)
1294 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
1295 :asdf
/component
:asdf
/system
#:asdf
/cache
:asdf
/find-system
:asdf
/find-component
:asdf
/operation
)
1297 #:action
#:define-convenience-action-methods
1298 #:explain
#:action-description
1299 #:downward-operation
#:upward-operation
#:sideway-operation
#:selfward-operation
#:non-propagating-operation
1300 #:component-depends-on
1301 #:input-files
#:output-files
#:output-file
#:operation-done-p
1302 #:action-status
#:action-stamp
#:action-done-p
1303 #:component-operation-time
#:mark-operation-done
#:compute-action-stamp
1304 #:perform
#:perform-with-restarts
#:retry
#:accept
1305 #:traverse-actions
#:traverse-sub-actions
#:required-components
;; in plan
1306 #:action-path
#:find-action
#:stamp
#:done-p
1307 #:operation-definition-warning
#:operation-definition-error
;; condition
1309 (in-package :asdf
/action
)
1311 (eval-when (#-lispworks
:compile-toplevel
:load-toplevel
:execute
) ;; LispWorks issues spurious warning
1312 (deftype action
() '(cons operation component
)) ;; a step to be performed while building
1314 (deftype operation-designator
()
1315 ;; an operation designates itself,
1316 ;; nil designates a context-dependent current operation, and
1317 ;; class-name or class designates an instance of the designated class.
1318 '(or operation null symbol class
)))
1320 (with-upgradability ()
1321 (defgeneric traverse-actions
(actions &key
&allow-other-keys
))
1322 (defgeneric traverse-sub-actions
(operation component
&key
&allow-other-keys
))
1323 (defgeneric required-components
(component &key
&allow-other-keys
)))
1325 ;;;; Reified representation for storage or debugging. Note: dropping original-initargs
1326 (with-upgradability ()
1327 (defun action-path (action)
1328 (destructuring-bind (o . c
) action
(cons (type-of o
) (component-find-path c
))))
1329 (defun find-action (path)
1330 (destructuring-bind (o . c
) path
(cons (make-operation o
) (find-component () c
)))))
1333 ;;;; Convenience methods
1334 (with-upgradability ()
1335 (defmacro define-convenience-action-methods
1336 (function formals
&key if-no-operation if-no-component operation-initargs
)
1337 (let* ((rest (gensym "REST"))
1338 (found (gensym "FOUND"))
1339 (keyp (equal (last formals
) '(&key
)))
1340 (formals-no-key (if keyp
(butlast formals
) formals
))
1341 (len (length formals-no-key
))
1342 (operation 'operation
)
1343 (component 'component
)
1344 (opix (position operation formals
))
1345 (coix (position component formals
))
1346 (prefix (subseq formals
0 opix
))
1347 (suffix (subseq formals
(1+ coix
) len
))
1348 (more-args (when keyp
`(&rest
,rest
&key
&allow-other-keys
))))
1349 (assert (and (integerp opix
) (integerp coix
) (= coix
(1+ opix
))))
1350 (flet ((next-method (o c
)
1352 `(apply ',function
,@prefix
,o
,c
,@suffix
,rest
)
1353 `(,function
,@prefix
,o
,c
,@suffix
))))
1355 (defmethod ,function
(,@prefix
(,operation string
) ,component
,@suffix
,@more-args
)
1356 (let ((,component
(find-component () ,component
))) ;; do it first, for defsystem-depends-on
1357 ,(next-method `(safe-read-from-string ,operation
:package
:asdf
/interface
) component
)))
1358 (defmethod ,function
(,@prefix
(,operation symbol
) ,component
,@suffix
,@more-args
)
1361 (if operation-initargs
;backward-compatibility with ASDF1's operate. Yuck.
1362 `(apply 'make-operation
,operation
:original-initargs
,rest
,rest
)
1363 `(make-operation ,operation
))
1364 `(or (find-component () ,component
) ,if-no-component
))
1366 (defmethod ,function
(,@prefix
(,operation operation
) ,component
,@suffix
,@more-args
)
1367 (if (typep ,component
'component
)
1368 (error "No defined method for ~S on ~/asdf-action:format-action/"
1369 ',function
(cons ,operation
,component
))
1370 (if-let (,found
(find-component () ,component
))
1371 ,(next-method operation found
)
1372 ,if-no-component
))))))))
1375 ;;;; self-description
1376 (with-upgradability ()
1377 (defgeneric action-description
(operation component
)
1378 (:documentation
"returns a phrase that describes performing this operation
1379 on this component, e.g. \"loading /a/b/c\".
1380 You can put together sentences using this phrase."))
1381 (defmethod action-description (operation component
)
1382 (format nil
(compatfmt "~@<~A on ~A~@:>")
1383 (type-of operation
) component
))
1384 (defgeneric* (explain) (operation component
))
1385 (defmethod explain ((o operation
) (c component
))
1386 (asdf-message (compatfmt "~&~@<; ~@;~A~:>~%") (action-description o c
)))
1387 (define-convenience-action-methods explain
(operation component
))
1389 (defun format-action (stream action
&optional colon-p at-sign-p
)
1390 (assert (null colon-p
)) (assert (null at-sign-p
))
1391 (destructuring-bind (operation . component
) action
1392 (princ (action-description operation component
) stream
))))
1396 (with-upgradability ()
1397 (defgeneric* (component-depends-on) (operation component
) ;; ASDF4: rename to component-dependencies
1399 "Returns a list of dependencies needed by the component to perform
1400 the operation. A dependency has one of the following forms:
1402 (<operation> <component>*), where <operation> is an operation designator
1403 with respect to FIND-OPERATION in the context of the OPERATION argument,
1404 and each <component> is a component designator with respect to
1405 FIND-COMPONENT in the context of the COMPONENT argument,
1406 and means that the component depends on
1407 <operation> having been performed on each <component>;
1409 [Note: an <operation> is an operation designator -- it can be either an
1410 operation name or an operation object. Similarly, a <component> may be
1411 a component name or a component object. Also note that, the degenerate
1412 case of (<operation>) is a no-op.]
1414 Methods specialized on subclasses of existing component types
1415 should usually append the results of CALL-NEXT-METHOD to the list."))
1416 (define-convenience-action-methods component-depends-on
(operation component
))
1418 (defmethod component-depends-on :around
((o operation
) (c component
))
1419 (do-asdf-cache `(component-depends-on ,o
,c
)
1420 (call-next-method))))
1423 ;;;; upward-operation, downward-operation, sideway-operation, selfward-operation
1424 ;; These together handle actions that propagate along the component hierarchy or operation universe.
1425 (with-upgradability ()
1426 (defclass downward-operation
(operation)
1427 ((downward-operation
1428 :initform nil
:reader downward-operation
1429 :type operation-designator
:allocation
:class
))
1430 (:documentation
"A DOWNWARD-OPERATION's dependencies propagate down the component hierarchy.
1431 I.e., if O is a DOWNWARD-OPERATION and its DOWNWARD-OPERATION slot designates operation D, then
1432 the action (O . M) of O on module M will depends on each of (D . C) for each child C of module M.
1433 The default value for slot DOWNWARD-OPERATION is NIL, which designates the operation O itself.
1434 E.g. in order for a MODULE to be loaded with LOAD-OP (resp. compiled with COMPILE-OP), all the
1435 children of the MODULE must have been loaded with LOAD-OP (resp. compiled with COMPILE-OP."))
1436 (defun downward-operation-depends-on (o c
)
1437 `((,(or (downward-operation o
) o
) ,@(component-children c
))))
1438 (defmethod component-depends-on ((o downward-operation
) (c parent-component
))
1439 `(,@(downward-operation-depends-on o c
) ,@(call-next-method)))
1441 (defclass upward-operation
(operation)
1443 :initform nil
:reader upward-operation
1444 :type operation-designator
:allocation
:class
))
1445 (:documentation
"An UPWARD-OPERATION has dependencies that propagate up the component hierarchy.
1446 I.e., if O is an instance of UPWARD-OPERATION, and its UPWARD-OPERATION slot designates operation U,
1447 then the action (O . C) of O on a component C that has the parent P will depends on (U . P).
1448 The default value for slot UPWARD-OPERATION is NIL, which designates the operation O itself.
1449 E.g. in order for a COMPONENT to be prepared for loading or compiling with PREPARE-OP, its PARENT
1450 must first be prepared for loading or compiling with PREPARE-OP."))
1451 ;; For backward-compatibility reasons, a system inherits from module and is a child-component
1452 ;; so we must guard against this case. ASDF4: remove that.
1453 (defun upward-operation-depends-on (o c
)
1454 (if-let (p (component-parent c
)) `((,(or (upward-operation o
) o
) ,p
))))
1455 (defmethod component-depends-on ((o upward-operation
) (c child-component
))
1456 `(,@(upward-operation-depends-on o c
) ,@(call-next-method)))
1458 (defclass sideway-operation
(operation)
1460 :initform nil
:reader sideway-operation
1461 :type operation-designator
:allocation
:class
))
1462 (:documentation
"A SIDEWAY-OPERATION has dependencies that propagate \"sideway\" to siblings
1463 that a component depends on. I.e. if O is a SIDEWAY-OPERATION, and its SIDEWAY-OPERATION slot
1464 designates operation S (where NIL designates O itself), then the action (O . C) of O on component C
1465 depends on each of (S . D) where D is a declared dependency of C.
1466 E.g. in order for a COMPONENT to be prepared for loading or compiling with PREPARE-OP,
1467 each of its declared dependencies must first be loaded as by LOAD-OP."))
1468 (defun sideway-operation-depends-on (o c
)
1469 `((,(or (sideway-operation o
) o
) ,@(component-sideway-dependencies c
))))
1470 (defmethod component-depends-on ((o sideway-operation
) (c component
))
1471 `(,@(sideway-operation-depends-on o c
) ,@(call-next-method)))
1473 (defclass selfward-operation
(operation)
1474 ((selfward-operation
1475 ;; NB: no :initform -- if an operation depends on others, it must explicitly specify which
1476 :type
(or operation-designator list
) :reader selfward-operation
:allocation
:class
))
1477 (:documentation
"A SELFWARD-OPERATION depends on another operation on the same component.
1478 I.e., if O is a SELFWARD-OPERATION, and its SELFWARD-OPERATION designates a list of operations L,
1479 then the action (O . C) of O on component C depends on each (S . C) for S in L.
1480 E.g. before a component may be loaded by LOAD-OP, it must have been compiled by COMPILE-OP.
1481 A operation-designator designates a singleton list of the designated operation;
1482 a list of operation-designators designates the list of designated operations;
1483 NIL is not a valid operation designator in that context. Note that any dependency
1484 ordering between the operations in a list of SELFWARD-OPERATION should be specified separately
1485 in the respective operation's COMPONENT-DEPENDS-ON methods so that they be scheduled properly."))
1486 (defun selfward-operation-depends-on (o c
)
1487 (loop :for op
:in
(ensure-list (selfward-operation o
)) :collect
`(,op
,c
)))
1488 (defmethod component-depends-on ((o selfward-operation
) (c component
))
1489 `(,@(selfward-operation-depends-on o c
) ,@(call-next-method)))
1491 (defclass non-propagating-operation
(operation)
1493 (:documentation
"A NON-PROPAGATING-OPERATION is an operation that propagates
1494 no dependencies whatsoever. It is supplied in order that the programmer be able
1495 to specify that s/he is intentionally specifying an operation which invokes no
1499 ;;;---------------------------------------------------------------------------
1500 ;;; Help programmers catch obsolete OPERATION subclasses
1501 ;;;---------------------------------------------------------------------------
1502 (with-upgradability ()
1503 (define-condition operation-definition-warning
(simple-warning)
1505 (:documentation
"Warning condition related to definition of obsolete OPERATION objects."))
1507 (define-condition operation-definition-error
(simple-error)
1509 (:documentation
"Error condition related to definition of incorrect OPERATION objects."))
1511 (defmethod initialize-instance :before
((o operation
) &key
)
1512 (unless (typep o
'(or downward-operation upward-operation sideway-operation
1513 selfward-operation non-propagating-operation
))
1514 (warn 'operation-definition-warning
1516 "No dependency propagating scheme specified for operation class ~S.
1517 The class needs to be updated for ASDF 3.1 and specify appropriate propagation mixins."
1518 :format-arguments
(list (type-of o
)))))
1520 (defmethod initialize-instance :before
((o non-propagating-operation
) &key
)
1521 (when (typep o
'(or downward-operation upward-operation sideway-operation selfward-operation
))
1522 (error 'operation-definition-error
1524 "Inconsistent class: ~S
1525 NON-PROPAGATING-OPERATION is incompatible with propagating operation classes as superclasses."
1527 (list (type-of o
)))))
1529 (defmethod component-depends-on ((o operation
) (c component
))
1530 `(;; Normal behavior, to allow user-specified in-order-to dependencies
1531 ,@(cdr (assoc (type-of o
) (component-in-order-to c
)))
1532 ;; For backward-compatibility with ASDF2, any operation that doesn't specify propagation
1533 ;; or non-propagation through an appropriate mixin will be downward and sideway.
1534 ,@(unless (typep o
'(or downward-operation upward-operation sideway-operation
1535 selfward-operation non-propagating-operation
))
1536 `(,@(sideway-operation-depends-on o c
)
1537 ,@(when (typep c
'parent-component
) (downward-operation-depends-on o c
))))))
1539 (defmethod downward-operation ((o operation
)) nil
)
1540 (defmethod sideway-operation ((o operation
)) nil
))
1543 ;;;---------------------------------------------------------------------------
1544 ;;; End of OPERATION class checking
1545 ;;;---------------------------------------------------------------------------
1548 ;;;; Inputs, Outputs, and invisible dependencies
1549 (with-upgradability ()
1550 (defgeneric* (output-files) (operation component
))
1551 (defgeneric* (input-files) (operation component
))
1552 (defgeneric* (operation-done-p) (operation component
)
1553 (:documentation
"Returns a boolean, which is NIL if the action is forced to be performed again"))
1554 (define-convenience-action-methods output-files
(operation component
))
1555 (define-convenience-action-methods input-files
(operation component
))
1556 (define-convenience-action-methods operation-done-p
(operation component
))
1558 (defmethod operation-done-p ((o operation
) (c component
))
1561 (defmethod output-files :around
(operation component
)
1562 "Translate output files, unless asked not to. Memoize the result."
1563 operation component
;; hush genera, not convinced by declare ignorable(!)
1564 (do-asdf-cache `(output-files ,operation
,component
)
1566 (multiple-value-bind (pathnames fixedp
) (call-next-method)
1567 ;; 1- Make sure we have absolute pathnames
1568 (let* ((directory (pathname-directory-pathname
1569 (component-pathname (find-component () component
))))
1572 :for pathname
:in pathnames
1573 :collect
(ensure-absolute-pathname pathname directory
))))
1574 ;; 2- Translate those pathnames as required
1577 (mapcar *output-translation-function
* absolute-pathnames
))))
1579 (defmethod output-files ((o operation
) (c component
))
1581 (defun output-file (operation component
)
1582 "The unique output file of performing OPERATION on COMPONENT"
1583 (let ((files (output-files operation component
)))
1584 (assert (length=n-p files
1))
1587 (defmethod input-files :around
(operation component
)
1588 "memoize input files."
1589 (do-asdf-cache `(input-files ,operation
,component
)
1590 (call-next-method)))
1592 (defmethod input-files ((o operation
) (c component
))
1595 (defmethod input-files ((o selfward-operation
) (c component
))
1596 `(,@(or (loop :for dep-o
:in
(ensure-list (selfward-operation o
))
1597 :append
(or (output-files dep-o c
) (input-files dep-o c
)))
1598 (if-let ((pathname (component-pathname c
)))
1599 (and (file-pathname-p pathname
) (list pathname
))))
1600 ,@(call-next-method))))
1603 ;;;; Done performing
1604 (with-upgradability ()
1605 (defgeneric component-operation-time
(operation component
)) ;; ASDF4: hide it behind plan-action-stamp
1606 (define-convenience-action-methods component-operation-time
(operation component
))
1608 (defgeneric mark-operation-done
(operation component
)) ;; ASDF4: hide it behind (setf plan-action-stamp)
1609 (defgeneric compute-action-stamp
(plan operation component
&key just-done
)
1610 (:documentation
"Has this action been successfully done already,
1611 and at what known timestamp has it been done at or will it be done at?
1612 Takes two keywords JUST-DONE and PLAN:
1613 JUST-DONE is a boolean that is true if the action was just successfully performed,
1614 at which point we want compute the actual stamp and warn if files are missing;
1615 otherwise we are making plans, anticipating the effects of the action.
1616 PLAN is a plan object modelling future effects of actions,
1617 or NIL to denote what actually happened.
1619 * a STAMP saying when it was done or will be done,
1620 or T if the action has involves files that need to be recomputed.
1621 * a boolean DONE-P that indicates whether the action has actually been done,
1622 and both its output-files and its in-image side-effects are up to date."))
1624 (defclass action-status
()
1626 :initarg
:stamp
:reader action-stamp
1627 :documentation
"STAMP associated with the ACTION if it has been completed already
1628 in some previous image, or T if it needs to be done.")
1630 :initarg
:done-p
:reader action-done-p
1631 :documentation
"a boolean, true iff the action was already done (before any planned action)."))
1632 (:documentation
"Status of an action"))
1634 (defmethod print-object ((status action-status
) stream
)
1635 (print-unreadable-object (status stream
:type t
)
1636 (with-slots (stamp done-p
) status
1637 (format stream
"~@{~S~^ ~}" :stamp stamp
:done-p done-p
))))
1639 (defmethod component-operation-time ((o operation
) (c component
))
1640 (gethash (type-of o
) (component-operation-times c
)))
1642 (defmethod mark-operation-done ((o operation
) (c component
))
1643 (setf (gethash (type-of o
) (component-operation-times c
))
1644 (compute-action-stamp nil o c
:just-done t
))))
1648 (with-upgradability ()
1649 (defgeneric* (perform-with-restarts) (operation component
))
1650 (defgeneric* (perform) (operation component
))
1651 (define-convenience-action-methods perform
(operation component
))
1653 (defmethod perform :before
((o operation
) (c component
))
1654 (ensure-all-directories-exist (output-files o c
)))
1655 (defmethod perform :after
((o operation
) (c component
))
1656 (mark-operation-done o c
))
1657 (defmethod perform ((o operation
) (c parent-component
))
1659 (defmethod perform ((o operation
) (c source-file
))
1660 ;; For backward compatibility, don't error on operations that don't specify propagation.
1661 (when (typep o
'(or downward-operation upward-operation sideway-operation
1662 selfward-operation non-propagating-operation
))
1664 (compatfmt "~@<Required method ~S not implemented for ~/asdf-action:format-action/~@:>")
1665 'perform
(cons o c
))))
1667 (defmethod perform-with-restarts (operation component
)
1668 ;; TOO verbose, especially as the default. Add your own :before method
1669 ;; to perform-with-restart or perform if you want that:
1670 #|
(explain operation component
)|
#
1671 (perform operation component
))
1672 (defmethod perform-with-restarts :around
(operation component
)
1675 (return (call-next-method))
1679 (format s
(compatfmt "~@<Retry ~A.~@:>")
1680 (action-description operation component
))))
1684 (format s
(compatfmt "~@<Continue, treating ~A as having been successful.~@:>")
1685 (action-description operation component
)))
1686 (mark-operation-done operation component
)
1688 ;;;; -------------------------------------------------------------------------
1689 ;;;; Actions to build Common Lisp software
1691 (uiop/package
:define-package
:asdf
/lisp-action
1692 (:recycle
:asdf
/lisp-action
:asdf
)
1693 (:intern
#:proclamations
#:flags
)
1694 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/cache
1695 :asdf
/component
:asdf
/system
:asdf
/find-component
:asdf
/find-system
1696 :asdf
/operation
:asdf
/action
)
1699 #:cl-source-file
#:cl-source-file.cl
#:cl-source-file.lsp
1700 #:basic-load-op
#:basic-compile-op
#:compile-op-flags
#:compile-op-proclamations
1701 #:load-op
#:prepare-op
#:compile-op
#:test-op
#:load-source-op
#:prepare-source-op
1702 #:call-with-around-compile-hook
1703 #:perform-lisp-compilation
#:perform-lisp-load-fasl
#:perform-lisp-load-source
1704 #:lisp-compilation-output-files
#:flags
))
1705 (in-package :asdf
/lisp-action
)
1708 ;;;; Component classes
1709 (with-upgradability ()
1710 (defclass cl-source-file
(source-file)
1711 ((type :initform
"lisp")))
1712 (defclass cl-source-file.cl
(cl-source-file)
1713 ((type :initform
"cl")))
1714 (defclass cl-source-file.lsp
(cl-source-file)
1715 ((type :initform
"lsp"))))
1718 ;;;; Operation classes
1719 (with-upgradability ()
1720 (defclass basic-load-op
(operation) ())
1721 (defclass basic-compile-op
(operation)
1722 ((proclamations :initarg
:proclamations
:accessor compile-op-proclamations
:initform nil
)
1723 (flags :initarg
:flags
:accessor compile-op-flags
:initform nil
))))
1725 ;;; Our default operations: loading into the current lisp image
1726 (with-upgradability ()
1727 (defclass prepare-op
(upward-operation sideway-operation
)
1728 ((sideway-operation :initform
'load-op
:allocation
:class
))
1729 (:documentation
"Load dependencies necessary for COMPILE-OP or LOAD-OP of a given COMPONENT."))
1730 (defclass load-op
(basic-load-op downward-operation selfward-operation
)
1731 ;; NB: even though compile-op depends on prepare-op it is not needed-in-image-p,
1732 ;; so we need to directly depend on prepare-op for its side-effects in the current image.
1733 ((selfward-operation :initform
'(prepare-op compile-op
) :allocation
:class
)))
1734 (defclass compile-op
(basic-compile-op downward-operation selfward-operation
)
1735 ((selfward-operation :initform
'prepare-op
:allocation
:class
)))
1737 (defclass prepare-source-op
(upward-operation sideway-operation
)
1738 ((sideway-operation :initform
'load-source-op
:allocation
:class
)))
1739 (defclass load-source-op
(basic-load-op downward-operation selfward-operation
)
1740 ((selfward-operation :initform
'prepare-source-op
:allocation
:class
)))
1742 (defclass test-op
(selfward-operation)
1743 ((selfward-operation :initform
'load-op
:allocation
:class
))))
1746 ;;;; prepare-op, compile-op and load-op
1749 (with-upgradability ()
1750 (defmethod action-description ((o prepare-op
) (c component
))
1751 (format nil
(compatfmt "~@<loading dependencies of ~3i~_~A~@:>") c
))
1752 (defmethod perform ((o prepare-op
) (c component
))
1754 (defmethod input-files ((o prepare-op
) (s system
))
1755 (if-let (it (system-source-file s
)) (list it
))))
1758 (with-upgradability ()
1759 (defmethod action-description ((o compile-op
) (c component
))
1760 (format nil
(compatfmt "~@<compiling ~3i~_~A~@:>") c
))
1761 (defmethod action-description ((o compile-op
) (c parent-component
))
1762 (format nil
(compatfmt "~@<completing compilation for ~3i~_~A~@:>") c
))
1763 (defgeneric call-with-around-compile-hook
(component thunk
))
1764 (defmethod call-with-around-compile-hook ((c component
) function
)
1765 (call-around-hook (around-compile-hook c
) function
))
1766 (defun perform-lisp-compilation (o c
)
1767 (let (;; Before 2.26.53, that was unfortunately component-pathname. Now,
1768 ;; we consult input-files, the first of which should be the one to compile-file
1769 (input-file (first (input-files o c
)))
1770 ;; on some implementations, there are more than one output-file,
1771 ;; but the first one should always be the primary fasl that gets loaded.
1772 (outputs (output-files o c
)))
1773 (multiple-value-bind (output warnings-p failure-p
)
1777 #+(or clasp ecl mkcl
) object-file
1779 warnings-file
) outputs
1780 (call-with-around-compile-hook
1781 c
#'(lambda (&rest flags
)
1782 (apply 'compile-file
* input-file
1783 :output-file output-file
1784 :external-format
(component-external-format c
)
1785 :warnings-file warnings-file
1787 #+clisp
(list :lib-file lib-file
)
1788 #+(or clasp ecl mkcl
) (list :object-file object-file
)
1789 flags
(compile-op-flags o
))))))
1790 (check-lisp-compile-results output warnings-p failure-p
1791 "~/asdf-action::format-action/" (list (cons o c
))))))
1793 (defun report-file-p (f)
1794 (equalp (pathname-type f
) "build-report"))
1795 (defun perform-lisp-warnings-check (o c
)
1796 (let* ((expected-warnings-files (remove-if-not #'warnings-file-p
(input-files o c
)))
1797 (actual-warnings-files (loop :for w
:in expected-warnings-files
1798 :when
(get-file-stamp w
)
1800 :else
:do
(warn "Missing warnings file ~S while ~A"
1801 w
(action-description o c
)))))
1802 (check-deferred-warnings actual-warnings-files
)
1803 (let* ((output (output-files o c
))
1804 (report (find-if #'report-file-p output
)))
1806 (with-open-file (s report
:direction
:output
:if-exists
:supersede
)
1807 (format s
":success~%"))))))
1808 (defmethod perform ((o compile-op
) (c cl-source-file
))
1809 (perform-lisp-compilation o c
))
1810 (defun lisp-compilation-output-files (o c
)
1811 (let* ((i (first (input-files o c
)))
1812 (f (compile-file-pathname
1813 i
#+clasp
:output-type
#+ecl
:type
#+(or clasp ecl
) :fasl
1814 #+mkcl
:fasl-p
#+mkcl t
)))
1815 `(,f
;; the fasl is the primary output, in first position
1817 ,@(unless nil
;; was (use-ecl-byte-compiler-p)
1818 `(,(compile-file-pathname i
:output-type
:object
)))
1820 ,@`(,(make-pathname :type
"lib" :defaults f
))
1822 ,@(unless (use-ecl-byte-compiler-p)
1823 `(,(compile-file-pathname i
:type
:object
)))
1825 ,(compile-file-pathname i
:fasl-p nil
) ;; object file
1826 ,@(when (and *warnings-file-type
* (not (builtin-system-p (component-system c
))))
1827 `(,(make-pathname :type
*warnings-file-type
* :defaults f
))))))
1828 (defmethod output-files ((o compile-op
) (c cl-source-file
))
1829 (lisp-compilation-output-files o c
))
1830 (defmethod perform ((o compile-op
) (c static-file
))
1832 (defmethod perform ((o compile-op
) (c system
))
1833 (when (and *warnings-file-type
* (not (builtin-system-p c
)))
1834 (perform-lisp-warnings-check o c
)))
1835 (defmethod input-files ((o compile-op
) (c system
))
1836 (when (and *warnings-file-type
* (not (builtin-system-p c
)))
1837 ;; The most correct way to do it would be to use:
1838 ;; (traverse-sub-actions o c :other-systems nil :keep-operation 'compile-op :keep-component 'cl-source-file)
1839 ;; but it's expensive and we don't care too much about file order or ASDF extensions.
1840 (loop :for sub
:in
(sub-components c
:type
'cl-source-file
)
1841 :nconc
(remove-if-not 'warnings-file-p
(output-files o sub
)))))
1842 (defmethod output-files ((o compile-op
) (c system
))
1843 (when (and *warnings-file-type
* (not (builtin-system-p c
)))
1844 (if-let ((pathname (component-pathname c
)))
1845 (list (subpathname pathname
(coerce-filename c
) :type
"build-report"))))))
1848 (with-upgradability ()
1849 (defmethod action-description ((o load-op
) (c cl-source-file
))
1850 (format nil
(compatfmt "~@<loading FASL for ~3i~_~A~@:>") c
))
1851 (defmethod action-description ((o load-op
) (c parent-component
))
1852 (format nil
(compatfmt "~@<completing load for ~3i~_~A~@:>") c
))
1853 (defmethod action-description ((o load-op
) (c component
))
1854 (format nil
(compatfmt "~@<loading ~3i~_~A~@:>") c
))
1855 (defmethod perform-with-restarts ((o load-op
) (c cl-source-file
))
1858 (return (call-next-method))
1861 (format s
"Recompile ~a and try loading it again"
1862 (component-name c
)))
1863 (perform (find-operation o
'compile-op
) c
)))))
1864 (defun perform-lisp-load-fasl (o c
)
1865 (if-let (fasl (first (input-files o c
)))
1867 (defmethod perform ((o load-op
) (c cl-source-file
))
1868 (perform-lisp-load-fasl o c
))
1869 (defmethod perform ((o load-op
) (c static-file
))
1873 ;;;; prepare-source-op, load-source-op
1875 ;;; prepare-source-op
1876 (with-upgradability ()
1877 (defmethod action-description ((o prepare-source-op
) (c component
))
1878 (format nil
(compatfmt "~@<loading source for dependencies of ~3i~_~A~@:>") c
))
1879 (defmethod input-files ((o prepare-source-op
) (s system
))
1880 (if-let (it (system-source-file s
)) (list it
)))
1881 (defmethod perform ((o prepare-source-op
) (c component
))
1885 (with-upgradability ()
1886 (defmethod action-description ((o load-source-op
) (c component
))
1887 (format nil
(compatfmt "~@<Loading source of ~3i~_~A~@:>") c
))
1888 (defmethod action-description ((o load-source-op
) (c parent-component
))
1889 (format nil
(compatfmt "~@<Loaded source of ~3i~_~A~@:>") c
))
1890 (defun perform-lisp-load-source (o c
)
1891 (call-with-around-compile-hook
1893 (load* (first (input-files o c
))
1894 :external-format
(component-external-format c
)))))
1896 (defmethod perform ((o load-source-op
) (c cl-source-file
))
1897 (perform-lisp-load-source o c
))
1898 (defmethod perform ((o load-source-op
) (c static-file
))
1903 (with-upgradability ()
1904 (defmethod perform ((o test-op
) (c component
))
1906 (defmethod operation-done-p ((o test-op
) (c system
))
1907 "Testing a system is _never_ done."
1910 ;;;; -------------------------------------------------------------------------
1913 (uiop/package
:define-package
:asdf
/plan
1914 (:recycle
:asdf
/plan
:asdf
)
1915 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
1916 :asdf
/component
:asdf
/operation
:asdf
/system
1917 :asdf
/cache
:asdf
/find-system
:asdf
/find-component
1918 :asdf
/operation
:asdf
/action
:asdf
/lisp-action
)
1920 #:component-operation-time
#:mark-operation-done
1921 #:plan
#:plan-traversal
#:sequential-plan
#:*default-plan-class
*
1922 #:planned-action-status
#:plan-action-status
#:action-already-done-p
1923 #:circular-dependency
#:circular-dependency-actions
1924 #:node-for
#:needed-in-image-p
1925 #:action-index
#:action-planned-p
#:action-valid-p
1926 #:plan-record-dependency
1927 #:normalize-forced-systems
#:action-forced-p
#:action-forced-not-p
1928 #:map-direct-dependencies
#:reduce-direct-dependencies
#:direct-dependencies
1929 #:compute-action-stamp
#:traverse-action
1930 #:circular-dependency
#:circular-dependency-actions
1931 #:call-while-visiting-action
#:while-visiting-action
1932 #:make-plan
#:plan-actions
#:perform-plan
#:plan-operates-on-p
1933 #:planned-p
#:index
#:forced
#:forced-not
#:total-action-count
1934 #:planned-action-count
#:planned-output-action-count
#:visited-actions
1935 #:visiting-action-set
#:visiting-action-list
#:plan-actions-r
1936 #:required-components
#:filtered-sequential-plan
1938 #:plan-action-filter
#:plan-component-type
#:plan-keep-operation
#:plan-keep-component
1939 #:traverse-actions
#:traverse-sub-actions
))
1940 (in-package :asdf
/plan
)
1942 ;;;; Generic plan traversal class
1943 (with-upgradability ()
1944 (defclass plan
() ())
1945 (defclass plan-traversal
(plan)
1946 ((system :initform nil
:initarg
:system
:accessor plan-system
)
1947 (forced :initform nil
:initarg
:force
:accessor plan-forced
)
1948 (forced-not :initform nil
:initarg
:force-not
:accessor plan-forced-not
)
1949 (total-action-count :initform
0 :accessor plan-total-action-count
)
1950 (planned-action-count :initform
0 :accessor plan-planned-action-count
)
1951 (planned-output-action-count :initform
0 :accessor plan-planned-output-action-count
)
1952 (visited-actions :initform
(make-hash-table :test
'equal
) :accessor plan-visited-actions
)
1953 (visiting-action-set :initform
(make-hash-table :test
'equal
) :accessor plan-visiting-action-set
)
1954 (visiting-action-list :initform
() :accessor plan-visiting-action-list
))))
1957 ;;;; Planned action status
1958 (with-upgradability ()
1959 (defgeneric plan-action-status
(plan operation component
)
1960 (:documentation
"Returns the ACTION-STATUS associated to
1961 the action of OPERATION on COMPONENT in the PLAN"))
1963 (defgeneric (setf plan-action-status
) (new-status plan operation component
)
1964 (:documentation
"Sets the ACTION-STATUS associated to
1965 the action of OPERATION on COMPONENT in the PLAN"))
1967 (defclass planned-action-status
(action-status)
1969 :initarg
:planned-p
:reader action-planned-p
1970 :documentation
"a boolean, true iff the action was included in the plan.")
1972 :initarg
:index
:reader action-index
1973 :documentation
"an integer, counting all traversed actions in traversal order."))
1974 (:documentation
"Status of an action in a plan"))
1976 (defmethod print-object ((status planned-action-status
) stream
)
1977 (print-unreadable-object (status stream
:type t
:identity nil
)
1978 (with-slots (stamp done-p planned-p index
) status
1979 (format stream
"~@{~S~^ ~}" :stamp stamp
:done-p done-p
:planned-p planned-p
:index index
))))
1981 (defmethod action-planned-p ((action-status t
))
1982 t
) ; default method for non planned-action-status objects
1984 ;; TODO: eliminate NODE-FOR, use CONS.
1985 ;; Supposes cleaner protocol for operation initargs passed to MAKE-OPERATION.
1986 ;; However, see also component-operation-time and mark-operation-done
1987 (defun node-for (o c
) (cons (type-of o
) c
))
1989 (defun action-already-done-p (plan operation component
)
1990 (action-done-p (plan-action-status plan operation component
)))
1992 (defmethod plan-action-status ((plan null
) (o operation
) (c component
))
1993 (multiple-value-bind (stamp done-p
) (component-operation-time o c
)
1994 (make-instance 'action-status
:stamp stamp
:done-p done-p
)))
1996 (defmethod (setf plan-action-status
) (new-status (plan null
) (o operation
) (c component
))
1997 (let ((to (type-of o
))
1998 (times (component-operation-times c
)))
1999 (if (action-done-p new-status
)
2001 (setf (gethash to times
) (action-stamp new-status
))))
2006 (with-upgradability ()
2007 (defgeneric action-forced-p
(plan operation component
))
2008 (defgeneric action-forced-not-p
(plan operation component
))
2010 (defun normalize-forced-systems (x system
)
2012 ((or (member nil
:all
) hash-table function
) x
)
2013 (cons (list-to-hash-set (mapcar #'coerce-name x
)))
2014 ((eql t
) (when system
(list-to-hash-set (list (coerce-name system
)))))))
2016 (defun normalize-forced-not-systems (x system
)
2019 ((or (member nil
:all
) hash-table function
) x
)
2020 (cons (list-to-hash-set (mapcar #'coerce-name x
)))
2021 ((eql t
) (if system
(let ((name (coerce-name system
)))
2022 #'(lambda (x) (not (equal x name
))))
2024 (if (and *immutable-systems
* requested
)
2025 #'(lambda (x) (or (call-function requested x
) (call-function *immutable-systems
* x
)))
2026 (or *immutable-systems
* requested
))))
2028 (defun action-override-p (plan operation component override-accessor
)
2029 (declare (ignore operation
))
2030 (call-function (funcall override-accessor plan
)
2031 (coerce-name (component-system (find-component () component
)))))
2033 (defmethod action-forced-p (plan operation component
)
2035 ;; Did the user ask us to re-perform the action?
2036 (action-override-p plan operation component
'plan-forced
)
2037 ;; You really can't force a builtin system and :all doesn't apply to it,
2038 ;; except it it's the specifically the system currently being built.
2039 (not (let ((system (component-system component
)))
2040 (and (builtin-system-p system
)
2041 (not (eq system
(plan-system plan
))))))))
2043 (defmethod action-forced-not-p (plan operation component
)
2044 ;; Did the user ask us to not re-perform the action?
2045 ;; NB: force-not takes precedence over force, as it should
2046 (action-override-p plan operation component
'plan-forced-not
))
2048 (defmethod action-forced-p ((plan null
) (operation operation
) (component component
))
2051 (defmethod action-forced-not-p ((plan null
) (operation operation
) (component component
))
2056 (with-upgradability ()
2057 (defgeneric action-valid-p
(plan operation component
)
2058 (:documentation
"Is this action valid to include amongst dependencies?"))
2059 (defmethod action-valid-p ((plan t
) (o operation
) (c component
))
2060 (if-let (it (component-if-feature c
)) (featurep it
) t
))
2061 (defmethod action-valid-p ((plan t
) (o null
) (c t
)) nil
)
2062 (defmethod action-valid-p ((plan t
) (o t
) (c null
)) nil
)
2063 (defmethod action-valid-p ((plan null
) (o operation
) (c component
)) t
))
2065 ;;;; Is the action needed in this image?
2066 (with-upgradability ()
2067 (defgeneric needed-in-image-p
(operation component
)
2068 (:documentation
"Is the action of OPERATION on COMPONENT needed in the current image to be meaningful,
2069 or could it just as well have been done in another Lisp image?"))
2071 (defmethod needed-in-image-p ((o operation
) (c component
))
2072 ;; We presume that actions that modify the filesystem don't need be run
2073 ;; in the current image if they have already been done in another,
2074 ;; and can be run in another process (e.g. a fork),
2075 ;; whereas those that don't are meant to side-effect the current image and can't.
2076 (not (output-files o c
))))
2079 ;;;; Visiting dependencies of an action and computing action stamps
2080 (with-upgradability ()
2081 (defun (map-direct-dependencies) (plan operation component fun
)
2082 (loop* :for
(dep-o-spec . dep-c-specs
) :in
(component-depends-on operation component
)
2083 :for dep-o
= (find-operation operation dep-o-spec
)
2085 :do
(loop :for dep-c-spec
:in dep-c-specs
2086 :for dep-c
= (and dep-c-spec
(resolve-dependency-spec component dep-c-spec
))
2087 :when
(and dep-c
(action-valid-p plan dep-o dep-c
))
2088 :do
(funcall fun dep-o dep-c
))))
2090 (defun (reduce-direct-dependencies) (plan operation component combinator seed
)
2091 (map-direct-dependencies
2092 plan operation component
2093 #'(lambda (dep-o dep-c
)
2094 (setf seed
(funcall combinator dep-o dep-c seed
))))
2097 (defun (direct-dependencies) (plan operation component
)
2098 (reduce-direct-dependencies plan operation component
#'acons nil
))
2100 ;; In a distant future, get-file-stamp, component-operation-time and latest-stamp
2101 ;; shall also be parametrized by the plan, or by a second model object,
2102 ;; so they need not refer to the state of the filesystem,
2103 ;; and the stamps could be cryptographic checksums rather than timestamps.
2104 ;; Such a change remarkably would only affect COMPUTE-ACTION-STAMP.
2106 (defmethod compute-action-stamp (plan (o operation
) (c component
) &key just-done
)
2107 ;; Given an action, figure out at what time in the past it has been done,
2108 ;; or if it has just been done, return the time that it has.
2109 ;; Returns two values:
2110 ;; 1- the TIMESTAMP of the action if it has already been done and is up to date,
2111 ;; or T is either hasn't been done or is out of date.
2112 ;; 2- the DONE-IN-IMAGE-P boolean flag that is T if the action has already been done
2113 ;; in the current image, or NIL if it hasn't.
2114 ;; Note that if e.g. LOAD-OP only depends on up-to-date files, but
2115 ;; hasn't been done in the current image yet, then it can have a non-T timestamp,
2116 ;; yet a NIL done-in-image-p flag.
2119 (let ((dep-stamp ; collect timestamp from dependencies (or T if forced or out-of-date)
2120 (reduce-direct-dependencies
2122 #'(lambda (o c stamp
)
2123 (if-let (it (plan-action-status plan o c
))
2124 (latest-stamp stamp
(action-stamp it
))
2127 ;; out-of-date dependency: don't bother expensively querying the filesystem
2128 (when (and (eq dep-stamp t
) (not just-done
)) (return (values t nil
))))
2129 ;; collect timestamps from inputs, and exit early if any is missing
2130 (let* ((in-files (input-files o c
))
2131 (in-stamps (mapcar #'get-file-stamp in-files
))
2132 (missing-in (loop :for f
:in in-files
:for s
:in in-stamps
:unless s
:collect f
))
2133 (latest-in (stamps-latest (cons dep-stamp in-stamps
))))
2134 (when (and missing-in
(not just-done
)) (return (values t nil
))))
2135 ;; collect timestamps from outputs, and exit early if any is missing
2136 (let* ((out-files (output-files o c
))
2137 (out-stamps (mapcar (if just-done
'register-file-stamp
'get-file-stamp
) out-files
))
2138 (missing-out (loop :for f
:in out-files
:for s
:in out-stamps
:unless s
:collect f
))
2139 (earliest-out (stamps-earliest out-stamps
)))
2140 (when (and missing-out
(not just-done
)) (return (values t nil
))))
2141 (let* (;; There are three kinds of actions:
2142 (out-op (and out-files t
)) ; those that create files on the filesystem
2143 ;;(image-op (and in-files (null out-files))) ; those that load stuff into the image
2144 ;;(null-op (and (null out-files) (null in-files))) ; placeholders that do nothing
2145 ;; When was the thing last actually done? (Now, or ask.)
2146 (op-time (or just-done
(component-operation-time o c
)))
2147 ;; Time stamps from the files at hand, and whether any is missing
2148 (all-present (not (or missing-in missing-out
)))
2149 ;; Has any input changed since we last generated the files?
2150 (up-to-date-p (stamp<= latest-in earliest-out
))
2151 ;; If everything is up to date, the latest of inputs and outputs is our stamp
2152 (done-stamp (stamps-latest (cons latest-in out-stamps
))))
2153 ;; Warn if some files are missing:
2154 ;; either our model is wrong or some other process is messing with our files.
2155 (when (and just-done
(not all-present
))
2156 (warn "~A completed without ~:[~*~;~*its input file~:p~2:*~{ ~S~}~*~]~
2157 ~:[~; or ~]~:[~*~;~*its output file~:p~2:*~{ ~S~}~*~]"
2158 (action-description o c
)
2159 missing-in
(length missing-in
) (and missing-in missing-out
)
2160 missing-out
(length missing-out
))))
2161 ;; Note that we use stamp<= instead of stamp< to play nice with generated files.
2162 ;; Any race condition is intrinsic to the limited timestamp resolution.
2163 (if (or just-done
;; The done-stamp is valid: if we're just done, or
2164 ;; if all filesystem effects are up-to-date and there's no invalidating reason.
2165 (and all-present up-to-date-p
(operation-done-p o c
) (not (action-forced-p plan o c
))))
2166 (values done-stamp
;; return the hard-earned timestamp
2168 out-op
;; a file-creating op is done when all files are up to date
2169 ;; a image-effecting a placeholder op is done when it was actually run,
2170 (and op-time
(eql op-time done-stamp
)))) ;; with the matching stamp
2171 ;; done-stamp invalid: return a timestamp in an indefinite future, action not done yet
2175 ;;;; Generic support for plan-traversal
2176 (with-upgradability ()
2177 (defgeneric plan-record-dependency
(plan operation component
))
2179 (defgeneric call-while-visiting-action
(plan operation component function
)
2180 (:documentation
"Detect circular dependencies"))
2182 (defmethod initialize-instance :after
((plan plan-traversal
)
2183 &key force force-not system
2185 (with-slots (forced forced-not
) plan
2186 (setf forced
(normalize-forced-systems force system
))
2187 (setf forced-not
(normalize-forced-not-systems force-not system
))))
2189 (defmethod (setf plan-action-status
) (new-status (plan plan-traversal
) (o operation
) (c component
))
2190 (setf (gethash (node-for o c
) (plan-visited-actions plan
)) new-status
))
2192 (defmethod plan-action-status ((plan plan-traversal
) (o operation
) (c component
))
2193 (or (and (action-forced-not-p plan o c
) (plan-action-status nil o c
))
2194 (values (gethash (node-for o c
) (plan-visited-actions plan
)))))
2196 (defmethod action-valid-p ((plan plan-traversal
) (o operation
) (s system
))
2197 (and (not (action-forced-not-p plan o s
)) (call-next-method)))
2199 (defmethod call-while-visiting-action ((plan plan-traversal
) operation component fun
)
2200 (with-accessors ((action-set plan-visiting-action-set
)
2201 (action-list plan-visiting-action-list
)) plan
2202 (let ((action (cons operation component
)))
2203 (when (gethash action action-set
)
2204 (error 'circular-dependency
:actions
2205 (member action
(reverse action-list
) :test
'equal
)))
2206 (setf (gethash action action-set
) t
)
2207 (push action action-list
)
2211 (setf (gethash action action-set
) nil
))))))
2214 ;;;; Actual traversal: traverse-action
2215 (with-upgradability ()
2216 (define-condition circular-dependency
(system-definition-error)
2217 ((actions :initarg
:actions
:reader circular-dependency-actions
))
2218 (:report
(lambda (c s
)
2219 (format s
(compatfmt "~@<Circular dependency: ~3i~_~S~@:>")
2220 (circular-dependency-actions c
)))))
2222 (defmacro while-visiting-action
((p o c
) &body body
)
2223 `(call-while-visiting-action ,p
,o
,c
#'(lambda () ,@body
)))
2225 (defgeneric traverse-action
(plan operation component needed-in-image-p
))
2227 ;; TRAVERSE-ACTION, in the context of a given PLAN object that accumulates dependency data,
2228 ;; visits the action defined by its OPERATION and COMPONENT arguments,
2229 ;; and all its transitive dependencies (unless already visited),
2230 ;; in the context of the action being (or not) NEEDED-IN-IMAGE-P,
2231 ;; i.e. needs to be done in the current image vs merely have been done in a previous image.
2232 ;; For actions that are up-to-date, it returns a STAMP identifying the state of the action
2233 ;; (that's timestamp, but it could be a cryptographic digest in some ASDF extension),
2234 ;; or T if the action needs to be done again.
2236 ;; Note that for an XCVB-like plan with one-image-per-file-outputting-action,
2237 ;; the below method would be insufficient, since it assumes a single image
2238 ;; to traverse each node at most twice; non-niip actions would be traversed only once,
2239 ;; but niip nodes could be traversed once per image, i.e. once plus once per non-niip action.
2241 (defmethod traverse-action (plan operation component needed-in-image-p
)
2243 ;; ACTION-VALID-P among other things, handles forcing logic, including FORCE-NOT,
2244 ;; and IF-FEATURE filtering.
2245 (unless (action-valid-p plan operation component
) (return nil
))
2246 ;; the following hook is needed by POIU, which tracks a full dependency graph,
2247 ;; instead of just a dependency order as in vanilla ASDF
2248 (plan-record-dependency plan operation component
)
2249 ;; needed in image distinguishes b/w things that must happen in the
2250 ;; current image and those things that simply need to have been done in a previous one.
2251 (let* ((aniip (needed-in-image-p operation component
)) ; action-specific needed-in-image
2252 ;; effective niip: meaningful for the action and required by the plan as traversed
2253 (eniip (and aniip needed-in-image-p
))
2254 ;; status: have we traversed that action previously, and if so what was its status?
2255 (status (plan-action-status plan operation component
)))
2256 (when (and status
(or (action-done-p status
) (action-planned-p status
) (not eniip
)))
2257 (return (action-stamp status
))) ; Already visited with sufficient need-in-image level!
2258 (labels ((visit-action (niip) ; We may visit the action twice, once with niip NIL, then T
2259 (map-direct-dependencies ; recursively traverse dependencies
2260 plan operation component
#'(lambda (o c
) (traverse-action plan o c niip
)))
2261 (multiple-value-bind (stamp done-p
) ; AFTER dependencies have been traversed,
2262 (compute-action-stamp plan operation component
) ; compute action stamp
2263 (let ((add-to-plan-p (or (eql stamp t
) (and niip
(not done-p
)))))
2264 (cond ; it needs be done if it's out of date or needed in image but absent
2265 ((and add-to-plan-p
(not niip
)) ; if we need to do it,
2266 (visit-action t
)) ; then we need to do it *in the (current) image*!
2268 (setf (plan-action-status plan operation component
) ; update status:
2270 'planned-action-status
2271 :stamp stamp
; computed stamp
2272 :done-p
(and done-p
(not add-to-plan-p
)) ; done *and* up-to-date?
2273 :planned-p add-to-plan-p
; included in list of things to be done?
2274 :index
(if status
; index of action amongst all nodes in traversal
2275 (action-index status
) ;; if already visited, keep index
2276 (incf (plan-total-action-count plan
))))) ; else new index
2277 (when add-to-plan-p
; if it needs to be added to the plan,
2278 (incf (plan-planned-action-count plan
)) ; count it
2279 (unless aniip
; if it's output-producing,
2280 (incf (plan-planned-output-action-count plan
)))) ; count it
2281 stamp
)))))) ; return the stamp
2282 (while-visiting-action (plan operation component
) ; maintain context, handle circularity.
2283 (visit-action eniip
))))))) ; visit the action
2286 ;;;; Sequential plans (the default)
2287 (with-upgradability ()
2288 (defclass sequential-plan
(plan-traversal)
2289 ((actions-r :initform nil
:accessor plan-actions-r
)))
2291 (defgeneric plan-actions
(plan))
2292 (defmethod plan-actions ((plan list
))
2294 (defmethod plan-actions ((plan sequential-plan
))
2295 (reverse (plan-actions-r plan
)))
2297 (defmethod plan-record-dependency ((plan sequential-plan
) (o operation
) (c component
))
2300 (defmethod (setf plan-action-status
) :after
2301 (new-status (p sequential-plan
) (o operation
) (c component
))
2302 (when (action-planned-p new-status
)
2303 (push (cons o c
) (plan-actions-r p
)))))
2305 ;;;; High-level interface: traverse, perform-plan, plan-operates-on-p
2306 (with-upgradability ()
2307 (defgeneric make-plan
(plan-class operation component
&key
&allow-other-keys
)
2309 "Generate and return a plan for performing OPERATION on COMPONENT."))
2310 (define-convenience-action-methods make-plan
(plan-class operation component
&key
))
2312 (defgeneric perform-plan
(plan &key
))
2313 (defgeneric plan-operates-on-p
(plan component
))
2315 (defvar *default-plan-class
* 'sequential-plan
)
2317 (defmethod make-plan (plan-class (o operation
) (c component
) &rest keys
&key
&allow-other-keys
)
2318 (let ((plan (apply 'make-instance
(or plan-class
*default-plan-class
*)
2319 :system
(component-system c
) keys
)))
2320 (traverse-action plan o c t
)
2323 (defmethod perform-plan :around
((plan t
) &key
)
2324 #+xcl
(declare (ignorable plan
))
2325 (let ((*package
* *package
*)
2326 (*readtable
* *readtable
*))
2327 (with-compilation-unit () ;; backward-compatibility.
2328 (call-next-method)))) ;; Going forward, see deferred-warning support in lisp-build.
2330 (defmethod perform-plan ((plan t
) &rest keys
&key
&allow-other-keys
)
2331 (apply 'perform-plan
(plan-actions plan
) keys
))
2333 (defmethod perform-plan ((steps list
) &key force
&allow-other-keys
)
2334 (loop* :for
(o . c
) :in steps
2335 :when
(or force
(not (nth-value 1 (compute-action-stamp nil o c
))))
2336 :do
(perform-with-restarts o c
)))
2338 (defmethod plan-operates-on-p ((plan plan-traversal
) (component-path list
))
2339 (plan-operates-on-p (plan-actions plan
) component-path
))
2341 (defmethod plan-operates-on-p ((plan list
) (component-path list
))
2342 (find component-path
(mapcar 'cdr plan
)
2343 :test
'equal
:key
'component-find-path
)))
2346 ;;;; Incidental traversals
2348 ;;; Making a FILTERED-SEQUENTIAL-PLAN can be used to, e.g., all of the source
2349 ;;; files required by a bundling operation.
2350 (with-upgradability ()
2351 (defclass filtered-sequential-plan
(sequential-plan)
2352 ((action-filter :initform t
:initarg
:action-filter
:reader plan-action-filter
)
2353 (component-type :initform t
:initarg
:component-type
:reader plan-component-type
)
2354 (keep-operation :initform t
:initarg
:keep-operation
:reader plan-keep-operation
)
2355 (keep-component :initform t
:initarg
:keep-component
:reader plan-keep-component
)))
2357 (defmethod initialize-instance :after
((plan filtered-sequential-plan
)
2358 &key force force-not
2360 (declare (ignore force force-not
))
2361 (with-slots (forced forced-not action-filter system
) plan
2362 (setf forced
(normalize-forced-systems (if other-systems
:all t
) system
))
2363 (setf forced-not
(normalize-forced-not-systems (if other-systems nil t
) system
))
2364 (setf action-filter
(ensure-function action-filter
))))
2366 (defmethod action-valid-p ((plan filtered-sequential-plan
) o c
)
2367 (and (funcall (plan-action-filter plan
) o c
)
2368 (typep c
(plan-component-type plan
))
2369 (call-next-method)))
2371 (defmethod traverse-actions (actions &rest keys
&key plan-class
&allow-other-keys
)
2372 (let ((plan (apply 'make-instance
(or plan-class
'filtered-sequential-plan
) keys
)))
2373 (loop* :for
(o . c
) :in actions
:do
(traverse-action plan o c t
))
2376 (define-convenience-action-methods traverse-sub-actions
(operation component
&key
))
2377 (defmethod traverse-sub-actions ((operation operation
) (component component
)
2378 &rest keys
&key
&allow-other-keys
)
2379 (apply 'traverse-actions
(direct-dependencies t operation component
)
2380 :system
(component-system component
) keys
))
2382 (defmethod plan-actions ((plan filtered-sequential-plan
))
2383 (with-slots (keep-operation keep-component
) plan
2384 (loop* :for
(o . c
) :in
(call-next-method)
2385 :when
(and (typep o keep-operation
) (typep c keep-component
))
2386 :collect
(cons o c
))))
2388 (defmethod required-components (system &rest keys
&key
(goal-operation 'load-op
) &allow-other-keys
)
2390 (mapcar 'cdr
(plan-actions
2391 (apply 'traverse-sub-actions goal-operation system
2392 (remove-plist-key :goal-operation keys
))))
2395 ;;;; -------------------------------------------------------------------------
2396 ;;;; Invoking Operations
2398 (uiop/package
:define-package
:asdf
/operate
2399 (:recycle
:asdf
/operate
:asdf
)
2400 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/cache
2401 :asdf
/component
:asdf
/system
:asdf
/operation
:asdf
/action
2402 :asdf
/find-system
:asdf
/find-component
:asdf
/lisp-action
:asdf
/plan
)
2405 #:*systems-being-operated
*
2407 #:load-system
#:load-systems
#:load-systems
*
2408 #:compile-system
#:test-system
#:require-system
2409 #:*load-system-operation
* #:module-provide-asdf
2410 #:component-loaded-p
#:already-loaded-systems
))
2411 (in-package :asdf
/operate
)
2413 (with-upgradability ()
2414 (defgeneric* (operate) (operation component
&key
&allow-other-keys
)
2416 "Operate does three things:
2418 1. It creates an instance of OPERATION-CLASS using any keyword parameters as initargs.
2419 2. It finds the asdf-system specified by SYSTEM (possibly loading it from disk).
2420 3. It then calls MAKE-PLAN with the operation and system as arguments
2422 The operation of making a plan is wrapped in WITH-COMPILATION-UNIT and error
2423 handling code. If a VERSION argument is supplied, then operate also ensures
2424 that the system found satisfies it using the VERSION-SATISFIES method.
2426 Note that dependencies may cause the operation to invoke other operations on the system
2427 or its components: the new operations will be created with the same initargs as the original one.
2429 The :FORCE or :FORCE-NOT argument to OPERATE can be:
2430 T to force the inside of the specified system to be rebuilt (resp. not),
2431 without recursively forcing the other systems we depend on.
2432 :ALL to force all systems including other systems we depend on to be rebuilt (resp. not).
2433 (SYSTEM1 SYSTEM2 ... SYSTEMN) to force systems named in a given list
2434 :FORCE has precedence over :FORCE-NOT; builtin systems cannot be forced."))
2436 (define-convenience-action-methods
2437 operate
(operation component
&key
)
2438 ;; I'd like to at least remove-plist-keys :force :force-not :verbose,
2439 ;; but swank.asd relies on :force (!).
2440 :operation-initargs t
;; backward-compatibility with ASDF1. Yuck.
2441 :if-no-component
(error 'missing-component
:requires component
))
2443 (defvar *systems-being-operated
* nil
2444 "A boolean indicating that some systems are being operated on")
2446 (defmethod operate :around
(operation component
&rest keys
2448 (on-warnings *compile-file-warnings-behaviour
*)
2449 (on-failure *compile-file-failure-behaviour
*) &allow-other-keys
)
2450 (let* ((systems-being-operated *systems-being-operated
*)
2451 (*systems-being-operated
* (or systems-being-operated
(make-hash-table :test
'equal
)))
2452 (operation-remaker ;; how to remake the operation after ASDF was upgraded (if it was)
2453 (etypecase operation
2454 (operation (let ((name (type-of operation
))
2455 (initargs (operation-original-initargs operation
)))
2456 #'(lambda () (apply 'make-operation name
:original-initargs initargs initargs
))))
2457 ((or symbol string
) (constantly operation
))))
2458 (component-path (typecase component
;; to remake the component after ASDF upgrade
2459 (component (component-find-path component
))
2461 ;; Before we operate on any system, make sure ASDF is up-to-date,
2462 ;; for if an upgrade is ever attempted at any later time, there may be BIG trouble.
2463 (unless systems-being-operated
2464 (when (upgrade-asdf)
2465 ;; If we were upgraded, restart OPERATE the hardest of ways, for
2466 ;; its function may have been redefined, its symbol uninterned, its package deleted.
2467 (return-from operate
2468 (apply 'operate
(funcall operation-remaker
) component-path keys
))))
2469 ;; Setup proper bindings around any operate call.
2471 (let* ((*verbose-out
* (and verbose
*standard-output
*))
2472 (*compile-file-warnings-behaviour
* on-warnings
)
2473 (*compile-file-failure-behaviour
* on-failure
))
2474 (call-next-method)))))
2476 (defmethod operate :before
((operation operation
) (component component
)
2477 &key version
&allow-other-keys
)
2478 (let ((system (component-system component
)))
2479 (setf (gethash (coerce-name system
) *systems-being-operated
*) system
))
2480 (unless (version-satisfies component version
)
2481 (error 'missing-component-of-version
:requires component
:version version
)))
2483 (defmethod operate ((operation operation
) (component component
)
2484 &rest keys
&key plan-class
&allow-other-keys
)
2485 (let ((plan (apply 'make-plan plan-class operation component keys
)))
2486 (apply 'perform-plan plan keys
)
2487 (values operation plan
)))
2489 (defun oos (operation component
&rest args
&key
&allow-other-keys
)
2490 (apply 'operate operation component args
))
2492 (setf (documentation 'oos
'function
)
2493 (format nil
"Short for _operate on system_ and an alias for the OPERATE function.~%~%~a"
2494 (documentation 'operate
'function
))))
2497 ;;;; Common operations
2498 (with-upgradability ()
2499 (defvar *load-system-operation
* 'load-op
2500 "Operation used by ASDF:LOAD-SYSTEM. By default, ASDF:LOAD-OP.
2501 You may override it with e.g. ASDF:LOAD-FASL-OP from asdf-bundle
2502 or ASDF:LOAD-SOURCE-OP if your fasl loading is somehow broken.
2504 The default operation may change in the future if we implement a
2505 component-directed strategy for how to load or compile systems.")
2507 (defmethod component-depends-on ((o prepare-op
) (s system
))
2508 (loop :for
(o . cs
) :in
(call-next-method)
2509 :collect
(cons (if (eq o
'load-op
) *load-system-operation
* o
) cs
)))
2511 (defclass build-op
(non-propagating-operation) ()
2512 (:documentation
"Since ASDF3, BUILD-OP is the recommended 'master' operation,
2513 to operate by default on a system or component, via the function BUILD.
2514 Its meaning is configurable via the :BUILD-OPERATION option of a component.
2515 which typically specifies the name of a specific operation to which to delegate the build,
2516 as a symbol or as a string later read as a symbol (after loading the defsystem-depends-on);
2517 if NIL is specified (the default), BUILD-OP falls back to the *LOAD-SYSTEM-OPERATION*
2518 that will load the system in the current image, and its typically LOAD-OP."))
2519 (defmethod component-depends-on ((o build-op
) (c component
))
2520 `((,(or (component-build-operation c
) *load-system-operation
*) ,c
)
2521 ,@(call-next-method)))
2523 (defun make (system &rest keys
)
2524 "The recommended way to interact with ASDF3.1 is via (ASDF:MAKE :FOO).
2525 It will build system FOO using the operation BUILD-OP,
2526 the meaning of which is configurable by the system, and
2527 defaults to *LOAD-SYSTEM-OPERATION*, usually LOAD-OP,
2528 to load it in current image."
2529 (apply 'operate
'build-op system keys
)
2532 (defun load-system (system &rest keys
&key force force-not verbose version
&allow-other-keys
)
2533 "Shorthand for `(operate 'asdf:load-op system)`. See OPERATE for details."
2534 (declare (ignore force force-not verbose version
))
2535 (apply 'operate
*load-system-operation
* system keys
)
2538 (defun load-systems* (systems &rest keys
)
2539 "Loading multiple systems at once."
2540 (dolist (s systems
) (apply 'load-system s keys
)))
2542 (defun load-systems (&rest systems
)
2543 "Loading multiple systems at once."
2544 (load-systems* systems
))
2546 (defun compile-system (system &rest args
&key force force-not verbose version
&allow-other-keys
)
2547 "Shorthand for `(asdf:operate 'asdf:compile-op system)`. See OPERATE for details."
2548 (declare (ignore force force-not verbose version
))
2549 (apply 'operate
'compile-op system args
)
2552 (defun test-system (system &rest args
&key force force-not verbose version
&allow-other-keys
)
2553 "Shorthand for `(asdf:operate 'asdf:test-op system)`. See OPERATE for details."
2554 (declare (ignore force force-not verbose version
))
2555 (apply 'operate
'test-op system args
)
2558 ;;;;; Define the function REQUIRE-SYSTEM, that, similarly to REQUIRE,
2559 ;; only tries to load its specified target if it's not loaded yet.
2560 (with-upgradability ()
2561 (defun component-loaded-p (component)
2562 "has given COMPONENT been successfully loaded in the current image (yet)?"
2563 (action-already-done-p nil
(make-instance 'load-op
) (find-component component
())))
2565 (defun already-loaded-systems ()
2566 "return a list of the names of the systems that have been successfully loaded so far"
2567 (remove-if-not 'component-loaded-p
(registered-systems)))
2569 (defun require-system (system &rest keys
&key
&allow-other-keys
)
2570 "Ensure the specified SYSTEM is loaded, passing the KEYS to OPERATE, but skip any update to the
2571 system or its dependencies if they have already been loaded."
2572 (apply 'load-system system
:force-not
(already-loaded-systems) keys
)))
2575 ;;;; Define the class REQUIRE-SYSTEM, to be hooked into CL:REQUIRE when possible,
2576 ;; i.e. for ABCL, CLISP, ClozureCL, CMUCL, ECL, MKCL and SBCL
2577 (with-upgradability ()
2578 (defvar *modules-being-required
* nil
)
2580 (defclass require-system
(system)
2581 ((module :initarg
:module
:initform nil
:accessor required-module
))
2582 (:documentation
"A SYSTEM subclass whose processing is handled by
2583 the implementation's REQUIRE rather than by internal ASDF mechanisms."))
2585 (defmethod perform ((o compile-op
) (c require-system
))
2588 (defmethod perform ((o load-op
) (s require-system
))
2589 (let* ((module (or (required-module s
) (coerce-name s
)))
2590 (*modules-being-required
* (cons module
*modules-being-required
*)))
2591 (assert (null (component-children s
)))
2594 (defmethod resolve-dependency-combination (component (combinator (eql :require
)) arguments
)
2595 (unless (length=n-p arguments
1)
2596 (error (compatfmt "~@<Bad dependency ~S for ~S. ~S takes only one argument~@:>")
2597 (cons combinator arguments
) component combinator
))
2598 (let* ((module (car arguments
))
2599 (name (string-downcase module
))
2600 (system (find-system name nil
)))
2602 ;;(unless (typep system '(or null require-system))
2603 ;; (warn "~S depends on ~S but ~S is registered as a ~S"
2604 ;; component (cons combinator arguments) module (type-of system)))
2605 (or system
(let ((system (make-instance 'require-system
:name name
)))
2606 (register-system system
)
2609 (defun module-provide-asdf (name)
2610 (let ((module (string-downcase name
)))
2611 (unless (member module
*modules-being-required
* :test
'equal
)
2612 (let ((*modules-being-required
* (cons module
*modules-being-required
*))
2613 #+sbcl
(sb-impl::*requiring
* (remove module sb-impl
::*requiring
* :test
'equal
)))
2615 ((style-warning #'muffle-warning
)
2616 (missing-component (constantly nil
))
2617 (error #'(lambda (e)
2618 (format *error-output
* (compatfmt "~@<ASDF could not load ~(~A~) because ~A.~@:>~%")
2620 (let ((*verbose-out
* (make-broadcast-stream)))
2621 (let ((system (find-system module nil
)))
2623 (require-system system
:verbose nil
)
2627 ;;;; Some upgrade magic
2628 (with-upgradability ()
2629 (defun restart-upgraded-asdf ()
2630 ;; If we're in the middle of something, restart it.
2632 (let ((l (loop :for k
:being
:the hash-keys
:of
*asdf-cache
*
2633 :when
(eq (first k
) 'find-system
) :collect
(second k
))))
2634 (clrhash *asdf-cache
*)
2635 (dolist (s l
) (find-system s nil
)))))
2636 (register-hook-function '*post-upgrade-restart-hook
* 'restart-upgraded-asdf
))
2639 ;;;; ---------------------------------------------------------------------------
2640 ;;;; asdf-output-translations
2642 (uiop/package
:define-package
:asdf
/output-translations
2643 (:recycle
:asdf
/output-translations
:asdf
)
2644 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
)
2646 #:*output-translations
* #:*output-translations-parameter
*
2647 #:invalid-output-translation
2648 #:output-translations
#:output-translations-initialized-p
2649 #:initialize-output-translations
#:clear-output-translations
2650 #:disable-output-translations
#:ensure-output-translations
2651 #:apply-output-translations
2652 #:validate-output-translations-directive
#:validate-output-translations-form
2653 #:validate-output-translations-file
#:validate-output-translations-directory
2654 #:parse-output-translations-string
#:wrapping-output-translations
2655 #:user-output-translations-pathname
#:system-output-translations-pathname
2656 #:user-output-translations-directory-pathname
#:system-output-translations-directory-pathname
2657 #:environment-output-translations
#:process-output-translations
2658 #:compute-output-translations
2659 #+abcl
#:translate-jar-pathname
2661 (in-package :asdf
/output-translations
)
2663 (when-upgrading () (undefine-function '(setf output-translations
)))
2665 (with-upgradability ()
2666 (define-condition invalid-output-translation
(invalid-configuration warning
)
2667 ((format :initform
(compatfmt "~@<Invalid asdf output-translation ~S~@[ in ~S~]~@{ ~@?~}~@:>"))))
2669 (defvar *output-translations
* ()
2670 "Either NIL (for uninitialized), or a list of one element,
2671 said element itself being a sorted list of mappings.
2672 Each mapping is a pair of a source pathname and destination pathname,
2673 and the order is by decreasing length of namestring of the source pathname.")
2675 (defun output-translations ()
2676 (car *output-translations
*))
2678 (defun set-output-translations (new-value)
2679 (setf *output-translations
*
2681 (stable-sort (copy-list new-value
) #'>
2686 (let ((directory (pathname-directory (car x
))))
2687 (if (listp directory
) (length directory
) 0))))))))
2689 (defun* ((setf output-translations
)) (new-value) (set-output-translations new-value
))
2691 (defun output-translations-initialized-p ()
2692 (and *output-translations
* t
))
2694 (defun clear-output-translations ()
2695 "Undoes any initialization of the output translations."
2696 (setf *output-translations
* '())
2698 (register-clear-configuration-hook 'clear-output-translations
)
2700 (defun validate-output-translations-directive (directive)
2701 (or (member directive
'(:enable-user-cache
:disable-cache nil
))
2702 (and (consp directive
)
2703 (or (and (length=n-p directive
2)
2704 (or (and (eq (first directive
) :include
)
2705 (typep (second directive
) '(or string pathname null
)))
2706 (and (location-designator-p (first directive
))
2707 (or (location-designator-p (second directive
))
2708 (location-function-p (second directive
))))))
2709 (and (length=n-p directive
1)
2710 (location-designator-p (first directive
)))))))
2712 (defun validate-output-translations-form (form &key location
)
2713 (validate-configuration-form
2715 :output-translations
2716 'validate-output-translations-directive
2717 :location location
:invalid-form-reporter
'invalid-output-translation
))
2719 (defun validate-output-translations-file (file)
2720 (validate-configuration-file
2721 file
'validate-output-translations-form
:description
"output translations"))
2723 (defun validate-output-translations-directory (directory)
2724 (validate-configuration-directory
2725 directory
:output-translations
'validate-output-translations-directive
2726 :invalid-form-reporter
'invalid-output-translation
))
2728 (defun parse-output-translations-string (string &key location
)
2730 ((or (null string
) (equal string
""))
2731 '(:output-translations
:inherit-configuration
))
2732 ((not (stringp string
))
2733 (error (compatfmt "~@<Environment string isn't: ~3i~_~S~@:>") string
))
2734 ((eql (char string
0) #\")
2735 (parse-output-translations-string (read-from-string string
) :location location
))
2736 ((eql (char string
0) #\
()
2737 (validate-output-translations-form (read-from-string string
) :location location
))
2741 :with directives
= ()
2743 :with end
= (length string
)
2745 :with separator
= (inter-directory-separator)
2746 :for i
= (or (position separator string
:start start
) end
) :do
2747 (let ((s (subseq string start i
)))
2750 (push (list source
(if (equal "" s
) nil s
)) directives
)
2754 (error (compatfmt "~@<Only one inherited configuration allowed: ~3i~_~S~@:>")
2757 (push :inherit-configuration directives
))
2763 (error (compatfmt "~@<Uneven number of components in source to destination mapping: ~3i~_~S~@:>")
2766 (push :ignore-inherited-configuration directives
))
2767 (return `(:output-translations
,@(nreverse directives
)))))))))
2769 (defparameter* *default-output-translations
*
2770 '(environment-output-translations
2771 user-output-translations-pathname
2772 user-output-translations-directory-pathname
2773 system-output-translations-pathname
2774 system-output-translations-directory-pathname
))
2776 (defun wrapping-output-translations ()
2777 `(:output-translations
2778 ;; Some implementations have precompiled ASDF systems,
2779 ;; so we must disable translations for implementation paths.
2780 #+(or clasp
#|clozure|
# ecl mkcl sbcl
)
2781 ,@(let ((h (resolve-symlinks* (lisp-implementation-directory))))
2782 (when h
`(((,h
,*wild-path
*) ()))))
2783 #+mkcl
(,(translate-logical-pathname "CONTRIB:") ())
2784 ;; All-import, here is where we want user stuff to be:
2785 :inherit-configuration
2786 ;; These are for convenience, and can be overridden by the user:
2787 #+abcl
(#p
"/___jar___file___root___/**/*.*" (:user-cache
#p
"**/*.*"))
2788 #+abcl
(#p
"jar:file:/**/*.jar!/**/*.*" (:function translate-jar-pathname
))
2789 ;; We enable the user cache by default, and here is the place we do:
2790 :enable-user-cache
))
2792 (defparameter *output-translations-file
* (parse-unix-namestring "common-lisp/asdf-output-translations.conf"))
2793 (defparameter *output-translations-directory
* (parse-unix-namestring "common-lisp/asdf-output-translations.conf.d/"))
2795 (defun user-output-translations-pathname (&key
(direction :input
))
2796 (xdg-config-pathname *output-translations-file
* direction
))
2797 (defun system-output-translations-pathname (&key
(direction :input
))
2798 (find-preferred-file (system-config-pathnames *output-translations-file
*)
2799 :direction direction
))
2800 (defun user-output-translations-directory-pathname (&key
(direction :input
))
2801 (xdg-config-pathname *output-translations-directory
* direction
))
2802 (defun system-output-translations-directory-pathname (&key
(direction :input
))
2803 (find-preferred-file (system-config-pathnames *output-translations-directory
*)
2804 :direction direction
))
2805 (defun environment-output-translations ()
2806 (getenv "ASDF_OUTPUT_TRANSLATIONS"))
2808 (defgeneric process-output-translations
(spec &key inherit collect
))
2810 (defun inherit-output-translations (inherit &key collect
)
2812 (process-output-translations (first inherit
) :collect collect
:inherit
(rest inherit
))))
2814 (defun* (process-output-translations-directive) (directive &key inherit collect
)
2815 (if (atom directive
)
2817 ((:enable-user-cache
)
2818 (process-output-translations-directive '(t :user-cache
) :collect collect
))
2820 (process-output-translations-directive '(t t
) :collect collect
))
2821 ((:inherit-configuration
)
2822 (inherit-output-translations inherit
:collect collect
))
2823 ((:ignore-inherited-configuration
:ignore-invalid-entries nil
)
2825 (let ((src (first directive
))
2826 (dst (second directive
)))
2827 (if (eq src
:include
)
2829 (process-output-translations (pathname dst
) :inherit nil
:collect collect
))
2831 (let ((trusrc (or (eql src t
)
2832 (let ((loc (resolve-location src
:ensure-directory t
:wilden t
)))
2833 (if (absolute-pathname-p loc
) (resolve-symlinks* loc
) loc
)))))
2835 ((location-function-p dst
)
2837 (list trusrc
(ensure-function (second dst
)))))
2838 ((typep dst
'boolean
)
2839 (funcall collect
(list trusrc t
)))
2841 (let* ((trudst (resolve-location dst
:ensure-directory t
:wilden t
)))
2842 (funcall collect
(list trudst t
))
2843 (funcall collect
(list trusrc trudst
)))))))))))
2845 (defmethod process-output-translations ((x symbol
) &key
2846 (inherit *default-output-translations
*)
2848 (process-output-translations (funcall x
) :inherit inherit
:collect collect
))
2849 (defmethod process-output-translations ((pathname pathname
) &key inherit collect
)
2851 ((directory-pathname-p pathname
)
2852 (process-output-translations (validate-output-translations-directory pathname
)
2853 :inherit inherit
:collect collect
))
2854 ((probe-file* pathname
:truename
*resolve-symlinks
*)
2855 (process-output-translations (validate-output-translations-file pathname
)
2856 :inherit inherit
:collect collect
))
2858 (inherit-output-translations inherit
:collect collect
))))
2859 (defmethod process-output-translations ((string string
) &key inherit collect
)
2860 (process-output-translations (parse-output-translations-string string
)
2861 :inherit inherit
:collect collect
))
2862 (defmethod process-output-translations ((x null
) &key inherit collect
)
2863 (inherit-output-translations inherit
:collect collect
))
2864 (defmethod process-output-translations ((form cons
) &key inherit collect
)
2865 (dolist (directive (cdr (validate-output-translations-form form
)))
2866 (process-output-translations-directive directive
:inherit inherit
:collect collect
)))
2868 (defun compute-output-translations (&optional parameter
)
2869 "read the configuration, return it"
2871 (while-collecting (c)
2872 (inherit-output-translations
2873 `(wrapping-output-translations ,parameter
,@*default-output-translations
*) :collect
#'c
))
2874 :test
'equal
:from-end t
))
2876 (defvar *output-translations-parameter
* nil
)
2878 (defun initialize-output-translations (&optional
(parameter *output-translations-parameter
*))
2879 "read the configuration, initialize the internal configuration variable,
2880 return the configuration"
2881 (setf *output-translations-parameter
* parameter
2882 (output-translations) (compute-output-translations parameter
)))
2884 (defun disable-output-translations ()
2885 "Initialize output translations in a way that maps every file to itself,
2886 effectively disabling the output translation facility."
2887 (initialize-output-translations
2888 '(:output-translations
:disable-cache
:ignore-inherited-configuration
)))
2890 ;; checks an initial variable to see whether the state is initialized
2891 ;; or cleared. In the former case, return current configuration; in
2892 ;; the latter, initialize. ASDF will call this function at the start
2893 ;; of (asdf:find-system).
2894 (defun ensure-output-translations ()
2895 (if (output-translations-initialized-p)
2896 (output-translations)
2897 (initialize-output-translations)))
2899 (defun* (apply-output-translations) (path)
2903 ((or pathname string
)
2904 (ensure-output-translations)
2905 (loop* :with p
= (resolve-symlinks* path
)
2906 :for
(source destination
) :in
(car *output-translations
*)
2907 :for root
= (when (or (eq source t
)
2908 (and (pathnamep source
)
2909 (not (absolute-pathname-p source
))))
2911 :for absolute-source
= (cond
2912 ((eq source t
) (wilden root
))
2913 (root (merge-pathnames* source root
))
2915 :when
(or (eq source t
) (pathname-match-p p absolute-source
))
2916 :return
(translate-pathname* p absolute-source destination root source
)
2917 :finally
(return p
)))))
2919 ;; Hook into uiop's output-translation mechanism
2921 (setf *output-translation-function
* 'apply-output-translations
)
2924 (defun translate-jar-pathname (source wildcard
)
2925 (declare (ignore wildcard
))
2926 (flet ((normalize-device (pathname)
2927 (if (find :windows
*features
*)
2929 (make-pathname :defaults pathname
:device
:unspecific
))))
2931 (pathname (first (pathname-device source
))))
2932 (target-root-directory-namestring
2933 (format nil
"/___jar___file___root___/~@[~A/~]"
2934 (and (find :windows
*features
*)
2935 (pathname-device jar
))))
2937 (relativize-pathname-directory source
))
2939 (relativize-pathname-directory (ensure-directory-pathname jar
)))
2940 (target-root-directory
2942 (pathname-directory-pathname
2943 (parse-namestring target-root-directory-namestring
))))
2945 (merge-pathnames* relative-jar target-root-directory
))
2947 (merge-pathnames* relative-source target-root
)))
2948 (normalize-device (apply-output-translations target
))))))
2950 ;;;; -----------------------------------------------------------------
2951 ;;;; Source Registry Configuration, by Francois-Rene Rideau
2952 ;;;; See the Manual and https://bugs.launchpad.net/asdf/+bug/485918
2954 (uiop/package
:define-package
:asdf
/source-registry
2955 (:recycle
:asdf
/source-registry
:asdf
)
2956 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/find-system
)
2958 #:*source-registry-parameter
* #:*default-source-registries
*
2959 #:invalid-source-registry
2960 #:source-registry-initialized-p
2961 #:initialize-source-registry
#:clear-source-registry
#:*source-registry
*
2962 #:ensure-source-registry
#:*source-registry-parameter
*
2963 #:*default-source-registry-exclusions
* #:*source-registry-exclusions
*
2964 #:*wild-asd
* #:directory-asd-files
#:register-asd-directory
2965 #:*recurse-beyond-asds
* #:collect-asds-in-directory
#:collect-sub
*directories-asd-files
2966 #:validate-source-registry-directive
#:validate-source-registry-form
2967 #:validate-source-registry-file
#:validate-source-registry-directory
2968 #:parse-source-registry-string
#:wrapping-source-registry
2969 #:default-user-source-registry
#:default-system-source-registry
2970 #:user-source-registry
#:system-source-registry
2971 #:user-source-registry-directory
#:system-source-registry-directory
2972 #:environment-source-registry
#:process-source-registry
2973 #:compute-source-registry
#:flatten-source-registry
2974 #:sysdef-source-registry-search
))
2975 (in-package :asdf
/source-registry
)
2977 (with-upgradability ()
2978 (define-condition invalid-source-registry
(invalid-configuration warning
)
2979 ((format :initform
(compatfmt "~@<Invalid source registry ~S~@[ in ~S~]~@{ ~@?~}~@:>"))))
2981 ;; Using ack 1.2 exclusions
2982 (defvar *default-source-registry-exclusions
*
2984 ;; "~.dep" "~.dot" "~.nib" "~.plst" ; we don't support ack wildcards
2985 ".git" ".hg" ".pc" ".svn" "CVS" "RCS" "SCCS" "_darcs"
2986 "_sgbak" "autom4te.cache" "cover_db" "_build"
2987 "debian")) ;; debian often builds stuff under the debian directory... BAD.
2989 (defvar *source-registry-exclusions
* *default-source-registry-exclusions
*)
2991 (defvar *source-registry
* nil
2992 "Either NIL (for uninitialized), or an equal hash-table, mapping
2993 system names to pathnames of .asd files")
2995 (defun source-registry-initialized-p ()
2996 (typep *source-registry
* 'hash-table
))
2998 (defun clear-source-registry ()
2999 "Undoes any initialization of the source registry."
3000 (setf *source-registry
* nil
)
3002 (register-clear-configuration-hook 'clear-source-registry
)
3004 (defparameter *wild-asd
*
3005 (make-pathname* :directory nil
:name
*wild
* :type
"asd" :version
:newest
))
3007 (defun directory-asd-files (directory)
3008 (directory-files directory
*wild-asd
*))
3010 (defun collect-asds-in-directory (directory collect
)
3011 (let ((asds (directory-asd-files directory
)))
3012 (map () collect asds
)
3015 (defvar *recurse-beyond-asds
* t
3016 "Should :tree entries of the source-registry recurse in subdirectories
3017 after having found a .asd file? True by default.")
3019 (defun process-source-registry-cache (directory collect
)
3020 (let ((cache (ignore-errors
3021 (safe-read-file-form (subpathname directory
".cl-source-registry.cache")))))
3022 (when (and (listp cache
) (eq :source-registry-cache
(first cache
)))
3023 (loop :for s
:in
(rest cache
) :do
(funcall collect
(subpathname directory s
)))
3026 (defun collect-sub*directories-asd-files
3027 (directory &key
(exclude *default-source-registry-exclusions
*) collect
3028 (recurse-beyond-asds *recurse-beyond-asds
*) ignore-cache
)
3029 (collect-sub*directories
3032 (unless (and (not ignore-cache
) (process-source-registry-cache directory collect
))
3033 (let ((asds (collect-asds-in-directory dir collect
)))
3034 (or recurse-beyond-asds
(not asds
)))))
3036 (not (member (car (last (pathname-directory x
))) exclude
:test
#'equal
)))
3039 (defun validate-source-registry-directive (directive)
3040 (or (member directive
'(:default-registry
))
3041 (and (consp directive
)
3042 (let ((rest (rest directive
)))
3043 (case (first directive
)
3044 ((:include
:directory
:tree
)
3045 (and (length=n-p rest
1)
3046 (location-designator-p (first rest
))))
3047 ((:exclude
:also-exclude
)
3048 (every #'stringp rest
))
3049 ((:default-registry
)
3052 (defun validate-source-registry-form (form &key location
)
3053 (validate-configuration-form
3054 form
:source-registry
'validate-source-registry-directive
3055 :location location
:invalid-form-reporter
'invalid-source-registry
))
3057 (defun validate-source-registry-file (file)
3058 (validate-configuration-file
3059 file
'validate-source-registry-form
:description
"a source registry"))
3061 (defun validate-source-registry-directory (directory)
3062 (validate-configuration-directory
3063 directory
:source-registry
'validate-source-registry-directive
3064 :invalid-form-reporter
'invalid-source-registry
))
3066 (defun parse-source-registry-string (string &key location
)
3068 ((or (null string
) (equal string
""))
3069 '(:source-registry
:inherit-configuration
))
3070 ((not (stringp string
))
3071 (error (compatfmt "~@<Environment string isn't: ~3i~_~S~@:>") string
))
3072 ((find (char string
0) "\"(")
3073 (validate-source-registry-form (read-from-string string
) :location location
))
3077 :with directives
= ()
3079 :with end
= (length string
)
3080 :with separator
= (inter-directory-separator)
3081 :for pos
= (position separator string
:start start
) :do
3082 (let ((s (subseq string start
(or pos end
))))
3084 (unless (absolute-pathname-p dir
)
3085 (error (compatfmt "~@<source-registry string must specify absolute pathnames: ~3i~_~S~@:>") string
))
3088 ((equal "" s
) ; empty element: inherit
3090 (error (compatfmt "~@<Only one inherited configuration allowed: ~3i~_~S~@:>")
3093 (push ':inherit-configuration directives
))
3094 ((string-suffix-p s
"//") ;; TODO: allow for doubling of separator even outside Unix?
3095 (push `(:tree
,(check (subseq s
0 (- (length s
) 2)))) directives
))
3097 (push `(:directory
,(check s
)) directives
))))
3100 (setf start
(1+ pos
)))
3103 (push '(:ignore-inherited-configuration
) directives
))
3104 (return `(:source-registry
,@(nreverse directives
))))))))))
3106 (defun register-asd-directory (directory &key recurse exclude collect
)
3108 (collect-asds-in-directory directory collect
)
3109 (collect-sub*directories-asd-files
3110 directory
:exclude exclude
:collect collect
)))
3112 (defparameter* *default-source-registries
*
3113 '(environment-source-registry
3114 user-source-registry
3115 user-source-registry-directory
3116 default-user-source-registry
3117 system-source-registry
3118 system-source-registry-directory
3119 default-system-source-registry
)
3120 "List of default source registries" "3.1.0.102")
3122 (defparameter *source-registry-file
* (parse-unix-namestring "common-lisp/source-registry.conf"))
3123 (defparameter *source-registry-directory
* (parse-unix-namestring "common-lisp/source-registry.conf.d/"))
3125 (defun wrapping-source-registry ()
3127 #+(or clasp ecl sbcl
) (:tree
,(resolve-symlinks* (lisp-implementation-directory)))
3128 :inherit-configuration
3129 #+mkcl
(:tree
,(translate-logical-pathname "CONTRIB:"))
3130 #+cmu
(:tree
#p
"modules:")
3131 #+scl
(:tree
#p
"file://modules/")))
3132 (defun default-user-source-registry ()
3134 (:tree
(:home
"common-lisp/"))
3135 #+sbcl
(:directory
(:home
".sbcl/systems/"))
3136 (:directory
,(xdg-data-home "common-lisp/systems/"))
3137 (:tree
,(xdg-data-home "common-lisp/source/"))
3138 :inherit-configuration
))
3139 (defun default-system-source-registry ()
3141 ,@(loop :for dir
:in
(xdg-data-dirs "common-lisp/")
3142 :collect
`(:directory
(,dir
"systems/"))
3143 :collect
`(:tree
(,dir
"source/")))
3144 :inherit-configuration
))
3145 (defun user-source-registry (&key
(direction :input
))
3146 (xdg-config-pathname *source-registry-file
* direction
))
3147 (defun system-source-registry (&key
(direction :input
))
3148 (find-preferred-file (system-config-pathnames *source-registry-file
*)
3149 :direction direction
))
3150 (defun user-source-registry-directory (&key
(direction :input
))
3151 (xdg-config-pathname *source-registry-directory
* direction
))
3152 (defun system-source-registry-directory (&key
(direction :input
))
3153 (find-preferred-file (system-config-pathnames *source-registry-directory
*)
3154 :direction direction
))
3155 (defun environment-source-registry ()
3156 (getenv "CL_SOURCE_REGISTRY"))
3158 (defgeneric* (process-source-registry) (spec &key inherit register
))
3160 (defun* (inherit-source-registry) (inherit &key register
)
3162 (process-source-registry (first inherit
) :register register
:inherit
(rest inherit
))))
3164 (defun* (process-source-registry-directive) (directive &key inherit register
)
3165 (destructuring-bind (kw &rest rest
) (if (consp directive
) directive
(list directive
))
3168 (destructuring-bind (pathname) rest
3169 (process-source-registry (resolve-location pathname
) :inherit nil
:register register
)))
3171 (destructuring-bind (pathname) rest
3173 (funcall register
(resolve-location pathname
:ensure-directory t
)))))
3175 (destructuring-bind (pathname) rest
3177 (funcall register
(resolve-location pathname
:ensure-directory t
)
3178 :recurse t
:exclude
*source-registry-exclusions
*))))
3180 (setf *source-registry-exclusions
* rest
))
3182 (appendf *source-registry-exclusions
* rest
))
3183 ((:default-registry
)
3184 (inherit-source-registry
3185 '(default-user-source-registry default-system-source-registry
) :register register
))
3186 ((:inherit-configuration
)
3187 (inherit-source-registry inherit
:register register
))
3188 ((:ignore-inherited-configuration
)
3192 (defmethod process-source-registry ((x symbol
) &key inherit register
)
3193 (process-source-registry (funcall x
) :inherit inherit
:register register
))
3194 (defmethod process-source-registry ((pathname pathname
) &key inherit register
)
3196 ((directory-pathname-p pathname
)
3197 (let ((*here-directory
* (resolve-symlinks* pathname
)))
3198 (process-source-registry (validate-source-registry-directory pathname
)
3199 :inherit inherit
:register register
)))
3200 ((probe-file* pathname
:truename
*resolve-symlinks
*)
3201 (let ((*here-directory
* (pathname-directory-pathname pathname
)))
3202 (process-source-registry (validate-source-registry-file pathname
)
3203 :inherit inherit
:register register
)))
3205 (inherit-source-registry inherit
:register register
))))
3206 (defmethod process-source-registry ((string string
) &key inherit register
)
3207 (process-source-registry (parse-source-registry-string string
)
3208 :inherit inherit
:register register
))
3209 (defmethod process-source-registry ((x null
) &key inherit register
)
3210 (inherit-source-registry inherit
:register register
))
3211 (defmethod process-source-registry ((form cons
) &key inherit register
)
3212 (let ((*source-registry-exclusions
* *default-source-registry-exclusions
*))
3213 (dolist (directive (cdr (validate-source-registry-form form
)))
3214 (process-source-registry-directive directive
:inherit inherit
:register register
))))
3216 (defun flatten-source-registry (&optional parameter
)
3218 (while-collecting (collect)
3219 (with-pathname-defaults () ;; be location-independent
3220 (inherit-source-registry
3221 `(wrapping-source-registry
3223 ,@*default-source-registries
*)
3224 :register
#'(lambda (directory &key recurse exclude
)
3225 (collect (list directory
:recurse recurse
:exclude exclude
))))))
3226 :test
'equal
:from-end t
))
3228 ;; Will read the configuration and initialize all internal variables.
3229 (defun compute-source-registry (&optional parameter
(registry *source-registry
*))
3230 (dolist (entry (flatten-source-registry parameter
))
3231 (destructuring-bind (directory &key recurse exclude
) entry
3232 (let* ((h (make-hash-table :test
'equal
))) ; table to detect duplicates
3233 (register-asd-directory
3234 directory
:recurse recurse
:exclude exclude
:collect
3236 (let* ((name (pathname-name asd
))
3237 (name (if (typep asd
'logical-pathname
)
3238 ;; logical pathnames are upper-case,
3239 ;; at least in the CLHS and on SBCL,
3240 ;; yet (coerce-name :foo) is lower-case.
3241 ;; won't work well with (load-system "Foo")
3242 ;; instead of (load-system 'foo)
3243 (string-downcase name
)
3246 ((gethash name registry
) ; already shadowed by something else
3248 ((gethash name h
) ; conflict at current level
3250 (warn (compatfmt "~@<In source-registry entry ~A~@[/~*~] ~
3251 found several entries for ~A - picking ~S over ~S~:>")
3252 directory recurse name
(gethash name h
) asd
)))
3254 (setf (gethash name registry
) asd
)
3255 (setf (gethash name h
) asd
))))))
3259 (defvar *source-registry-parameter
* nil
)
3261 (defun initialize-source-registry (&optional
(parameter *source-registry-parameter
*))
3262 ;; Record the parameter used to configure the registry
3263 (setf *source-registry-parameter
* parameter
)
3264 ;; Clear the previous registry database:
3265 (setf *source-registry
* (make-hash-table :test
'equal
))
3267 (compute-source-registry parameter
))
3269 ;; Checks an initial variable to see whether the state is initialized
3270 ;; or cleared. In the former case, return current configuration; in
3271 ;; the latter, initialize. ASDF will call this function at the start
3272 ;; of (asdf:find-system) to make sure the source registry is initialized.
3273 ;; However, it will do so *without* a parameter, at which point it
3274 ;; will be too late to provide a parameter to this function, though
3275 ;; you may override the configuration explicitly by calling
3276 ;; initialize-source-registry directly with your parameter.
3277 (defun ensure-source-registry (&optional parameter
)
3278 (unless (source-registry-initialized-p)
3279 (initialize-source-registry parameter
))
3282 (defun sysdef-source-registry-search (system)
3283 (ensure-source-registry)
3284 (values (gethash (primary-system-name system
) *source-registry
*))))
3287 ;;;; -------------------------------------------------------------------------
3290 (uiop/package
:define-package
:asdf
/parse-defsystem
3291 (:recycle
:asdf
/parse-defsystem
:asdf
/defsystem
:asdf
)
3292 (:nicknames
:asdf
/defsystem
) ;; previous name, to be compatible with, in case anyone cares
3293 (:use
:uiop
/common-lisp
:asdf
/driver
:asdf
/upgrade
3294 :asdf
/cache
:asdf
/component
:asdf
/system
3295 :asdf
/find-system
:asdf
/find-component
:asdf
/action
:asdf
/lisp-action
:asdf
/operate
)
3296 (:import-from
:asdf
/system
#:depends-on
#:weakly-depends-on
)
3298 #:defsystem
#:register-system-definition
3299 #:class-for-type
#:*default-component-class
*
3300 #:determine-system-directory
#:parse-component-form
3301 #:non-toplevel-system
#:non-system-system
3302 #:sysdef-error-component
#:check-component-input
))
3303 (in-package :asdf
/parse-defsystem
)
3306 (with-upgradability ()
3307 (defun determine-system-directory (pathname)
3308 ;; The defsystem macro calls this function to determine
3309 ;; the pathname of a system as follows:
3310 ;; 1. if the pathname argument is an pathname object (NOT a namestring),
3311 ;; that is already an absolute pathname, return it.
3312 ;; 2. otherwise, the directory containing the LOAD-PATHNAME
3313 ;; is considered (as deduced from e.g. *LOAD-PATHNAME*), and
3314 ;; if it is indeed available and an absolute pathname, then
3315 ;; the PATHNAME argument is normalized to a relative pathname
3316 ;; as per PARSE-UNIX-NAMESTRING (with ENSURE-DIRECTORY T)
3317 ;; and merged into that DIRECTORY as per SUBPATHNAME.
3318 ;; Note: avoid *COMPILE-FILE-PATHNAME* because .asd is loaded,
3319 ;; and may be from within the EVAL-WHEN of a file compilation.
3320 ;; If no absolute pathname was found, we return NIL.
3321 (check-type pathname
(or null string pathname
))
3322 (pathname-directory-pathname
3324 (ensure-absolute-pathname
3325 (parse-unix-namestring pathname
:type
:directory
)
3326 #'(lambda () (ensure-absolute-pathname
3327 (load-pathname) 'get-pathname-defaults nil
))
3332 (with-upgradability ()
3333 (defvar *default-component-class
* 'cl-source-file
)
3335 (defun class-for-type (parent type
)
3336 (or (coerce-class type
:package
:asdf
/interface
:super
'component
:error nil
)
3337 (and (eq type
:file
)
3339 (or (loop :for p
= parent
:then
(component-parent p
) :while p
3340 :thereis
(module-default-component-class p
))
3341 *default-component-class
*)
3342 :package
:asdf
/interface
:super
'component
:error nil
))
3343 (sysdef-error "don't recognize component type ~S" type
))))
3347 (with-upgradability ()
3348 (define-condition non-system-system
(system-definition-error)
3349 ((name :initarg
:name
:reader non-system-system-name
)
3350 (class-name :initarg
:class-name
:reader non-system-system-class-name
))
3351 (:report
(lambda (c s
)
3352 (format s
(compatfmt "~@<Error while defining system ~S: class ~S isn't a subclass of ~S~@:>")
3353 (non-system-system-name c
) (non-system-system-class-name c
) 'system
))))
3355 (define-condition non-toplevel-system
(system-definition-error)
3356 ((parent :initarg
:parent
:reader non-toplevel-system-parent
)
3357 (name :initarg
:name
:reader non-toplevel-system-name
))
3358 (:report
(lambda (c s
)
3359 (format s
(compatfmt "~@<Error while defining system: component ~S claims to have a system ~S as a child~@:>")
3360 (non-toplevel-system-parent c
) (non-toplevel-system-name c
)))))
3362 (defun sysdef-error-component (msg type name value
)
3363 (sysdef-error (strcat msg
(compatfmt "~&~@<The value specified for ~(~A~) ~A is ~S~@:>"))
3366 (defun check-component-input (type name weakly-depends-on
3367 depends-on components
)
3368 "A partial test of the values of a component."
3369 (unless (listp depends-on
)
3370 (sysdef-error-component ":depends-on must be a list."
3371 type name depends-on
))
3372 (unless (listp weakly-depends-on
)
3373 (sysdef-error-component ":weakly-depends-on must be a list."
3374 type name weakly-depends-on
))
3375 (unless (listp components
)
3376 (sysdef-error-component ":components must be NIL or a list of components."
3377 type name components
)))
3379 (defun* (normalize-version) (form &key pathname component parent
)
3380 (labels ((invalid (&optional
(continuation "using NIL instead"))
3381 (warn (compatfmt "~@<Invalid :version specifier ~S~@[ for component ~S~]~@[ in ~S~]~@[ from file ~S~]~@[, ~A~]~@:>")
3382 form component parent pathname continuation
))
3383 (invalid-parse (control &rest args
)
3384 (unless (if-let (target (find-component parent component
)) (builtin-system-p target
))
3385 (apply 'warn control args
)
3387 (if-let (v (typecase form
3388 ((or string null
) form
)
3390 (invalid "Substituting a string")
3391 (format nil
"~D" form
)) ;; 1.0 becomes "1.0"
3395 (destructuring-bind (subpath &key
(at 0)) (rest form
)
3396 (safe-read-file-form (subpathname pathname subpath
)
3397 :at at
:package
:asdf-user
)))
3399 (destructuring-bind (subpath &key
(at 0)) (rest form
)
3400 (safe-read-file-line (subpathname pathname subpath
)
3406 (if-let (pv (parse-version v
#'invalid-parse
))
3407 (unparse-version pv
)
3411 ;;; "inline methods"
3412 (with-upgradability ()
3413 (defparameter* +asdf-methods
+
3414 '(perform-with-restarts perform explain output-files operation-done-p
))
3416 (defun %remove-component-inline-methods
(component)
3417 (dolist (name +asdf-methods
+)
3419 ;; this is inefficient as most of the stored
3420 ;; methods will not be for this particular gf
3421 ;; But this is hardly performance-critical
3423 (remove-method (symbol-function name
) m
))
3424 (component-inline-methods component
)))
3425 (component-inline-methods component
) nil
)
3427 (defun %define-component-inline-methods
(ret rest
)
3428 (loop* :for
(key value
) :on rest
:by
#'cddr
3429 :for name
= (and (keywordp key
) (find key
+asdf-methods
+ :test
'string
=))
3431 (destructuring-bind (op &rest body
) value
3432 (loop :for arg
= (pop body
)
3434 :collect arg
:into qualifiers
3436 (destructuring-bind (o c
) arg
3438 (eval `(defmethod ,name
,@qualifiers
((,o
,op
) (,c
(eql ,ret
))) ,@body
))
3439 (component-inline-methods ret
)))))))
3441 (defun %refresh-component-inline-methods
(component rest
)
3442 ;; clear methods, then add the new ones
3443 (%remove-component-inline-methods component
)
3444 (%define-component-inline-methods component rest
)))
3447 ;;; Main parsing function
3448 (with-upgradability ()
3449 (defun* parse-dependency-def
(dd)
3453 (unless (= (length dd
) 3)
3454 (sysdef-error "Ill-formed feature dependency: ~s" dd
))
3455 (let ((embedded (parse-dependency-def (third dd
))))
3456 `(:feature
,(second dd
) ,embedded
)))
3458 (sysdef-error "`feature' has been removed from the dependency spec language of ASDF. Use :feature instead in ~s." dd
))
3460 (unless (= (length dd
) 2)
3461 (sysdef-error "Ill-formed require dependency: ~s" dd
))
3464 (unless (= (length dd
) 3)
3465 (sysdef-error "Ill-formed version dependency: ~s" dd
))
3466 `(:version
,(coerce-name (second dd
)) ,(third dd
)))
3467 (otherwise (sysdef-error "Ill-formed dependency: ~s" dd
)))
3470 (defun* parse-dependency-defs
(dd-list)
3471 "Parse the dependency defs in DD-LIST into canonical form by translating all
3472 system names contained using COERCE-NAME. Return the result."
3473 (mapcar 'parse-dependency-def dd-list
))
3475 (defun* (parse-component-form) (parent options
&key previous-serial-component
)
3477 (type name
&rest rest
&key
3478 (builtin-system-p () bspp
)
3479 ;; the following list of keywords is reproduced below in the
3480 ;; remove-plist-keys form. important to keep them in sync
3481 components pathname perform explain output-files operation-done-p
3482 weakly-depends-on depends-on serial
3483 do-first if-component-dep-fails version
3485 &allow-other-keys
) options
3486 (declare (ignore perform explain output-files operation-done-p builtin-system-p
))
3487 (check-component-input type name weakly-depends-on depends-on components
)
3489 (find-component parent name
)
3490 (not ;; ignore the same object when rereading the defsystem
3491 (typep (find-component parent name
)
3492 (class-for-type parent type
))))
3493 (error 'duplicate-names
:name name
))
3494 (when do-first
(error "DO-FIRST is not supported anymore as of ASDF 3"))
3495 (let* ((name (coerce-name name
))
3498 ,@(when parent
`(:parent
,parent
))
3499 ,@(remove-plist-keys
3500 '(:components
:pathname
:if-component-dep-fails
:version
3501 :perform
:explain
:output-files
:operation-done-p
3502 :weakly-depends-on
:depends-on
:serial
)
3504 (component (find-component parent name
))
3505 (class (class-for-type parent type
)))
3506 (when (and parent
(subtypep class
'system
))
3507 (error 'non-toplevel-system
:parent parent
:name name
))
3508 (if component
; preserve identity
3509 (apply 'reinitialize-instance component args
)
3510 (setf component
(apply 'make-instance class args
)))
3511 (component-pathname component
) ; eagerly compute the absolute pathname
3512 (when (typep component
'system
)
3513 ;; cache information for introspection
3514 (setf (slot-value component
'depends-on
)
3515 (parse-dependency-defs depends-on
)
3516 (slot-value component
'weakly-depends-on
)
3517 ;; these must be a list of systems, cannot be features or versioned systems
3518 (mapcar 'coerce-name weakly-depends-on
)))
3519 (let ((sysfile (system-source-file (component-system component
)))) ;; requires the previous
3520 (when (and (typep component
'system
) (not bspp
))
3521 (setf (builtin-system-p component
) (lisp-implementation-pathname-p sysfile
)))
3522 (setf version
(normalize-version version
:component name
:parent parent
:pathname sysfile
)))
3523 ;; Don't use the accessor: kluge to avoid upgrade issue on CCL 1.8.
3524 ;; A better fix is required.
3525 (setf (slot-value component
'version
) version
)
3526 (when (typep component
'parent-component
)
3527 (setf (component-children component
)
3529 :with previous-component
= nil
3530 :for c-form
:in components
3531 :for c
= (parse-component-form component c-form
3532 :previous-serial-component previous-component
)
3533 :for name
= (component-name c
)
3535 :when serial
:do
(setf previous-component name
)))
3536 (compute-children-by-name component
))
3537 (when previous-serial-component
3538 (push previous-serial-component depends-on
))
3539 (when weakly-depends-on
3540 ;; ASDF4: deprecate this feature and remove it.
3542 (remove-if (complement #'(lambda (x) (find-system x nil
))) weakly-depends-on
)))
3543 ;; Used by POIU. ASDF4: rename to component-depends-on?
3544 (setf (component-sideway-dependencies component
) depends-on
)
3545 (%refresh-component-inline-methods component rest
)
3546 (when if-component-dep-fails
3547 (error "The system definition for ~S uses deprecated ~
3548 ASDF option :IF-COMPONENT-DEP-FAILS. ~
3549 Starting with ASDF 3, please use :IF-FEATURE instead"
3550 (coerce-name (component-system component
))))
3553 (defun register-system-definition
3554 (name &rest options
&key pathname
(class 'system
) (source-file () sfp
)
3555 defsystem-depends-on
&allow-other-keys
)
3556 ;; The system must be registered before we parse the body,
3557 ;; otherwise we recur when trying to find an existing system
3558 ;; of the same name to reuse options (e.g. pathname) from.
3559 ;; To avoid infinite recursion in cases where you defsystem a system
3560 ;; that is registered to a different location to find-system,
3561 ;; we also need to remember it in the asdf-cache.
3563 (let* ((name (coerce-name name
))
3564 (source-file (if sfp source-file
(resolve-symlinks* (load-pathname))))
3565 (registered (system-registered-p name
))
3566 (registered! (if registered
3567 (rplaca registered
(get-file-stamp source-file
))
3569 (make-instance 'system
:name name
:source-file source-file
))))
3570 (system (reset-system (cdr registered
!)
3571 :name name
:source-file source-file
))
3573 (remove-plist-keys '(:defsystem-depends-on
:class
) options
))
3574 (defsystem-dependencies (loop :for spec
:in defsystem-depends-on
3575 :when
(resolve-dependency-spec nil spec
)
3577 ;; cache defsystem-depends-on in canonical form
3578 (when defsystem-depends-on
3579 (setf component-options
3580 (append `(:defsystem-depends-on
,(parse-dependency-defs defsystem-depends-on
))
3581 component-options
)))
3582 (set-asdf-cache-entry `(find-system ,name
) (list system
))
3583 (load-systems* defsystem-dependencies
)
3584 ;; We change-class AFTER we loaded the defsystem-depends-on
3585 ;; since the class might be defined as part of those.
3586 (let ((class (class-for-type nil class
)))
3587 (unless (subtypep class
'system
)
3588 (error 'non-system-system
:name name
:class-name
(class-name class
)))
3589 (unless (eq (type-of system
) class
)
3590 (change-class system class
)))
3591 (parse-component-form
3594 :pathname
(determine-system-directory pathname
)
3595 component-options
)))))
3597 (defmacro defsystem
(name &body options
)
3598 `(apply 'register-system-definition
',name
',options
)))
3599 ;;;; -------------------------------------------------------------------------
3602 (uiop/package
:define-package
:asdf
/bundle
3603 (:recycle
:asdf
/bundle
:asdf
)
3604 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
3605 :asdf
/component
:asdf
/system
:asdf
/find-system
:asdf
/find-component
:asdf
/operation
3606 :asdf
/action
:asdf
/lisp-action
:asdf
/plan
:asdf
/operate
:asdf
/defsystem
)
3608 #:bundle-op
#:bundle-type
#:program-system
3609 #:bundle-system
#:bundle-pathname-type
#:bundlable-file-p
#:direct-dependency-files
3610 #:monolithic-op
#:monolithic-bundle-op
#:operation-monolithic-p
3611 #:basic-compile-bundle-op
#:prepare-bundle-op
3612 #:compile-bundle-op
#:load-bundle-op
#:monolithic-compile-bundle-op
#:monolithic-load-bundle-op
3613 #:lib-op
#:monolithic-lib-op
3614 #:dll-op
#:monolithic-dll-op
3615 #:deliver-asd-op
#:monolithic-deliver-asd-op
3616 #:program-op
#:image-op
#:compiled-file
#:precompiled-system
#:prebuilt-system
3617 #:user-system-p
#:user-system
#:trivial-system-p
3619 #:build-args
#:name-suffix
#:prologue-code
#:epilogue-code
#:static-library
))
3620 (in-package :asdf
/bundle
)
3622 (with-upgradability ()
3623 (defclass bundle-op
(basic-compile-op)
3624 ((build-args :initarg
:args
:initform nil
:accessor extra-build-args
)
3625 (name-suffix :initarg
:name-suffix
:initform nil
)
3626 (bundle-type :initform
:no-output-file
:reader bundle-type
)
3627 #+(or clasp ecl
) (lisp-files :initform nil
:accessor extra-object-files
)))
3629 (defclass monolithic-op
(operation) ()
3630 (:documentation
"A MONOLITHIC operation operates on a system *and all of its
3631 dependencies*. So, for example, a monolithic concatenate operation will
3632 concatenate together a system's components and all of its dependencies, but a
3633 simple concatenate operation will concatenate only the components of the system
3634 itself.")) ;; operation on a system and its dependencies
3636 (defclass monolithic-bundle-op
(monolithic-op bundle-op
)
3637 ;; Old style way of specifying prologue and epilogue on ECL: in the monolithic operation
3638 ((prologue-code :initform nil
:accessor prologue-code
)
3639 (epilogue-code :initform nil
:accessor epilogue-code
)))
3641 (defclass program-system
(system)
3642 ;; New style (ASDF3.1) way of specifying prologue and epilogue on ECL: in the system
3643 ((prologue-code :initform nil
:initarg
:prologue-code
:reader prologue-code
)
3644 (epilogue-code :initform nil
:initarg
:epilogue-code
:reader epilogue-code
)
3645 (no-uiop :initform nil
:initarg
:no-uiop
:reader no-uiop
)
3646 (prefix-lisp-object-files :initarg
:prefix-lisp-object-files
3647 :initform nil
:accessor prefix-lisp-object-files
)
3648 (postfix-lisp-object-files :initarg
:postfix-lisp-object-files
3649 :initform nil
:accessor postfix-lisp-object-files
)
3650 (extra-object-files :initarg
:extra-object-files
3651 :initform nil
:accessor extra-object-files
)
3652 (extra-build-args :initarg
:extra-build-args
3653 :initform nil
:accessor extra-build-args
)))
3655 (defmethod prologue-code ((x t
)) nil
)
3656 (defmethod epilogue-code ((x t
)) nil
)
3657 (defmethod no-uiop ((x t
)) nil
)
3658 (defmethod prefix-lisp-object-files ((x t
)) nil
)
3659 (defmethod postfix-lisp-object-files ((x t
)) nil
)
3660 (defmethod extra-object-files ((x t
)) nil
)
3661 (defmethod extra-build-args ((x t
)) nil
)
3663 (defclass link-op
(bundle-op) ()
3664 (:documentation
"Abstract operation for linking files together"))
3666 (defclass gather-op
(bundle-op)
3667 ((gather-op :initform nil
:allocation
:class
:reader gather-op
))
3668 (:documentation
"Abstract operation for gathering many input files from a system"))
3670 (defun operation-monolithic-p (op)
3671 (typep op
'monolithic-op
))
3673 (defmethod component-depends-on ((o gather-op
) (s system
))
3674 (let* ((mono (operation-monolithic-p o
))
3676 (required-components
3677 s
:other-systems mono
:component-type
(if mono
'system
'(not system
))
3678 :goal-operation
(find-operation o
'load-op
)
3679 :keep-operation
'compile-op
)))
3680 ;; NB: the explicit make-operation on ECL and MKCL
3681 ;; ensures that we drop the original-initargs and its magic flags when recursing.
3682 `((,(make-operation (or (gather-op o
) (if mono
'lib-op
'compile-op
))) ,@deps
)
3683 ,@(call-next-method))))
3685 ;; create a single fasl for the entire library
3686 (defclass basic-compile-bundle-op
(bundle-op)
3687 ((bundle-type :initform
:fasl
)))
3689 (defclass prepare-bundle-op
(sideway-operation)
3691 :initform
#+(or clasp ecl mkcl
) 'load-bundle-op
#-
(or clasp ecl mkcl
) 'load-op
3692 :allocation
:class
)))
3694 (defclass lib-op
(link-op gather-op non-propagating-operation
)
3695 ((bundle-type :initform
:lib
))
3696 (:documentation
"compile the system and produce linkable (.a) library for it."))
3698 (defclass compile-bundle-op
(basic-compile-bundle-op selfward-operation
3699 #+(or clasp ecl mkcl
) link-op
#-
(or clasp ecl
) gather-op
)
3700 ((selfward-operation :initform
'(prepare-bundle-op #+(or clasp ecl
) lib-op
)
3701 :allocation
:class
)))
3703 (defclass load-bundle-op
(basic-load-op selfward-operation
)
3704 ((selfward-operation :initform
'(prepare-bundle-op compile-bundle-op
) :allocation
:class
)))
3706 ;; NB: since the monolithic-op's can't be sideway-operation's,
3707 ;; if we wanted lib-op, dll-op, deliver-asd-op to be sideway-operation's,
3708 ;; we'd have to have the monolithic-op not inherit from the main op,
3709 ;; but instead inherit from a basic-FOO-op as with basic-compile-bundle-op above.
3711 (defclass dll-op
(link-op gather-op non-propagating-operation
)
3712 ((bundle-type :initform
:dll
))
3713 (:documentation
"compile the system and produce dynamic (.so/.dll) library for it."))
3715 (defclass deliver-asd-op
(basic-compile-op selfward-operation
)
3716 ((selfward-operation :initform
'(compile-bundle-op #+(or clasp ecl mkcl
) lib-op
) :allocation
:class
))
3717 (:documentation
"produce an asd file for delivering the system as a single fasl"))
3720 (defclass monolithic-deliver-asd-op
(monolithic-bundle-op deliver-asd-op
)
3721 ((selfward-operation
3722 :initform
'(monolithic-compile-bundle-op #+(or clasp ecl mkcl
) monolithic-lib-op
)
3723 :allocation
:class
))
3724 (:documentation
"produce fasl and asd files for combined system and dependencies."))
3726 (defclass monolithic-compile-bundle-op
(monolithic-bundle-op basic-compile-bundle-op
3727 #+(or clasp ecl mkcl
) link-op gather-op non-propagating-operation
)
3728 ((gather-op :initform
#+(or clasp ecl mkcl
) 'lib-op
#-
(or clasp ecl mkcl
) 'compile-bundle-op
:allocation
:class
))
3729 (:documentation
"Create a single fasl for the system and its dependencies."))
3731 (defclass monolithic-load-bundle-op
(monolithic-bundle-op load-bundle-op
)
3732 ((selfward-operation :initform
'monolithic-compile-bundle-op
:allocation
:class
))
3733 (:documentation
"Load a single fasl for the system and its dependencies."))
3735 (defclass monolithic-lib-op
(monolithic-bundle-op lib-op non-propagating-operation
) ()
3736 (:documentation
"Create a single linkable library for the system and its dependencies."))
3738 (defclass monolithic-dll-op
(monolithic-bundle-op dll-op non-propagating-operation
)
3739 ((bundle-type :initform
:dll
))
3740 (:documentation
"Create a single dynamic (.so/.dll) library for the system and its dependencies."))
3742 (defclass image-op
(monolithic-bundle-op selfward-operation
3743 #+(or clasp ecl mkcl
) link-op
#+(or clasp ecl mkcl
) gather-op
)
3744 ((bundle-type :initform
:image
)
3745 (selfward-operation :initform
'(#-
(or clasp ecl mkcl
) load-op
) :allocation
:class
))
3746 (:documentation
"create an image file from the system and its dependencies"))
3748 (defclass program-op
(image-op)
3749 ((bundle-type :initform
:program
))
3750 (:documentation
"create an executable file from the system and its dependencies"))
3752 (defun bundle-pathname-type (bundle-type)
3753 (etypecase bundle-type
3754 ((eql :no-output-file
) nil
) ;; should we error out instead?
3755 ((or null string
) bundle-type
)
3756 ((eql :fasl
) #-
(or clasp ecl mkcl
) (compile-file-type) #+(or clasp ecl mkcl
) "fasb")
3758 ((member :dll
:lib
:shared-library
:static-library
:program
:object
:program
)
3759 (compile-file-type :type bundle-type
))
3760 ((member :image
) #+allegro
"dxl" #+(and clisp os-windows
) "exe" #-
(or allegro
(and clisp os-windows
)) "image")
3761 ((member :dll
:shared-library
) (os-cond ((os-macosx-p) "dylib") ((os-unix-p) "so") ((os-windows-p) "dll")))
3762 ((member :lib
:static-library
) (os-cond ((os-unix-p) "a")
3763 ((os-windows-p) (if (featurep '(:or
:mingw32
:mingw64
)) "a" "lib"))))
3764 ((eql :program
) (os-cond ((os-unix-p) nil
) ((os-windows-p) "exe")))))
3766 (defun bundle-output-files (o c
)
3767 (let ((bundle-type (bundle-type o
)))
3768 (unless (or (eq bundle-type
:no-output-file
) ;; NIL already means something regarding type.
3769 (and (null (input-files o c
)) (not (member bundle-type
'(:image
:program
)))))
3770 (let ((name (or (component-build-pathname c
)
3771 (format nil
"~A~@[~A~]" (component-name c
) (slot-value o
'name-suffix
))))
3772 (type (bundle-pathname-type bundle-type
)))
3773 (values (list (subpathname (component-pathname c
) name
:type type
))
3774 (eq (type-of o
) (component-build-operation c
)))))))
3776 (defmethod output-files ((o bundle-op
) (c system
))
3777 (bundle-output-files o c
))
3779 #-
(or clasp ecl mkcl
)
3781 (defmethod perform ((o image-op
) (c system
))
3782 (dump-image (output-file o c
) :executable
(typep o
'program-op
)))
3783 (defmethod perform :before
((o program-op
) (c system
))
3784 (setf *image-entry-point
* (ensure-function (component-entry-point c
)))))
3786 (defclass compiled-file
(file-component)
3787 ((type :initform
#-
(or clasp ecl mkcl
) (compile-file-type) #+(or clasp ecl mkcl
) "fasb")))
3789 (defclass precompiled-system
(system)
3790 ((build-pathname :initarg
:fasl
)))
3792 (defclass prebuilt-system
(system)
3793 ((build-pathname :initarg
:static-library
:initarg
:lib
3794 :accessor prebuilt-system-static-library
))))
3800 ;;; This operation takes all components from one or more systems and
3801 ;;; creates a single output file, which may be
3802 ;;; a FASL, a statically linked library, a shared library, etc.
3803 ;;; The different targets are defined by specialization.
3805 (with-upgradability ()
3806 (defmethod initialize-instance :after
((instance bundle-op
) &rest initargs
3807 &key
(name-suffix nil name-suffix-p
)
3809 (declare (ignore initargs name-suffix
))
3810 (unless name-suffix-p
3811 (setf (slot-value instance
'name-suffix
)
3812 (unless (typep instance
'program-op
)
3813 ;; "." is no good separator for Logical Pathnames, so we use "--"
3814 (if (operation-monolithic-p instance
) "--all-systems" #-
(or clasp ecl mkcl
) "--system"))))
3815 (when (typep instance
'monolithic-bundle-op
)
3816 (destructuring-bind (&key lisp-files prologue-code epilogue-code
3818 (operation-original-initargs instance
)
3819 (setf (prologue-code instance
) prologue-code
3820 (epilogue-code instance
) epilogue-code
)
3821 #-
(or clasp ecl
) (assert (null (or lisp-files
#-mkcl epilogue-code
#-mkcl prologue-code
)))
3822 #+(or clasp ecl
) (setf (extra-object-files instance
) lisp-files
)))
3823 (setf (extra-build-args instance
)
3825 '(:type
:monolithic
:name-suffix
:epilogue-code
:prologue-code
:lisp-files
3826 :force
:force-not
:plan-class
) ;; TODO: refactor so we don't mix plan and operation arguments
3827 (operation-original-initargs instance
))))
3829 (defun bundlable-file-p (pathname)
3830 (let ((type (pathname-type pathname
)))
3831 (declare (ignorable type
))
3832 (or #+(or clasp ecl
) (or (equalp type
(compile-file-type :type
:object
))
3833 (equalp type
(compile-file-type :type
:static-library
)))
3834 #+mkcl
(or (equalp type
(compile-file-type :fasl-p nil
))
3835 #+(or unix mingw32 mingw64
) (equalp type
"a") ;; valid on Unix and MinGW
3836 #+(and windows
(not (or mingw32 mingw64
))) (equalp type
"lib"))
3837 #+(or abcl allegro clisp clozure cmu lispworks sbcl scl xcl
) (equalp type
(compile-file-type)))))
3839 (defgeneric* (trivial-system-p) (component))
3841 (defun user-system-p (s)
3842 (and (typep s
'system
)
3843 (not (builtin-system-p s
))
3844 (not (trivial-system-p s
)))))
3846 (eval-when (#-lispworks
:compile-toplevel
:load-toplevel
:execute
)
3847 (deftype user-system
() '(and system
(satisfies user-system-p
))))
3850 ;;; First we handle monolithic bundles.
3851 ;;; These are standalone systems which contain everything,
3852 ;;; including other ASDF systems required by the current one.
3853 ;;; A PROGRAM is always monolithic.
3855 ;;; MONOLITHIC SHARED LIBRARIES, PROGRAMS, FASL
3857 (with-upgradability ()
3858 (defun direct-dependency-files (o c
&key
(test 'identity
) (key 'output-files
) &allow-other-keys
)
3859 ;; This file selects output files from direct dependencies;
3860 ;; your component-depends-on method better gathered the correct dependencies in the correct order.
3861 (while-collecting (collect)
3862 (map-direct-dependencies
3863 t o c
#'(lambda (sub-o sub-c
)
3864 (loop :for f
:in
(funcall key sub-o sub-c
)
3865 :when
(funcall test f
) :do
(collect f
))))))
3867 (defmethod input-files ((o gather-op
) (c system
))
3868 (unless (eq (bundle-type o
) :no-output-file
)
3869 (direct-dependency-files o c
:test
'bundlable-file-p
:key
'output-files
)))
3871 (defun select-bundle-operation (type &optional monolithic
)
3873 ((:dll
:shared-library
)
3874 (if monolithic
'monolithic-dll-op
'dll-op
))
3875 ((:lib
:static-library
)
3876 (if monolithic
'monolithic-lib-op
'lib-op
))
3878 (if monolithic
'monolithic-compile-bundle-op
'compile-bundle-op
))
3884 ;; DEPRECATED. This is originally from asdf-ecl.lisp. Does anyone use it?
3885 (defun make-build (system &rest args
&key
(monolithic nil
) (type :fasl
)
3886 (move-here nil move-here-p
)
3888 (let* ((operation-name (select-bundle-operation type monolithic
))
3889 (move-here-path (if (and move-here
3890 (typep move-here
'(or pathname string
)))
3891 (ensure-pathname move-here
:namestring
:lisp
:ensure-directory t
)
3892 (system-relative-pathname system
"asdf-output/")))
3893 (operation (apply #'operate operation-name
3895 (remove-plist-keys '(:monolithic
:type
:move-here
) args
)))
3896 (system (find-system system
))
3897 (files (and system
(output-files operation system
))))
3898 (if (or move-here
(and (null move-here-p
)
3899 (member operation-name
'(:program
:image
))))
3900 (loop :with dest-path
= (resolve-symlinks* (ensure-directories-exist move-here-path
))
3902 :for new-f
= (make-pathname :name
(pathname-name f
)
3903 :type
(pathname-type f
)
3904 :defaults dest-path
)
3905 :do
(rename-file-overwriting-target f new-f
)
3909 ;; DEPRECATED. Does anyone use this?
3910 (defun bundle-system (system &rest args
&key force
(verbose t
) version
&allow-other-keys
)
3911 (declare (ignore force verbose version
))
3912 (apply #'operate
'deliver-asd-op system args
)))
3917 ;;; This is like ASDF's LOAD-OP, but using bundle fasl files.
3919 (with-upgradability ()
3920 (defmethod component-depends-on ((o load-bundle-op
) (c system
))
3921 `((,o
,@(component-sideway-dependencies c
))
3922 (,(if (user-system-p c
) 'compile-bundle-op
'load-op
) ,c
)
3923 ,@(call-next-method)))
3925 (defmethod input-files ((o load-bundle-op
) (c system
))
3926 (when (user-system-p c
)
3927 (output-files (find-operation o
'compile-bundle-op
) c
)))
3929 (defmethod perform ((o load-bundle-op
) (c system
))
3930 (when (input-files o c
)
3931 (perform-lisp-load-fasl o c
)))
3933 (defmethod mark-operation-done :after
((o load-bundle-op
) (c system
))
3934 (mark-operation-done (find-operation o
'load-op
) c
)))
3937 ;;; PRECOMPILED FILES
3939 ;;; This component can be used to distribute ASDF systems in precompiled form.
3940 ;;; Only useful when the dependencies have also been precompiled.
3942 (with-upgradability ()
3943 (defmethod trivial-system-p ((s system
))
3944 (every #'(lambda (c) (typep c
'compiled-file
)) (component-children s
)))
3946 (defmethod input-files ((o operation
) (c compiled-file
))
3947 (list (component-pathname c
)))
3948 (defmethod perform ((o load-op
) (c compiled-file
))
3949 (perform-lisp-load-fasl o c
))
3950 (defmethod perform ((o load-source-op
) (c compiled-file
))
3951 (perform (find-operation o
'load-op
) c
))
3952 (defmethod perform ((o operation
) (c compiled-file
))
3956 ;;; Pre-built systems
3958 (with-upgradability ()
3959 (defmethod trivial-system-p ((s prebuilt-system
))
3962 (defmethod perform ((o link-op
) (c prebuilt-system
))
3965 (defmethod perform ((o basic-compile-bundle-op
) (c prebuilt-system
))
3968 (defmethod perform ((o lib-op
) (c prebuilt-system
))
3971 (defmethod perform ((o dll-op
) (c prebuilt-system
))
3974 (defmethod component-depends-on ((o gather-op
) (c prebuilt-system
))
3977 (defmethod output-files ((o lib-op
) (c prebuilt-system
))
3978 (values (list (prebuilt-system-static-library c
)) t
)))
3982 ;;; PREBUILT SYSTEM CREATOR
3984 (with-upgradability ()
3985 (defmethod output-files ((o deliver-asd-op
) (s system
))
3986 (list (make-pathname :name
(component-name s
) :type
"asd"
3987 :defaults
(component-pathname s
))))
3989 (defmethod perform ((o deliver-asd-op
) (s system
))
3990 (let* ((inputs (input-files o s
))
3991 (fasl (first inputs
))
3992 (library (second inputs
))
3993 (asd (first (output-files o s
)))
3994 (name (if (and fasl asd
) (pathname-name asd
) (return-from perform
)))
3995 (version (component-version s
))
3997 (if (operation-monolithic-p o
)
3998 (remove-if-not 'builtin-system-p
3999 (required-components s
:component-type
'system
4000 :keep-operation
'load-op
))
4001 (while-collecting (x) ;; resolve the sideway-dependencies of s
4002 (map-direct-dependencies
4005 (when (and (typep o
'load-op
) (typep c
'system
))
4007 (depends-on (mapcar 'coerce-name dependencies
)))
4008 (when (pathname-equal asd
(system-source-file s
))
4009 (cerror "overwrite the asd file"
4010 "~/asdf-action:format-action/ is going to overwrite the system definition file ~S which is probably not what you want; you probably need to tweak your output translations."
4012 (with-open-file (s asd
:direction
:output
:if-exists
:supersede
4013 :if-does-not-exist
:create
)
4014 (format s
";;; Prebuilt~:[~; monolithic~] ASDF definition for system ~A~%"
4015 (operation-monolithic-p o
) name
)
4016 (format s
";;; Built for ~A ~A on a ~A/~A ~A~%"
4017 (lisp-implementation-type)
4018 (lisp-implementation-version)
4022 (let ((*package
* (find-package :asdf-user
)))
4023 (pprint `(defsystem ,name
4024 :class prebuilt-system
4026 :depends-on
,depends-on
4027 :components
((:compiled-file
,(pathname-name fasl
)))
4028 ,@(when library
`(:lib
,(file-namestring library
))))
4032 #-
(or clasp ecl mkcl
)
4033 (defmethod perform ((o basic-compile-bundle-op
) (c system
))
4034 (let* ((input-files (input-files o c
))
4035 (fasl-files (remove (compile-file-type) input-files
:key
#'pathname-type
:test-not
#'equalp
))
4036 (non-fasl-files (remove (compile-file-type) input-files
:key
#'pathname-type
:test
#'equalp
))
4037 (output-files (output-files o c
))
4038 (output-file (first output-files
)))
4039 (assert (eq (not input-files
) (not output-files
)))
4041 (when non-fasl-files
4042 (error "On ~A, asdf/bundle can only bundle FASL files, but these were also produced: ~S"
4043 (implementation-type) non-fasl-files
))
4044 (when (or (prologue-code o
) (epilogue-code o
)
4045 (prologue-code c
) (epilogue-code c
))
4046 (error "prologue-code and epilogue-code are not supported on ~A"
4047 (implementation-type)))
4048 (with-staging-pathname (output-file)
4049 (combine-fasls fasl-files output-file
)))))
4051 (defmethod input-files ((o load-op
) (s precompiled-system
))
4052 (bundle-output-files (find-operation o
'compile-bundle-op
) s
))
4054 (defmethod perform ((o load-op
) (s precompiled-system
))
4055 (perform-lisp-load-fasl o s
))
4057 (defmethod component-depends-on ((o load-bundle-op
) (s precompiled-system
))
4058 #+xcl
(declare (ignorable o
))
4059 `((load-op ,s
) ,@(call-next-method))))
4062 (asdf:defsystem
:precompiled-asdf-utils
:class asdf
::precompiled-system
:fasl
(asdf:apply-output-translations
(asdf:system-relative-pathname
:asdf-utils
"asdf-utils.system.fasl")))
4063 (asdf:load-system
:precompiled-asdf-utils
)
4066 #+(or clasp ecl mkcl
)
4067 (with-upgradability ()
4068 ;; I think that Juanjo intended for this to be,
4069 ;; but beware the weird bug in test-xach-update-bug.script,
4070 ;; and also it makes mkcl fail test-logical-pathname.script,
4071 ;; and ecl fail test-bundle.script.
4072 ;;(unless (or #+(or clasp ecl) (use-ecl-byte-compiler-p))
4073 ;; (setf *load-system-operation* 'load-bundle-op))
4075 (defun uiop-library-pathname ()
4076 #+clasp
(probe-file* (compile-file-pathname "sys:uiop" :output-type
:object
))
4077 #+ecl
(or (probe-file* (compile-file-pathname "sys:uiop" :type
:lib
)) ;; new style
4078 (probe-file* (compile-file-pathname "sys:uiop" :type
:object
))) ;; old style
4079 #+mkcl
(make-pathname :type
(bundle-pathname-type :lib
) :defaults
#p
"sys:contrib;uiop"))
4081 (defun asdf-library-pathname ()
4082 #+clasp
(probe-file* (compile-file-pathname "sys:asdf" :output-type
:object
))
4083 #+ecl
(or (probe-file* (compile-file-pathname "sys:asdf" :type
:lib
)) ;; new style
4084 (probe-file* (compile-file-pathname "sys:asdf" :type
:object
))) ;; old style
4085 #+mkcl
(make-pathname :type
(bundle-pathname-type :lib
) :defaults
#p
"sys:contrib;asdf"))
4087 (defun compiler-library-pathname ()
4088 #+clasp
(compile-file-pathname "sys:cmp" :output-type
:lib
)
4089 #+ecl
(compile-file-pathname "sys:cmp" :type
:lib
)
4090 #+mkcl
(make-pathname :type
(bundle-pathname-type :lib
) :defaults
#p
"sys:cmp"))
4092 (defun make-library-system (name pathname
)
4093 (make-instance 'prebuilt-system
4094 :name
(coerce-name name
) :static-library
(resolve-symlinks* pathname
)))
4096 (defmethod component-depends-on :around
((o image-op
) (c system
))
4097 (destructuring-bind ((lib-op . deps
)) (call-next-method)
4098 (flet ((has-it-p (x) (find x deps
:test
'equal
:key
'coerce-name
)))
4100 ,@(unless (or (no-uiop c
) (has-it-p "cmp"))
4101 `(,(make-library-system
4102 "cmp" (compiler-library-pathname))))
4103 ,@(unless (or (no-uiop c
) (has-it-p "uiop") (has-it-p "asdf"))
4105 ((system-source-directory :uiop
) `(,(find-system :uiop
)))
4106 ((system-source-directory :asdf
) `(,(find-system :asdf
)))
4107 (t `(,@(if-let (uiop (uiop-library-pathname))
4108 `(,(make-library-system "uiop" uiop
)))
4109 ,(make-library-system "asdf" (asdf-library-pathname))))))
4112 (defmethod perform ((o link-op
) (c system
))
4113 (let* ((object-files (input-files o c
))
4114 (output (output-files o c
))
4115 (bundle (first output
))
4116 (programp (typep o
'program-op
))
4117 (kind (bundle-type o
)))
4119 (apply 'create-image
4121 (when programp
(prefix-lisp-object-files c
))
4123 (when programp
(postfix-lisp-object-files c
)))
4125 :prologue-code
(or (prologue-code o
) (when programp
(prologue-code c
)))
4126 :epilogue-code
(or (epilogue-code o
) (when programp
(epilogue-code c
)))
4127 :build-args
(or (extra-build-args o
) (when programp
(extra-build-args c
)))
4128 :extra-object-files
(or (extra-object-files o
) (when programp
(extra-object-files c
)))
4129 :no-uiop
(no-uiop c
)
4130 (when programp
`(:entry-point
,(component-entry-point c
))))))))
4132 #+(and (not asdf-use-unsafe-mac-bundle-op
)
4133 (or (and clasp ecl darwin
)
4134 (and abcl darwin
(not abcl-bundle-op-supported
))))
4135 (defmethod perform :before
((o basic-compile-bundle-op
) (c component
))
4136 (unless (featurep :asdf-use-unsafe-mac-bundle-op
)
4137 (cerror "Continue after modifying *FEATURES*."
4138 "BASIC-COMPILE-BUNDLE-OP operations are not supported on Mac OS X for this lisp.~%~T~
4139 To continue, push :asdf-use-unsafe-mac-bundle-op onto *FEATURES*.~%~T~
4140 Please report to ASDF-DEVEL if this works for you.")))
4143 ;;; Backward compatibility with pre-3.1.2 names
4144 ;; (defclass fasl-op (selfward-operation)
4145 ;; ((selfward-operation :initform 'compile-bundle-op :allocation :class)))
4146 ;; (defclass load-fasl-op (selfward-operation)
4147 ;; ((selfward-operation :initform 'load-bundle-op :allocation :class)))
4148 ;; (defclass binary-op (selfward-operation)
4149 ;; ((selfward-operation :initform 'deliver-asd-op :allocation :class)))
4150 ;; (defclass monolithic-fasl-op (selfward-operation)
4151 ;; ((selfward-operation :initform 'monolithic-compile-bundle-op :allocation :class)))
4152 ;; (defclass monolithic-load-fasl-op (selfward-operation)
4153 ;; ((selfward-operation :initform 'monolithic-load-bundle-op :allocation :class)))
4154 ;; (defclass monolithic-binary-op (selfward-operation)
4155 ;; ((selfward-operation :initform 'monolithic-deliver-asd-op :allocation :class)))
4156 ;;;; -------------------------------------------------------------------------
4157 ;;;; Concatenate-source
4159 (uiop/package
:define-package
:asdf
/concatenate-source
4160 (:recycle
:asdf
/concatenate-source
:asdf
)
4161 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
4162 :asdf
/component
:asdf
/operation
4163 :asdf
/system
:asdf
/find-system
4164 :asdf
/action
:asdf
/lisp-action
:asdf
/bundle
)
4166 #:concatenate-source-op
4167 #:load-concatenated-source-op
4168 #:compile-concatenated-source-op
4169 #:load-compiled-concatenated-source-op
4170 #:monolithic-concatenate-source-op
4171 #:monolithic-load-concatenated-source-op
4172 #:monolithic-compile-concatenated-source-op
4173 #:monolithic-load-compiled-concatenated-source-op
))
4174 (in-package :asdf
/concatenate-source
)
4177 ;;; Concatenate sources
4179 (with-upgradability ()
4180 (defclass basic-concatenate-source-op
(bundle-op)
4181 ((bundle-type :initform
"lisp")))
4182 (defclass basic-load-concatenated-source-op
(basic-load-op selfward-operation
) ())
4183 (defclass basic-compile-concatenated-source-op
(basic-compile-op selfward-operation
) ())
4184 (defclass basic-load-compiled-concatenated-source-op
(basic-load-op selfward-operation
) ())
4186 (defclass concatenate-source-op
(basic-concatenate-source-op non-propagating-operation
) ())
4187 (defclass load-concatenated-source-op
(basic-load-concatenated-source-op)
4188 ((selfward-operation :initform
'(prepare-op concatenate-source-op
) :allocation
:class
)))
4189 (defclass compile-concatenated-source-op
(basic-compile-concatenated-source-op)
4190 ((selfward-operation :initform
'(prepare-op concatenate-source-op
) :allocation
:class
)))
4191 (defclass load-compiled-concatenated-source-op
(basic-load-compiled-concatenated-source-op)
4192 ((selfward-operation :initform
'(prepare-op compile-concatenated-source-op
) :allocation
:class
)))
4194 (defclass monolithic-concatenate-source-op
(basic-concatenate-source-op monolithic-bundle-op non-propagating-operation
) ())
4195 (defclass monolithic-load-concatenated-source-op
(basic-load-concatenated-source-op)
4196 ((selfward-operation :initform
'monolithic-concatenate-source-op
:allocation
:class
)))
4197 (defclass monolithic-compile-concatenated-source-op
(basic-compile-concatenated-source-op)
4198 ((selfward-operation :initform
'monolithic-concatenate-source-op
:allocation
:class
)))
4199 (defclass monolithic-load-compiled-concatenated-source-op
(basic-load-compiled-concatenated-source-op)
4200 ((selfward-operation :initform
'monolithic-compile-concatenated-source-op
:allocation
:class
)))
4202 (defmethod input-files ((operation basic-concatenate-source-op
) (s system
))
4203 (loop :with encoding
= (or (component-encoding s
) *default-encoding
*)
4204 :with other-encodings
= '()
4205 :with around-compile
= (around-compile-hook s
)
4206 :with other-around-compile
= '()
4207 :for c
:in
(required-components
4208 s
:goal-operation
'compile-op
4209 :keep-operation
'compile-op
4210 :other-systems
(operation-monolithic-p operation
))
4212 (when (typep c
'cl-source-file
)
4213 (let ((e (component-encoding c
)))
4214 (unless (equal e encoding
)
4215 (let ((a (assoc e other-encodings
)))
4216 (if a
(push (component-find-path c
) (cdr a
))
4217 (push (list a
(component-find-path c
)) other-encodings
)))))
4218 (unless (equal around-compile
(around-compile-hook c
))
4219 (push (component-find-path c
) other-around-compile
))
4220 (input-files (make-operation 'compile-op
) c
)) :into inputs
4222 (when other-encodings
4223 (warn "~S uses encoding ~A but has sources that use these encodings:~{ ~A~}"
4225 (mapcar #'(lambda (x) (cons (car x
) (list (reverse (cdr x
)))))
4227 (when other-around-compile
4228 (warn "~S uses around-compile hook ~A but has sources that use these hooks: ~A"
4229 operation around-compile other-around-compile
))
4231 (defmethod output-files ((o basic-compile-concatenated-source-op
) (s system
))
4232 (lisp-compilation-output-files o s
))
4234 (defmethod perform ((o basic-concatenate-source-op
) (s system
))
4235 (let* ((ins (input-files o s
))
4236 (out (output-file o s
))
4237 (tmp (tmpize-pathname out
)))
4238 (concatenate-files ins tmp
)
4239 (rename-file-overwriting-target tmp out
)))
4240 (defmethod perform ((o basic-load-concatenated-source-op
) (s system
))
4241 (perform-lisp-load-source o s
))
4242 (defmethod perform ((o basic-compile-concatenated-source-op
) (s system
))
4243 (perform-lisp-compilation o s
))
4244 (defmethod perform ((o basic-load-compiled-concatenated-source-op
) (s system
))
4245 (perform-lisp-load-fasl o s
)))
4247 ;;;; -------------------------------------------------------------------------
4248 ;;;; Package systems in the style of quick-build or faslpath
4250 (uiop:define-package
:asdf
/package-inferred-system
4251 (:recycle
:asdf
/package-inferred-system
:asdf
/package-system
:asdf
)
4252 (:use
:uiop
/common-lisp
:uiop
4253 :asdf
/defsystem
;; Using the old name of :asdf/parse-defsystem for compatibility
4254 :asdf
/upgrade
:asdf
/component
:asdf
/system
:asdf
/find-system
:asdf
/lisp-action
)
4256 #:package-inferred-system
#:sysdef-package-inferred-system-search
4257 #:package-system
;; backward compatibility only. To be removed.
4258 #:register-system-packages
4259 #:*defpackage-forms
* #:*package-inferred-systems
* #:package-inferred-system-missing-package-error
))
4260 (in-package :asdf
/package-inferred-system
)
4262 (with-upgradability ()
4263 (defparameter *defpackage-forms
* '(defpackage define-package
))
4265 (defun initial-package-inferred-systems-table ()
4266 (let ((h (make-hash-table :test
'equal
)))
4267 (dolist (p (list-all-packages))
4268 (dolist (n (package-names p
))
4269 (setf (gethash n h
) t
)))
4272 (defvar *package-inferred-systems
* (initial-package-inferred-systems-table))
4274 (defclass package-inferred-system
(system)
4277 ;; For backward compatibility only. To be removed in an upcoming release:
4278 (defclass package-system
(package-inferred-system) ())
4280 (defun defpackage-form-p (form)
4282 (member (car form
) *defpackage-forms
*)))
4284 (defun stream-defpackage-form (stream)
4285 (loop :for form
= (read stream nil nil
) :while form
4286 :when
(defpackage-form-p form
) :return form
))
4288 (defun file-defpackage-form (file)
4289 "Return the first DEFPACKAGE form in FILE."
4290 (with-input-file (f file
)
4291 (stream-defpackage-form f
)))
4293 (define-condition package-inferred-system-missing-package-error
(system-definition-error)
4294 ((system :initarg
:system
:reader error-system
)
4295 (pathname :initarg
:pathname
:reader error-pathname
))
4296 (:report
(lambda (c s
)
4297 (format s
(compatfmt "~@<No package form found while ~
4298 trying to define package-inferred-system ~A from file ~A~>")
4299 (error-system c
) (error-pathname c
)))))
4301 (defun package-dependencies (defpackage-form)
4302 "Return a list of packages depended on by the package
4303 defined in DEFPACKAGE-FORM. A package is depended upon if
4304 the DEFPACKAGE-FORM uses it or imports a symbol from it."
4305 (assert (defpackage-form-p defpackage-form
))
4307 (while-collecting (dep)
4308 (loop* :for
(option . arguments
) :in
(cddr defpackage-form
) :do
4310 ((:use
:mix
:reexport
:use-reexport
:mix-reexport
)
4311 (dolist (p arguments
) (dep (string p
))))
4312 ((:import-from
:shadowing-import-from
)
4313 (dep (string (first arguments
))))
4314 ((:nicknames
:documentation
:shadow
:export
:intern
:unintern
:recycle
)))))
4315 :from-end t
:test
'equal
))
4317 (defun package-designator-name (package)
4319 (package (package-name package
))
4321 (symbol (string package
))))
4323 (defun register-system-packages (system packages
)
4324 "Register SYSTEM as providing PACKAGES."
4325 (let ((name (or (eq system t
) (coerce-name system
))))
4326 (dolist (p (ensure-list packages
))
4327 (setf (gethash (package-designator-name p
) *package-inferred-systems
*) name
))))
4329 (defun package-name-system (package-name)
4330 "Return the name of the SYSTEM providing PACKAGE-NAME, if such exists,
4331 otherwise return a default system name computed from PACKAGE-NAME."
4332 (check-type package-name string
)
4333 (if-let ((system-name (gethash package-name
*package-inferred-systems
*)))
4335 (string-downcase package-name
)))
4337 (defun package-inferred-system-file-dependencies (file &optional system
)
4338 (if-let (defpackage-form (file-defpackage-form file
))
4339 (remove t
(mapcar 'package-name-system
(package-dependencies defpackage-form
)))
4340 (error 'package-inferred-system-missing-package-error
:system system
:pathname file
)))
4342 (defun same-package-inferred-system-p (system name directory subpath dependencies
)
4343 (and (eq (type-of system
) 'package-inferred-system
)
4344 (equal (component-name system
) name
)
4345 (pathname-equal directory
(component-pathname system
))
4346 (equal dependencies
(component-sideway-dependencies system
))
4347 (let ((children (component-children system
)))
4348 (and (length=n-p children
1)
4349 (let ((child (first children
)))
4350 (and (eq (type-of child
) 'cl-source-file
)
4351 (equal (component-name child
) "lisp")
4352 (and (slot-boundp child
'relative-pathname
)
4353 (equal (slot-value child
'relative-pathname
) subpath
))))))))
4355 (defun sysdef-package-inferred-system-search (system)
4356 (let ((primary (primary-system-name system
)))
4357 (unless (equal primary system
)
4358 (let ((top (find-system primary nil
)))
4359 (when (typep top
'package-inferred-system
)
4360 (if-let (dir (system-source-directory top
))
4361 (let* ((sub (subseq system
(1+ (length primary
))))
4362 (f (probe-file* (subpathname dir sub
:type
"lisp")
4363 :truename
*resolve-symlinks
*)))
4364 (when (file-pathname-p f
)
4365 (let ((dependencies (package-inferred-system-file-dependencies f system
))
4366 (previous (cdr (system-registered-p system
))))
4367 (if (same-package-inferred-system-p previous system dir sub dependencies
)
4369 (eval `(defsystem ,system
4370 :class package-inferred-system
4373 :depends-on
,dependencies
4374 :components
((cl-source-file "lisp" :pathname
,sub
)))))))))))))))
4376 (with-upgradability ()
4377 (pushnew 'sysdef-package-inferred-system-search
*system-definition-search-functions
*)
4378 (setf *system-definition-search-functions
*
4379 (remove (find-symbol* :sysdef-package-system-search
:asdf
/package-system nil
)
4380 *system-definition-search-functions
*)))
4381 ;;;; -------------------------------------------------------------------------
4382 ;;; Internal hacks for backward-compatibility
4384 (uiop/package
:define-package
:asdf
/backward-internals
4385 (:recycle
:asdf
/backward-internals
:asdf
)
4386 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/find-system
)
4387 (:export
;; for internal use
4388 #:make-sub-operation
4389 #:load-sysdef
#:make-temporary-package
))
4390 (in-package :asdf
/backward-internals
)
4392 (when-upgrading (:when
(fboundp 'make-sub-operation
))
4393 (defun make-sub-operation (c o dep-c dep-o
)
4394 (declare (ignore c o dep-c dep-o
)) (asdf-upgrade-error)))
4397 (with-upgradability ()
4398 (defun load-sysdef (name pathname
)
4399 (load-asd pathname
:name name
))
4401 (defun make-temporary-package ()
4402 ;; For loading a .asd file, we don't make a temporary package anymore,
4403 ;; but use ASDF-USER. I'd like to have this function do this,
4404 ;; but since whoever uses it is likely to delete-package the result afterwards,
4405 ;; this would be a bad idea, so preserve the old behavior.
4406 (make-package (fresh-package-name :prefix
:asdf
:index
0) :use
'(:cl
:asdf
))))
4408 ;;;; -------------------------------------------------------------------------
4409 ;;; Backward-compatible interfaces
4411 (uiop/package
:define-package
:asdf
/backward-interface
4412 (:recycle
:asdf
/backward-interface
:asdf
)
4413 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
4414 :asdf
/component
:asdf
/system
:asdf
/find-system
:asdf
/operation
:asdf
/action
4415 :asdf
/lisp-action
:asdf
/plan
:asdf
/operate
:asdf
/output-translations
)
4418 #:operation-error
#:compile-error
#:compile-failed
#:compile-warned
4419 #:error-component
#:error-operation
#:traverse
4420 #:component-load-dependencies
4421 #:enable-asdf-binary-locations-compatibility
4423 #:operation-on-failure
#:operation-on-warnings
#:on-failure
#:on-warnings
4424 #:component-property
4426 #:system-definition-pathname
))
4427 (in-package :asdf
/backward-interface
)
4429 (with-upgradability ()
4430 (define-condition operation-error
(error) ;; Bad, backward-compatible name
4431 ;; Used by SBCL, cffi-tests, clsql-mysql, clsql-uffi, qt, elephant, uffi-tests, sb-grovel
4432 ((component :reader error-component
:initarg
:component
)
4433 (operation :reader error-operation
:initarg
:operation
))
4434 (:report
(lambda (c s
)
4435 (format s
(compatfmt "~@<~A while invoking ~A on ~A~@:>")
4436 (type-of c
) (error-operation c
) (error-component c
)))))
4437 (define-condition compile-error
(operation-error) ())
4438 (define-condition compile-failed
(compile-error) ())
4439 (define-condition compile-warned
(compile-error) ())
4441 (defun component-load-dependencies (component)
4442 ;; Old deprecated name for the same thing. Please update your software.
4443 (component-sideway-dependencies component
))
4445 (defgeneric operation-forced
(operation)) ;; Used by swank.asd for swank-loader.
4446 (defmethod operation-forced ((o operation
)) (getf (operation-original-initargs o
) :force
))
4448 (defgeneric operation-on-warnings
(operation))
4449 (defgeneric operation-on-failure
(operation))
4450 (defgeneric (setf operation-on-warnings
) (x operation
))
4451 (defgeneric (setf operation-on-failure
) (x operation
))
4452 (defmethod operation-on-warnings ((o operation
))
4453 *compile-file-warnings-behaviour
*)
4454 (defmethod operation-on-failure ((o operation
))
4455 *compile-file-failure-behaviour
*)
4456 (defmethod (setf operation-on-warnings
) (x (o operation
))
4457 (setf *compile-file-warnings-behaviour
* x
))
4458 (defmethod (setf operation-on-failure
) (x (o operation
))
4459 (setf *compile-file-failure-behaviour
* x
))
4461 (defun system-definition-pathname (x)
4462 ;; As of 2.014.8, we mean to make this function obsolete,
4463 ;; but that won't happen until all clients have been updated.
4464 ;;(cerror "Use ASDF:SYSTEM-SOURCE-FILE instead"
4465 "Function ASDF:SYSTEM-DEFINITION-PATHNAME is obsolete.
4466 It used to expose ASDF internals with subtle differences with respect to
4467 user expectations, that have been refactored away since.
4468 We recommend you use ASDF:SYSTEM-SOURCE-FILE instead
4469 for a mostly compatible replacement that we're supporting,
4470 or even ASDF:SYSTEM-SOURCE-DIRECTORY or ASDF:SYSTEM-RELATIVE-PATHNAME
4471 if that's whay you mean." ;;)
4472 (system-source-file x
))
4474 (defgeneric* (traverse) (operation component
&key
&allow-other-keys
)
4476 "Generate and return a plan for performing OPERATION on COMPONENT.
4478 The plan returned is a list of dotted-pairs. Each pair is the CONS
4479 of ASDF operation object and a COMPONENT object. The pairs will be
4480 processed in order by OPERATE."))
4481 (define-convenience-action-methods traverse
(operation component
&key
))
4483 (defmethod traverse ((o operation
) (c component
) &rest keys
&key plan-class
&allow-other-keys
)
4484 (plan-actions (apply 'make-plan plan-class o c keys
))))
4487 ;;;; ASDF-Binary-Locations compatibility
4488 ;; This remains supported for legacy user, but not recommended for new users.
4489 (with-upgradability ()
4490 (defun enable-asdf-binary-locations-compatibility
4492 (centralize-lisp-binaries nil
)
4493 (default-toplevel-directory
4494 (subpathname (user-homedir-pathname) ".fasls/")) ;; Use ".cache/common-lisp/" instead ???
4495 (include-per-user-information nil
)
4496 (map-all-source-files (or #+(or clasp clisp ecl mkcl
) t nil
))
4497 (source-to-target-mappings nil
)
4498 (file-types `(,(compile-file-type)
4500 #+(or clasp ecl
) (compile-file-type :type
:object
)
4501 #+mkcl
(compile-file-type :fasl-p nil
)
4502 #+clisp
"lib" #+sbcl
"cfasl"
4503 #+sbcl
"sbcl-warnings" #+clozure
"ccl-warnings")))
4504 #+(or clasp clisp ecl mkcl
)
4505 (when (null map-all-source-files
)
4506 (error "asdf:enable-asdf-binary-locations-compatibility doesn't support :map-all-source-files nil on CLISP, ECL and MKCL"))
4507 (let* ((patterns (if map-all-source-files
(list *wild-file
*)
4508 (loop :for type
:in file-types
4509 :collect
(make-pathname :type type
:defaults
*wild-file
*))))
4510 (destination-directory
4511 (if centralize-lisp-binaries
4512 `(,default-toplevel-directory
4513 ,@(when include-per-user-information
4514 (cdr (pathname-directory (user-homedir-pathname))))
4515 :implementation
,*wild-inferiors
*)
4516 `(:root
,*wild-inferiors
* :implementation
))))
4517 (initialize-output-translations
4518 `(:output-translations
4519 ,@source-to-target-mappings
4520 #+abcl
(#p
"jar:file:/**/*.jar!/**/*.*" (:function translate-jar-pathname
))
4521 #+abcl
(#p
"/___jar___file___root___/**/*.*" (,@destination-directory
))
4522 ,@(loop :for pattern
:in patterns
4523 :collect
`((:root
,*wild-inferiors
* ,pattern
)
4524 (,@destination-directory
,pattern
)))
4526 :ignore-inherited-configuration
))))
4528 (defmethod operate :before
(operation-class system
&rest args
&key
&allow-other-keys
)
4529 (declare (ignore operation-class system args
))
4530 (when (find-symbol* '#:output-files-for-system-and-operation
:asdf nil
)
4531 (error "ASDF 2 is not compatible with ASDF-BINARY-LOCATIONS, which you are using.
4532 ASDF 2 now achieves the same purpose with its builtin ASDF-OUTPUT-TRANSLATIONS,
4533 which should be easier to configure. Please stop using ASDF-BINARY-LOCATIONS,
4534 and instead use ASDF-OUTPUT-TRANSLATIONS. See the ASDF manual for details.
4535 In case you insist on preserving your previous A-B-L configuration, but
4536 do not know how to achieve the same effect with A-O-T, you may use function
4537 ASDF:ENABLE-ASDF-BINARY-LOCATIONS-COMPATIBILITY as documented in the manual;
4538 call that function where you would otherwise have loaded and configured A-B-L."))))
4541 ;;; run-shell-command
4542 ;; WARNING! The function below is not just deprecated but also dysfunctional.
4543 ;; Please use asdf/run-program:run-program instead.
4544 (with-upgradability ()
4545 (defun run-shell-command (control-string &rest args
)
4546 "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and
4547 synchronously execute the result using a Bourne-compatible shell, with
4548 output to *VERBOSE-OUT*. Returns the shell's exit code.
4551 Deprecated function, for backward-compatibility only.
4552 Please use UIOP:RUN-PROGRAM instead."
4553 (let ((command (apply 'format nil control-string args
)))
4554 (asdf-message "; $ ~A~%" command
)
4557 (nth-value 2 (run-program command
:force-shell t
:ignore-error-status t
4558 :output
*verbose-out
*)))))
4560 ((integer 0 255) exit-code
)
4563 (with-upgradability ()
4564 (defvar *asdf-verbose
* nil
)) ;; backward-compatibility with ASDF2 only. Unused.
4566 ;; backward-compatibility methods. Do NOT use in new code. NOT SUPPORTED.
4567 (with-upgradability ()
4568 (defgeneric component-property
(component property
))
4569 (defgeneric (setf component-property
) (new-value component property
))
4571 (defmethod component-property ((c component
) property
)
4572 (cdr (assoc property
(slot-value c
'properties
) :test
#'equal
)))
4574 (defmethod (setf component-property
) (new-value (c component
) property
)
4575 (let ((a (assoc property
(slot-value c
'properties
) :test
#'equal
)))
4577 (setf (cdr a
) new-value
)
4578 (setf (slot-value c
'properties
)
4579 (acons property new-value
(slot-value c
'properties
)))))
4581 ;;;; ---------------------------------------------------------------------------
4582 ;;;; Handle ASDF package upgrade, including implementation-dependent magic.
4584 (uiop/package
:define-package
:asdf
/interface
4585 (:nicknames
:asdf
:asdf-utilities
)
4586 (:recycle
:asdf
/interface
:asdf
)
4588 #:loaded-systems
; makes for annoying SLIME completion
4589 #:output-files-for-system-and-operation
) ; ASDF-BINARY-LOCATION function we use to detect ABL
4590 (:use
:uiop
/common-lisp
:uiop
:asdf
/upgrade
:asdf
/cache
4591 :asdf
/component
:asdf
/system
:asdf
/find-system
:asdf
/find-component
4592 :asdf
/operation
:asdf
/action
:asdf
/lisp-action
4593 :asdf
/output-translations
:asdf
/source-registry
4594 :asdf
/plan
:asdf
/operate
:asdf
/parse-defsystem
:asdf
/bundle
:asdf
/concatenate-source
4595 :asdf
/backward-internals
:asdf
/backward-interface
:asdf
/package-inferred-system
)
4596 ;; Note: (1) we are NOT automatically reexporting everything from previous packages.
4597 ;; (2) we only reexport UIOP functionality when backward-compatibility requires it.
4599 #:defsystem
#:find-system
#:load-asd
#:locate-system
#:coerce-name
#:primary-system-name
4600 #:oos
#:operate
#:make-plan
#:perform-plan
#:sequential-plan
4601 #:system-definition-pathname
4602 #:search-for-system-definition
#:find-component
#:component-find-path
4603 #:compile-system
#:load-system
#:load-systems
#:load-systems
*
4604 #:require-system
#:test-system
#:clear-system
4605 #:operation
#:make-operation
#:find-operation
4606 #:upward-operation
#:downward-operation
#:sideway-operation
#:selfward-operation
4607 #:non-propagating-operation
4609 #:load-op
#:prepare-op
#:compile-op
4610 #:prepare-source-op
#:load-source-op
#:test-op
4611 #:feature
#:version
#:version-satisfies
#:upgrade-asdf
4612 #:implementation-identifier
#:implementation-type
#:hostname
4613 #:input-files
#:output-files
#:output-file
#:perform
#:perform-with-restarts
4614 #:operation-done-p
#:explain
#:action-description
#:component-sideway-dependencies
4616 #:component-load-dependencies
#:run-shell-command
; deprecated, do not use
4617 #:bundle-op
#:monolithic-bundle-op
#:precompiled-system
#:compiled-file
#:bundle-system
4618 #:program-system
#:make-build
4619 #:basic-compile-bundle-op
#:prepare-bundle-op
4620 #:compile-bundle-op
#:load-bundle-op
#:monolithic-compile-bundle-op
#:monolithic-load-bundle-op
4621 #:lib-op
#:dll-op
#:deliver-asd-op
#:program-op
#:image-op
4622 #:monolithic-lib-op
#:monolithic-dll-op
#:monolithic-deliver-asd-op
4623 #:concatenate-source-op
4624 #:load-concatenated-source-op
4625 #:compile-concatenated-source-op
4626 #:load-compiled-concatenated-source-op
4627 #:monolithic-concatenate-source-op
4628 #:monolithic-load-concatenated-source-op
4629 #:monolithic-compile-concatenated-source-op
4630 #:monolithic-load-compiled-concatenated-source-op
4631 #:operation-monolithic-p
4632 #:required-components
4633 #:component-loaded-p
4635 #:component
#:parent-component
#:child-component
#:system
#:module
4636 #:file-component
#:source-file
#:c-source-file
#:java-source-file
4637 #:cl-source-file
#:cl-source-file.cl
#:cl-source-file.lsp
4638 #:static-file
#:doc-file
#:html-file
4639 #:file-type
#:source-file-type
4641 #:register-preloaded-system
#:sysdef-preloaded-system-search
4642 #:register-immutable-system
#:sysdef-immutable-system-search
4644 #:package-inferred-system
#:register-system-packages
4645 #:package-system
;; backward-compatibility during migration, to be removed in a further release.
4647 #:component-children
; component accessors
4648 #:component-children-by-name
4649 #:component-pathname
4650 #:component-relative-pathname
4655 #:component-encoding
4656 #:component-external-format
4658 #:component-depends-on
; backward-compatible name rather than action-depends-on
4659 #:module-components
; backward-compatibility
4660 #:operation-on-warnings
#:operation-on-failure
; backward-compatibility
4661 #:component-property
; backward-compatibility
4662 #:traverse
; backward-compatibility
4664 #:system-description
4665 #:system-long-description
4670 #:system-source-file
4671 #:system-source-directory
4672 #:system-relative-pathname
4675 #:system-bug-tracker
4677 #:system-source-control
4679 #:system-defsystem-depends-on
4681 #:system-weakly-depends-on
4683 #:*system-definition-search-functions
* ; variables
4684 #:*central-registry
*
4685 #:*compile-file-warnings-behaviour
*
4686 #:*compile-file-failure-behaviour
*
4687 #:*resolve-symlinks
*
4688 #:*load-system-operation
*
4689 #:*asdf-verbose
* ;; unused. For backward-compatibility only.
4694 #:compile-condition
#:compile-file-error
#:compile-warned-error
#:compile-failed-error
4695 #:compile-warned-warning
#:compile-failed-warning
4696 #:operation-error
#:compile-failed
#:compile-warned
#:compile-error
;; backward compatibility
4699 #:load-system-definition-error
4700 #:error-component
#:error-operation
4701 #:system-definition-error
4703 #:missing-component-of-version
4704 #:missing-dependency
4705 #:missing-dependency-of-version
4706 #:circular-dependency
; errors
4707 #:duplicate-names
#:non-toplevel-system
#:non-system-system
4708 #:package-inferred-system-missing-package-error
4709 #:operation-definition-warning
#:operation-definition-error
4711 #:try-recompiling
; restarts
4714 #:coerce-entry-to-directory
4715 #:remove-entry-from-registry
4716 #:clear-configuration-and-retry
4719 #:*encoding-detection-hook
*
4720 #:*encoding-external-format-hook
*
4721 #:*default-encoding
*
4722 #:*utf-8-external-format
*
4724 #:clear-configuration
4725 #:*output-translations-parameter
*
4726 #:initialize-output-translations
4727 #:disable-output-translations
4728 #:clear-output-translations
4729 #:ensure-output-translations
4730 #:apply-output-translations
4732 #:compile-file-pathname
*
4733 #:*warnings-file-type
* #:enable-deferred-warnings-check
#:disable-deferred-warnings-check
4734 #:enable-asdf-binary-locations-compatibility
4735 #:*default-source-registries
*
4736 #:*source-registry-parameter
*
4737 #:initialize-source-registry
4738 #:compute-source-registry
4739 #:clear-source-registry
4740 #:ensure-source-registry
4741 #:process-source-registry
4742 #:system-registered-p
#:registered-systems
#:already-loaded-systems
4746 #:user-output-translations-pathname
4747 #:system-output-translations-pathname
4748 #:user-output-translations-directory-pathname
4749 #:system-output-translations-directory-pathname
4750 #:user-source-registry
4751 #:system-source-registry
4752 #:user-source-registry-directory
4753 #:system-source-registry-directory
4756 ;;;; ---------------------------------------------------------------------------
4757 ;;;; ASDF-USER, where the action happens.
4759 (uiop/package
:define-package
:asdf
/user
4760 (:nicknames
:asdf-user
)
4761 ;; NB: releases before 3.1.2 this :use'd only uiop/package instead of uiop below.
4762 ;; They also :use'd uiop/common-lisp, that reexports common-lisp and is not included in uiop.
4763 ;; ASDF3 releases from 2.27 to 2.31 called uiop asdf-driver and asdf/foo uiop/foo.
4764 ;; ASDF1 and ASDF2 releases (2.26 and earlier) create a temporary package
4765 ;; that only :use's :cl and :asdf
4766 (:use
:uiop
/common-lisp
:uiop
:asdf
/interface
))
4767 ;;;; -----------------------------------------------------------------------
4768 ;;;; ASDF Footer: last words and cleanup
4770 (uiop/package
:define-package
:asdf
/footer
4771 (:recycle
:asdf
/footer
:asdf
)
4772 (:use
:uiop
/common-lisp
:uiop
4773 :asdf
/upgrade
:asdf
/find-system
:asdf
/operate
:asdf
/bundle
))
4774 (in-package :asdf
/footer
)
4776 ;;;; Hook ASDF into the implementation's REQUIRE and other entry points.
4777 #+(or abcl clasp clisp clozure cmu ecl mkcl sbcl
)
4778 (with-upgradability ()
4779 (if-let (x (and #+clisp
(find-symbol* '#:*module-provider-functions
* :custom nil
)))
4780 (eval `(pushnew 'module-provide-asdf
4781 #+abcl sys
::*module-provider-functions
*
4782 #+(or clasp cmu ecl
) ext
:*module-provider-functions
*
4784 #+clozure ccl
:*module-provider-functions
*
4785 #+mkcl mk-ext
:*module-provider-functions
*
4786 #+sbcl sb-ext
:*module-provider-functions
*)))
4788 #+(or clasp ecl mkcl
)
4790 (pushnew '("fasb" . si
::load-binary
) si
::*load-hooks
* :test
'equal
:key
'car
)
4792 #+(or (and clasp windows
) (and ecl win32
) (and mkcl windows
))
4793 (unless (assoc "asd" #+(or clasp ecl
) ext
:*load-hooks
* #+mkcl si
::*load-hooks
* :test
'equal
)
4794 (appendf #+(or clasp ecl
) ext
:*load-hooks
* #+mkcl si
::*load-hooks
* '(("asd" . si
::load-source
))))
4796 (setf #+(or clasp ecl
) ext
:*module-provider-functions
* #+mkcl mk-ext
::*module-provider-functions
*
4797 (loop :for f
:in
#+(or clasp ecl
) ext
:*module-provider-functions
*
4798 #+mkcl mk-ext
::*module-provider-functions
*
4800 (if (eq f
'module-provide-asdf
) f
4802 (let ((l (multiple-value-list (funcall f name
))))
4803 (and (first l
) (register-preloaded-system (coerce-name name
)))
4804 (values-list l
))))))))
4806 #+cmu
;; Hook into the CMUCL herald.
4807 (with-upgradability ()
4808 (defun herald-asdf (stream)
4809 (format stream
" ASDF ~A" (asdf-version)))
4810 (setf (getf ext
:*herald-items
* :asdf
) `(herald-asdf)))
4814 (with-upgradability ()
4816 (when (boundp 'excl
:*warn-on-nested-reader-conditionals
*)
4817 (setf excl
:*warn-on-nested-reader-conditionals
* asdf
/common-lisp
::*acl-warn-save
*))
4819 (dolist (f '(:asdf
:asdf2
:asdf3
:asdf3.1
:asdf-package-system
)) (pushnew f
*features
*))
4821 ;; Provide both lowercase and uppercase, to satisfy more people, especially LispWorks users.
4822 (provide "asdf") (provide "ASDF")
4824 (cleanup-upgraded-asdf))
4826 (when *load-verbose
*
4827 (asdf-message ";; ASDF, version ~a~%" (asdf-version)))