[git] CMU Common Lisp branch master updated. snapshot-2014-05-1-g18e61a1
Raymond Toy
rtoy at common-lisp.net
Wed May 7 02:49:40 UTC 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".
The branch, master has been updated
via 18e61a1940ee181a9583ded9044286d8b7983da7 (commit)
from fc6ec6d77cdde9c73bb3b6c8a2c5d1d6ced9094f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 18e61a1940ee181a9583ded9044286d8b7983da7
Author: Raymond Toy <toy.raymond at gmail.com>
Date: Tue May 6 19:49:23 2014 -0700
Update to ASDF 3.1.2.
diff --git a/src/contrib/asdf/asdf.lisp b/src/contrib/asdf/asdf.lisp
index 3592557..cce093d 100644
--- a/src/contrib/asdf/asdf.lisp
+++ b/src/contrib/asdf/asdf.lisp
@@ -1,5 +1,5 @@
-;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp -*-
-;;; This is ASDF 3.0.3: Another System Definition Facility.
+;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp ; buffer-read-only: t; -*-
+;;; This is ASDF 3.1.2: Another System Definition Facility.
;;;
;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <asdf-devel at common-lisp.net>.
@@ -19,7 +19,7 @@
;;; http://www.opensource.org/licenses/mit-license.html on or about
;;; Monday; July 13, 2009)
;;;
-;;; Copyright (c) 2001-2012 Daniel Barlow and contributors
+;;; Copyright (c) 2001-2014 Daniel Barlow and contributors
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining
;;; a copy of this software and associated documentation files (the
@@ -51,10 +51,16 @@
#+cmu
(eval-when (:load-toplevel :compile-toplevel :execute)
- (declaim (optimize (speed 1) (safety 3) (debug 3)))
(setf ext:*gc-verbose* nil))
-#+(or abcl clisp clozure cmu ecl xcl) ;; punt on hard package upgrade on those implementations
+;;; pre 1.3.0 ABCL versions do not support the bundle-op on Mac OS X
+#+abcl
+(eval-when (:load-toplevel :compile-toplevel :execute)
+ (unless (and (member :darwin *features*)
+ (second (third (sys::arglist 'directory))))
+ (push :abcl-bundle-op-supported *features*)))
+
+;; Punt on hard package upgrade: from ASDF1 always, and even from ASDF2 on most implementations.
(eval-when (:load-toplevel :compile-toplevel :execute)
(unless (member :asdf3 *features*)
(let* ((existing-version
@@ -71,11 +77,12 @@
(existing-version-number (and existing-version (read-from-string existing-major-minor)))
(away (format nil "~A-~A" :asdf existing-version)))
(when (and existing-version
- (< existing-version-number 2.27))
+ (< existing-version-number
+ #+(or allegro clisp lispworks sbcl) 2.0
+ #-(or allegro clisp lispworks sbcl) 2.27))
(rename-package :asdf away)
(when *load-verbose*
(format t "~&; Renamed old ~A package away to ~A~%" :asdf away))))))
-
;;;; ---------------------------------------------------------------------------
;;;; Handle ASDF package upgrade, including implementation-dependent magic.
;;
@@ -562,7 +569,7 @@ or when loading the package is optional."
(home-package-p existing to-package) (symbol-package-name existing)))
(t
(ensure-inherited name symbol to-package from-package t shadowed imported inherited)))))))
-
+
(defun recycle-symbol (name recycle exported)
;; Takes a symbol NAME (a string), a list of package designators for RECYCLE
;; packages, and a hash-table of names (strings) of symbols scheduled to be
@@ -615,7 +622,7 @@ or when loading the package is optional."
(unintern existing))
(when intern
(intern* name package))))))))
- (declaim (ftype function ensure-exported))
+ (declaim (ftype (function (t t t &optional t) t) ensure-exported))
(defun ensure-exported-to-user (name symbol to-package &optional recycle)
(check-type name string)
(check-type symbol symbol)
@@ -656,7 +663,7 @@ or when loading the package is optional."
import-from export intern
recycle mix reexport
unintern)
- #+(or gcl2.6 genera) (declare (ignore documentation))
+ #+genera (declare (ignore documentation))
(let* ((package-name (string name))
(nicknames (mapcar #'string nicknames))
(names (cons package-name nicknames))
@@ -678,7 +685,7 @@ or when loading the package is optional."
;; string to list home package and use package:
(inherited (make-hash-table :test 'equal)))
(when-package-fishiness (record-fishy package-name))
- #-(or gcl2.6 genera)
+ #-genera
(when documentation (setf (documentation package t) documentation))
(loop :for p :in (set-difference (package-use-list package) (append mix use))
:do (note-package-fishiness :over-use name (package-names p))
@@ -758,22 +765,26 @@ or when loading the package is optional."
:with documentation = nil
:for (kw . args) :in clauses
:when (eq kw :nicknames) :append args :into nicknames :else
- :when (eq kw :documentation)
- :do (cond
- (documentation (error "define-package: can't define documentation twice"))
- ((or (atom args) (cdr args)) (error "define-package: bad documentation"))
- (t (setf documentation (car args)))) :else
+ :when (eq kw :documentation)
+ :do (cond
+ (documentation (error "define-package: can't define documentation twice"))
+ ((or (atom args) (cdr args)) (error "define-package: bad documentation"))
+ (t (setf documentation (car args)))) :else
:when (eq kw :use) :append args :into use :and :do (setf use-p t) :else
- :when (eq kw :shadow) :append args :into shadow :else
- :when (eq kw :shadowing-import-from) :collect args :into shadowing-import-from :else
- :when (eq kw :import-from) :collect args :into import-from :else
- :when (eq kw :export) :append args :into export :else
- :when (eq kw :intern) :append args :into intern :else
- :when (eq kw :recycle) :append args :into recycle :and :do (setf recycle-p t) :else
- :when (eq kw :mix) :append args :into mix :else
- :when (eq kw :reexport) :append args :into reexport :else
- :when (eq kw :unintern) :append args :into unintern :else
- :do (error "unrecognized define-package keyword ~S" kw)
+ :when (eq kw :shadow) :append args :into shadow :else
+ :when (eq kw :shadowing-import-from) :collect args :into shadowing-import-from :else
+ :when (eq kw :import-from) :collect args :into import-from :else
+ :when (eq kw :export) :append args :into export :else
+ :when (eq kw :intern) :append args :into intern :else
+ :when (eq kw :recycle) :append args :into recycle :and :do (setf recycle-p t) :else
+ :when (eq kw :mix) :append args :into mix :else
+ :when (eq kw :reexport) :append args :into reexport :else
+ :when (eq kw :use-reexport) :append args :into use :and :append args :into reexport
+ :and :do (setf use-p t) :else
+ :when (eq kw :mix-reexport) :append args :into mix :and :append args :into reexport
+ :and :do (setf use-p t) :else
+ :when (eq kw :unintern) :append args :into unintern :else
+ :do (error "unrecognized define-package keyword ~S" kw)
:finally (return `(,package
:nicknames ,nicknames :documentation ,documentation
:use ,(if use-p use '(:common-lisp))
@@ -783,7 +794,7 @@ or when loading the package is optional."
:mix ,mix :reexport ,reexport :unintern ,unintern)))))
(defmacro define-package (package &rest clauses)
- "DEFINE-PACKAGE takes a PACKAGE and a number of CLAUSES, of the form
+ "DEFINE-PACKAGE takes a PACKAGE and a number of CLAUSES, of the form
\(KEYWORD . ARGS\).
DEFINE-PACKAGE supports the following keywords:
USE, SHADOW, SHADOWING-IMPORT-FROM, IMPORT-FROM, EXPORT, INTERN -- as per CL:DEFPACKAGE.
@@ -797,10 +808,10 @@ should appear in first position if it already exists, and even if it doesn't,
ahead of any package that is not going to be deleted afterwards and never
created again. In short, except for special cases, always make it the first
package on the list if the list is not empty.
-MIX -- Takes a list of package designators. MIX behaves like
+MIX -- Takes a list of package designators. MIX behaves like
\(:USE PKG1 PKG2 ... PKGn\) but additionally uses :SHADOWING-IMPORT-FROM to
resolve conflicts in favor of the first found symbol. It may still yield
-an error if there is a conflict with an explicitly :SHADOWING-IMPORT-FROM symbol.
+an error if there is a conflict with an explicitly :IMPORT-FROM symbol.
REEXPORT -- Takes a list of package designators. For each package, p, in the list,
export symbols with the same name as those exported from p. Note that in the case
of shadowing, etc. the symbols with the same name may not be the same symbols.
@@ -808,10 +819,7 @@ UNINTERN -- Remove symbols here from PACKAGE."
(let ((ensure-form
`(apply 'ensure-package ',(parse-define-package-form package clauses))))
`(progn
- #+clisp
- (eval-when (:compile-toplevel :load-toplevel :execute)
- ,ensure-form)
- #+(or clisp ecl gcl) (defpackage ,package (:use))
+ #+(or ecl gcl mkcl) (defpackage ,package (:use))
(eval-when (:compile-toplevel :load-toplevel :execute)
,ensure-form))))
@@ -823,21 +831,7 @@ UNINTERN -- Remove symbols here from PACKAGE."
#+allegro ;; We need to disable autoloading BEFORE any mention of package ASDF.
(setf excl::*autoload-package-name-alist*
(remove "asdf" excl::*autoload-package-name-alist*
- :test 'equalp :key 'car))
- #+gcl
- ;; Debian's GCL 2.7 has bugs with compiling multiple-value stuff,
- ;; but can run ASDF 2.011. GCL 2.6 has even more issues.
- (cond
- ((or (< system::*gcl-major-version* 2)
- (and (= system::*gcl-major-version* 2)
- (< system::*gcl-minor-version* 6)))
- (error "GCL 2.6 or later required to use ASDF"))
- ((and (= system::*gcl-major-version* 2)
- (= system::*gcl-minor-version* 6))
- (pushnew 'ignorable pcl::*variable-declarations-without-argument*)
- (pushnew :gcl2.6 *features*))
- (t
- (pushnew :gcl2.7 *features*))))
+ :test 'equalp :key 'car)))
;; Compatibility with whoever calls asdf/package
(define-package :asdf/package (:use :cl :uiop/package) (:reexport :uiop/package))
@@ -860,8 +854,6 @@ UNINTERN -- Remove symbols here from PACKAGE."
(:export
#:logical-pathname #:translate-logical-pathname
#:make-broadcast-stream #:file-namestring)
- #+gcl2.6 (:shadow #:type-of #:with-standard-io-syntax) ; causes errors when loading fasl(!)
- #+gcl2.6 (:shadowing-import-from :system #:*load-pathname*)
#+genera (:shadowing-import-from :scl #:boolean)
#+genera (:export #:boolean #:ensure-directories-exist)
#+mcl (:shadow #:user-homedir-pathname))
@@ -875,7 +867,7 @@ UNINTERN -- Remove symbols here from PACKAGE."
;;;; Early meta-level tweaks
-#+(or abcl allegro clisp cmu ecl mkcl clozure lispworks sbcl scl)
+#+(or abcl allegro clisp cmu ecl mkcl clozure lispworks mkcl sbcl scl)
(eval-when (:load-toplevel :compile-toplevel :execute)
;; Check for unicode at runtime, so that a hypothetical FASL compiled with unicode
;; but loaded in a non-unicode setting (e.g. on Allegro) won't tell a lie.
@@ -925,48 +917,21 @@ UNINTERN -- Remove symbols here from PACKAGE."
(defun use-ecl-byte-compiler-p () (and (member :ecl-bytecmp *features*) t))
(unless (use-ecl-byte-compiler-p) (require :cmp)))
-#+gcl ;; Debian's GCL 2.7 has bugs with compiling multiple-value stuff, but can run ASDF 2.011
+#+gcl
(eval-when (:load-toplevel :compile-toplevel :execute)
(unless (member :ansi-cl *features*)
(error "ASDF only supports GCL in ANSI mode. Aborting.~%"))
(setf compiler::*compiler-default-type* (pathname "")
- compiler::*lsp-ext* ""))
-
-#+gcl2.6
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (shadow 'type-of :uiop/common-lisp)
- (shadowing-import 'system:*load-pathname* :uiop/common-lisp))
-
-#+gcl2.6
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (export 'type-of :uiop/common-lisp)
- (export 'system:*load-pathname* :uiop/common-lisp))
-
-#+gcl2.6 ;; Doesn't support either logical-pathnames or output-translations.
-(eval-when (:load-toplevel :compile-toplevel :execute)
- (defvar *gcl2.6* t)
- (deftype logical-pathname () nil)
- (defun type-of (x) (class-name (class-of x)))
- (defun wild-pathname-p (path) (declare (ignore path)) nil)
- (defun translate-logical-pathname (x) x)
- (defvar *compile-file-pathname* nil)
- (defun pathname-match-p (in-pathname wild-pathname)
- (declare (ignore in-wildname wild-wildname)) nil)
- (defun translate-pathname (source from-wildname to-wildname &key)
- (declare (ignore from-wildname to-wildname)) source)
- (defun %print-unreadable-object (object stream type identity thunk)
- (format stream "#<~@[~S ~]" (when type (type-of object)))
- (funcall thunk)
- (format stream "~@[ ~X~]>" (when identity (system:address object))))
- (defmacro with-standard-io-syntax (&body body)
- `(progn , at body))
- (defmacro with-compilation-unit (options &body body)
- (declare (ignore options)) `(progn , at body))
- (defmacro print-unreadable-object ((object stream &key type identity) &body body)
- `(%print-unreadable-object ,object ,stream ,type ,identity (lambda () , at body)))
- (defun ensure-directories-exist (path)
- (lisp:system (format nil "mkdir -p ~S"
- (namestring (make-pathname :name nil :type nil :version nil :defaults path))))))
+ compiler::*lsp-ext* "")
+ #.(let ((code ;; Only support very recent GCL 2.7.0 from November 2013 or later.
+ (cond
+ #+gcl
+ ((or (< system::*gcl-major-version* 2)
+ (and (= system::*gcl-major-version* 2)
+ (< system::*gcl-minor-version* 7)))
+ '(error "GCL 2.7 or later required to use ASDF")))))
+ (eval code)
+ code))
#+genera
(eval-when (:load-toplevel :compile-toplevel :execute)
@@ -1015,7 +980,7 @@ FROB them, that is to say, remove them if FROB is NIL,
replace by FROB if FROB is a STRING, or if FROB is a FUNCTION,
call FROB with the match and a function that emits a string in the output.
Return a string made of the parts not omitted or emitted by FROB."
- (declare (optimize (speed 0) (safety 3) (debug 3)))
+ (declare (optimize (speed 0) (safety #-gcl 3 #+gcl 0) (debug 3)))
(let ((length (length string)) (stream nil))
(labels ((emit-string (x &optional (start 0) (end (length x)))
(when (< start end)
@@ -1049,7 +1014,7 @@ Return a string made of the parts not omitted or emitted by FROB."
(defmacro compatfmt (format)
#+(or gcl genera)
- (frob-substrings format `("~3i~_" #+(or genera gcl2.6) ,@'("~@<" "~@;" "~@:>" "~:>")))
+ (frob-substrings format `("~3i~_" #+genera ,@'("~@<" "~@;" "~@:>" "~:>")))
#-(or gcl genera) format))
;;;; -------------------------------------------------------------------------
;;;; General Purpose Utilities for ASDF
@@ -1066,8 +1031,9 @@ Return a string made of the parts not omitted or emitted by FROB."
(:export
;; magic helper to define debugging functions:
#:uiop-debug #:load-uiop-debug-utility #:*uiop-debug-utility*
- #:undefine-function #:undefine-functions #:defun* #:defgeneric* #:with-upgradability ;; (un)defining functions
- #:if-let ;; basic flow control
+ #:with-upgradability ;; (un)defining functions in an upgrade-friendly way
+ #:undefine-function #:undefine-functions #:defun* #:defgeneric*
+ #:nest #:if-let ;; basic flow control
#:while-collecting #:appendf #:length=n-p #:ensure-list ;; lists
#:remove-plist-keys #:remove-plist-key ;; plists
#:emptyp ;; sequences
@@ -1076,7 +1042,7 @@ Return a string made of the parts not omitted or emitted by FROB."
#:base-string-p #:strings-common-element-type #:reduce/strcat #:strcat ;; strings
#:first-char #:last-char #:split-string #:stripln #:+cr+ #:+lf+ #:+crlf+
#:string-prefix-p #:string-enclosed-p #:string-suffix-p
- #:find-class* ;; CLOS
+ #:coerce-class ;; CLOS
#:stamp< #:stamps< #:stamp*< #:stamp<= ;; stamps
#:earlier-stamp #:stamps-earliest #:earliest-stamp
#:later-stamp #:stamps-latest #:latest-stamp #:latest-stamp-f
@@ -1098,6 +1064,9 @@ Return a string made of the parts not omitted or emitted by FROB."
(defun undefine-function (function-spec)
(cond
((symbolp function-spec)
+ ;; undefining the previous function is the portable way
+ ;; of overriding any incompatible previous gf,
+ ;; but CLISP needs extra help with getting rid of previous methods.
#+clisp
(let ((f (and (fboundp function-spec) (fdefinition function-spec))))
(when (typep f 'clos:standard-generic-function)
@@ -1106,7 +1075,7 @@ Return a string made of the parts not omitted or emitted by FROB."
(fmakunbound function-spec))
((and (consp function-spec) (eq (car function-spec) 'setf)
(consp (cdr function-spec)) (null (cddr function-spec)))
- #-gcl2.6 (fmakunbound function-spec))
+ (fmakunbound function-spec))
(t (error "bad function spec ~S" function-spec))))
(defun undefine-functions (function-spec-list)
(map () 'undefine-function function-spec-list))
@@ -1119,29 +1088,28 @@ Return a string made of the parts not omitted or emitted by FROB."
name)
(declare (ignorable supersede))
`(progn
- ;; undefining the previous function is the portable way
- ;; of overriding any incompatible previous gf, except on CLISP.
;; We usually try to do it only for the functions that need it,
- ;; which happens in asdf/upgrade - however, for ECL, we need this hammer
- ;; (which causes issues in clisp)
- ,@(when (or #-clisp supersede #+(or ecl gcl2.7) t)
+ ;; which happens in asdf/upgrade - however, for ECL, we need this hammer.
+ ,@(when (or supersede #+ecl t)
`((undefine-function ',name)))
- #-gcl ; gcl 2.7.0 notinline functions lose secondary return values :-(
,@(when (and #+ecl (symbolp name)) ; fails for setf functions on ecl
`((declaim (notinline ,name))))
(,',def ,name ,formals , at rest))))))
(defdef defgeneric* defgeneric)
(defdef defun* defun))
(defmacro with-upgradability ((&optional) &body body)
+ "Evaluate BODY at compile- load- and run- times, with DEFUN and DEFGENERIC modified
+to also declare the functions NOTINLINE and to accept a wrapping the function name
+specification into a list with keyword argument SUPERSEDE (which defaults to T if the name
+is not wrapped, and NIL if it is wrapped). If SUPERSEDE is true, call UNDEFINE-FUNCTION
+to supersede any previous definition."
`(eval-when (:compile-toplevel :load-toplevel :execute)
,@(loop :for form :in body :collect
(if (consp form)
(destructuring-bind (car . cdr) form
(case car
((defun) `(defun* , at cdr))
- ((defgeneric)
- (unless (or #+gcl2.6 (and (consp (car cdr)) (eq 'setf (caar cdr))))
- `(defgeneric* , at cdr)))
+ ((defgeneric) `(defgeneric* , at cdr))
(otherwise form)))
form)))))
@@ -1167,9 +1135,13 @@ Return a string made of the parts not omitted or emitted by FROB."
(if file (load file)
(error "Failed to locate debug utility file: ~S" utility-file)))))))
-
;;; Flow control
(with-upgradability ()
+ (defmacro nest (&rest things)
+ "Macro to do keep code nesting and indentation under control." ;; Thanks to mbaringer
+ (reduce #'(lambda (outer inner) `(, at outer ,inner))
+ things :from-end t))
+
(defmacro if-let (bindings &body (then-form &optional else-form)) ;; from alexandria
;; bindings can be (var form) or ((var1 form1) ...)
(let* ((binding-list (if (and (consp bindings) (symbolp (car bindings)))
@@ -1242,6 +1214,7 @@ Returns two values: \(A B C\) and \(1 2 3\)."
;;; Characters
(with-upgradability () ;; base-char != character on ECL, LW, SBCL, Genera. LW also has SIMPLE-CHAR.
(defconstant +non-base-chars-exist-p+ (not (subtypep 'character 'base-char)))
+ #-scl ;; In SCL, all characters seem to be 16-bit base-char, but this flag gets set somehow???
(when +non-base-chars-exist-p+ (pushnew :non-base-chars-exist-p *features*)))
(with-upgradability ()
@@ -1294,7 +1267,8 @@ Returns two values: \(A B C\) and \(1 2 3\)."
NIL is interpreted as an empty string. A character is interpreted as a string of length one."
(when (or start end) (setf strings (subseq strings start end)))
(when key (setf strings (mapcar key strings)))
- (loop :with output = (make-string (loop :for s :in strings :sum (if (characterp s) 1 (length s)))
+ (loop :with output = (make-string (loop :for s :in strings
+ :sum (if (characterp s) 1 (length s)))
:element-type (strings-common-element-type strings))
:with pos = 0
:for input :in strings
@@ -1375,15 +1349,6 @@ the two results passed to STRCAT always reconstitute the original string"
(when x (c +crlf+) (c +lf+) (c +cr+) (values x nil)))))
-;;; CLOS
-(with-upgradability ()
- (defun find-class* (x &optional (errorp t) environment)
- (etypecase x
- ((or standard-class built-in-class) x)
- #+gcl2.6 (keyword nil)
- (symbol (find-class x errorp environment)))))
-
-
;;; stamps: a REAL or a boolean where NIL=-infinity, T=+infinity
(eval-when (#-lispworks :compile-toplevel :load-toplevel :execute)
(deftype stamp () '(or real boolean)))
@@ -1425,7 +1390,8 @@ and EVAL that in a (FUNCTION ...) context."
(etypecase fun
(function fun)
((or boolean keyword character number pathname) (constantly fun))
- (symbol fun)
+ (hash-table (lambda (x) (gethash x fun)))
+ (symbol (fdefinition fun))
(cons (if (eq 'lambda (car fun))
(eval fun)
#'(lambda (&rest args) (apply (car fun) (append (cdr fun) args)))))
@@ -1481,16 +1447,49 @@ When CALL-NOW-P is true, also call the function immediately."
(when call-now-p (call-function hook))))
+;;; CLOS
+(with-upgradability ()
+ (defun coerce-class (class &key (package :cl) (super t) (error 'error))
+ "Coerce CLASS to a class that is subclass of SUPER if specified,
+or invoke ERROR handler as per CALL-FUNCTION.
+
+A keyword designates the name a symbol, which when found in either PACKAGE, designates a class.
+-- for backward compatibility, *PACKAGE* is also accepted for now, but this may go in the future.
+A string is read as a symbol while in PACKAGE, the symbol designates a class.
+
+A class object designates itself.
+NIL designates itself (no class).
+A symbol otherwise designates a class by name."
+ (let* ((normalized
+ (typecase class
+ (keyword (or (find-symbol* class package nil)
+ (find-symbol* class *package* nil)))
+ (string (symbol-call :uiop :safe-read-from-string class :package package))
+ (t class)))
+ (found
+ (etypecase normalized
+ ((or standard-class built-in-class) normalized)
+ ((or null keyword) nil)
+ (symbol (find-class normalized nil nil)))))
+ (or (and found
+ (or (eq super t) (#-cormanlisp subtypep #+cormanlisp cl::subclassp found super))
+ found)
+ (call-function error "Can't coerce ~S to a ~@[class~;subclass of ~:*~S]" class super)))))
+
+
;;; Hash-tables
(with-upgradability ()
(defun ensure-gethash (key table default)
- "Lookup the TABLE for a KEY as by gethash, but if not present,
+ "Lookup the TABLE for a KEY as by GETHASH, but if not present,
call the (possibly constant) function designated by DEFAULT as per CALL-FUNCTION,
-set the corresponding entry to the result in the table, and return that result."
+set the corresponding entry to the result in the table.
+Return two values: the entry after its optional computation, and whether it was found"
(multiple-value-bind (value foundp) (gethash key table)
- (if foundp
- value
- (setf (gethash key table) (values (call-function default))))))
+ (values
+ (if foundp
+ value
+ (setf (gethash key table) (call-function default)))
+ foundp)))
(defun list-to-hash-set (list &aux (h (make-hash-table :test 'equal)))
"Convert a LIST into hash-table that has the same elements when viewed as a set,
@@ -1567,10 +1566,10 @@ with later being determined by a lexicographical comparison of minor numbers."
#+clisp 'system::$format-control
#+clozure 'ccl::format-control
#+(or cmu scl) 'conditions::format-control
- #+ecl 'si::format-control
+ #+(or ecl mkcl) 'si::format-control
#+(or gcl lispworks) 'conditions::format-string
#+sbcl 'sb-kernel:format-control
- #-(or abcl allegro clisp clozure cmu ecl gcl lispworks sbcl scl) nil
+ #-(or abcl allegro clisp clozure cmu ecl gcl lispworks mkcl sbcl scl) nil
"Name of the slot for FORMAT-CONTROL in simple-condition")
(defun match-condition-p (x condition)
@@ -1600,6 +1599,7 @@ or a string describing the format-control of a simple-condition."
(funcall thunk)))
(defmacro with-muffled-conditions ((conditions) &body body)
+ "Shorthand syntax for CALL-WITH-MUFFLED-CONDITIONS"
`(call-with-muffled-conditions #'(lambda () , at body) ,conditions)))
;;;; ---------------------------------------------------------------------------
@@ -1653,7 +1653,7 @@ keywords explicitly."
(defun os-windows-p ()
"Is the underlying operating system Microsoft Windows?"
(or #+abcl (featurep :windows)
- #+(and (not (or abcl unix cygwin darwin)) (or win32 windows mswindows mingw32)) t))
+ #+(and (not (or abcl unix cygwin darwin)) (or win32 windows mswindows mingw32 mingw64)) t))
(defun os-genera-p ()
"Is the underlying operating system Genera (running on a Symbolics Lisp Machine)?"
@@ -1667,10 +1667,11 @@ keywords explicitly."
"Detects the current operating system. Only needs be run at compile-time,
except on ABCL where it might change between FASL compilation and runtime."
(loop* :with o
- :for (feature . detect) :in '((:os-unix . os-unix-p) (:os-windows . os-windows-p)
- (:os-macosx . os-macosx-p)
+ :for (feature . detect) :in '((:os-unix . os-unix-p) (:os-macosx . os-macosx-p)
+ (:os-windows . os-windows-p)
(:genera . os-genera-p) (:os-oldmac . os-oldmac-p))
- :when (and (not o) (funcall detect)) :do (setf o feature) (pushnew o *features*)
+ :when (and (or (not o) (eq feature :os-macosx)) (funcall detect))
+ :do (setf o feature) (pushnew feature *features*)
:else :do (setf *features* (remove feature *features*))
:finally
(return (or o (error "Congratulations for trying ASDF on an operating system~%~
@@ -1850,8 +1851,9 @@ suitable for use as a directory name to segregate Lisp FASLs, C dynamic librarie
(defun getcwd ()
"Get the current working directory as per POSIX getcwd(3), as a pathname object"
- (or #+abcl (parse-namestring
- (java:jstatic "getProperty" "java.lang.System" "user.dir") :ensure-directory t)
+ (or #+abcl (truename (symbol-call :asdf/filesystem :parse-native-namestring
+ (java:jstatic "getProperty" "java.lang.System" "user.dir")
+ :ensure-directory t))
#+allegro (excl::current-directory)
#+clisp (ext:default-directory)
#+clozure (ccl:current-directory)
@@ -1859,8 +1861,7 @@ suitable for use as a directory name to segregate Lisp FASLs, C dynamic librarie
(strcat (nth-value 1 (unix:unix-current-directory)) "/"))
#+cormanlisp (pathname (pl::get-current-directory)) ;; Q: what type does it return?
#+ecl (ext:getcwd)
- #+gcl (parse-namestring ;; this is a joke. Isn't there a better way?
- (first (symbol-call :uiop :run-program '("/bin/pwd") :output :lines)))
+ #+gcl (let ((*default-pathname-defaults* #p"")) (truename #p""))
#+genera *default-pathname-defaults* ;; on a Lisp OS, it *is* canonical!
#+lispworks (system:current-directory)
#+mkcl (mk-ext:getcwd)
@@ -1882,7 +1883,7 @@ suitable for use as a directory name to segregate Lisp FASLs, C dynamic librarie
#+genera (setf *default-pathname-defaults* x)
#+lispworks (hcl:change-directory x)
#+mkcl (mk-ext:chdir x)
- #+sbcl (symbol-call :sb-posix :chdir (sb-ext:native-namestring x))
+ #+sbcl (progn (require :sb-posix) (symbol-call :sb-posix :chdir (sb-ext:native-namestring x)))
(error "chdir not supported on your implementation")))))
@@ -2018,33 +2019,22 @@ the number having BYTES octets (defaulting to 4)."
"Convert the DIRECTORY component from a format usable by the underlying
implementation's MAKE-PATHNAME and other primitives to a CLHS-standard format
that is a list and not a string."
- #+gcl2.6 (setf directory (substitute :back :parent directory))
(cond
#-(or cmu sbcl scl) ;; these implementations already normalize directory components.
((stringp directory) `(:absolute ,directory))
- #+gcl2.6
- ((and (consp directory) (eq :root (first directory)))
- `(:absolute ,@(rest directory)))
((or (null directory)
(and (consp directory) (member (first directory) '(:absolute :relative))))
directory)
- #+gcl2.6
+ #+gcl
((consp directory)
- `(:relative , at directory))
+ (cons :relative directory))
(t
(error (compatfmt "~@<Unrecognized pathname directory component ~S~@:>") directory))))
(defun denormalize-pathname-directory-component (directory-component)
"Convert the DIRECTORY-COMPONENT from a CLHS-standard format to a format usable
by the underlying implementation's MAKE-PATHNAME and other primitives"
- #-gcl2.6 directory-component
- #+gcl2.6
- (let ((d (substitute-if :parent (lambda (x) (member x '(:up :back)))
- directory-component)))
- (cond
- ((and (consp d) (eq :relative (first d))) (rest d))
- ((and (consp d) (eq :absolute (first d))) `(:root ,@(rest d)))
- (t d))))
+ directory-component)
(defun merge-pathname-directory-components (specified defaults)
"Helper for MERGE-PATHNAMES* that handles directory components"
@@ -2073,11 +2063,11 @@ by the underlying implementation's MAKE-PATHNAME and other primitives"
;; See CLHS make-pathname and 19.2.2.2.3.
;; This will be :unspecific if supported, or NIL if not.
(defparameter *unspecific-pathname-type*
- #+(or abcl allegro clozure cmu gcl genera lispworks mkcl sbcl scl xcl) :unspecific
- #+(or clisp ecl #|These haven't been tested:|# cormanlisp mcl) nil
+ #+(or abcl allegro clozure cmu genera lispworks sbcl scl) :unspecific
+ #+(or clisp ecl mkcl gcl xcl #|These haven't been tested:|# cormanlisp mcl) nil
"Unspecific type component to use with the underlying implementation's MAKE-PATHNAME")
- (defun make-pathname* (&rest keys &key (directory nil #+gcl2.6 directoryp)
+ (defun make-pathname* (&rest keys &key (directory nil)
host (device () #+allegro devicep) name type version defaults
#+scl &allow-other-keys)
"Takes arguments like CL:MAKE-PATHNAME in the CLHS, and
@@ -2088,9 +2078,6 @@ by the underlying implementation's MAKE-PATHNAME and other primitives"
(apply 'make-pathname
(append
#+allegro (when (and devicep (null device)) `(:device :unspecific))
- #+gcl2.6
- (when directoryp
- `(:directory ,(denormalize-pathname-directory-component directory)))
keys)))
(defun make-pathname-component-logical (x)
@@ -2175,8 +2162,9 @@ when merging, making or parsing pathnames"
;; But CMUCL decides to die on NIL.
;; MCL has issues with make-pathname, nil and defaulting
(declare (ignorable defaults))
- #.`(make-pathname* :directory nil :name nil :type nil :version nil :device nil
- :host (or #+cmu lisp::*unix-host*)
+ #.`(make-pathname* :directory nil :name nil :type nil :version nil
+ :device (or #+(and mkcl unix) :unspecific)
+ :host (or #+cmu lisp::*unix-host* #+(and mkcl unix) "localhost")
#+scl ,@'(:scheme nil :scheme-specific-part nil
:username nil :password nil :parameters nil :query nil :fragment nil)
;; the default shouldn't matter, but we really want something physical
@@ -2209,11 +2197,11 @@ when merging, making or parsing pathnames"
(or (and (null p1) (null p2))
(and (pathnamep p1) (pathnamep p2)
(and (=? pathname-host)
- (=? pathname-device)
+ #-(and mkcl unix) (=? pathname-device)
(=? normalize-pathname-directory-component pathname-directory)
(=? pathname-name)
(=? pathname-type)
- (=? pathname-version)))))))
+ #-mkcl (=? pathname-version)))))))
(defun absolute-pathname-p (pathspec)
"If PATHSPEC is a pathname or namestring object that parses as a pathname
@@ -2287,9 +2275,12 @@ ways that the filename components can be missing are for it to be NIL,
Note that this does _not_ check to see that PATHNAME points to an
actually-existing directory."
(when pathname
+ ;; I tried using Allegro's excl:file-directory-p, but this cannot be done,
+ ;; because it rejects apparently legal pathnames as
+ ;; ill-formed. [2014/02/10:rpg]
(let ((pathname (pathname pathname)))
(flet ((check-one (x)
- (member x '(nil :unspecific "") :test 'equal)))
+ (member x '(nil :unspecific) :test 'equal)))
(and (not (wild-pathname-p pathname))
(check-one (pathname-name pathname))
(check-one (pathname-type pathname))
@@ -2465,13 +2456,14 @@ or if it is a PATHNAME but some of its components are not recognized."
((or null string) pathname)
(pathname
(with-output-to-string (s)
- (flet ((err () (error "Not a valid unix-namestring ~S" pathname)))
+ (flet ((err () #+lispworks (describe pathname) (error "Not a valid unix-namestring ~S" pathname)))
(let* ((dir (normalize-pathname-directory-component (pathname-directory pathname)))
(name (pathname-name pathname))
+ (name (and (not (eq name :unspecific)) name))
(type (pathname-type pathname))
(type (and (not (eq type :unspecific)) type)))
(cond
- ((eq dir ()))
+ ((member dir '(nil :unspecific)))
((eq dir '(:relative)) (princ "./" s))
((consp dir)
(destructuring-bind (relabs &rest dirs) dir
@@ -2487,7 +2479,7 @@ or if it is a PATHNAME but some of its components are not recognized."
(t (err)))
(cond
(name
- (or (and (stringp name) (or (null type) (stringp type))) (err))
+ (unless (and (stringp name) (or (null type) (stringp type))) (err))
(format s "~A~@[.~A~]" name type))
(t
(or (null type) (err)))))))))))
@@ -2526,6 +2518,25 @@ then it is merged with the PATHNAME-DIRECTORY-PATHNAME of PATHNAME."
;; scheme-specific parts: port username password, not others:
. #.(or #+scl '(:parameters nil :query nil :fragment nil))))
+ (defun ensure-absolute-pathname (path &optional defaults (on-error 'error))
+ "Given a pathname designator PATH, return an absolute pathname as specified by PATH
+considering the DEFAULTS, or, if not possible, use CALL-FUNCTION on the specified ON-ERROR behavior,
+with a format control-string and other arguments as arguments"
+ (cond
+ ((absolute-pathname-p path))
+ ((stringp path) (ensure-absolute-pathname (pathname path) defaults on-error))
+ ((not (pathnamep path)) (call-function on-error "not a valid pathname designator ~S" path))
+ ((let ((default-pathname (if (pathnamep defaults) defaults (call-function defaults))))
+ (or (if (absolute-pathname-p default-pathname)
+ (absolute-pathname-p (merge-pathnames* path default-pathname))
+ (call-function on-error "Default pathname ~S is not an absolute pathname"
+ default-pathname))
+ (call-function on-error "Failed to merge ~S with ~S into an absolute pathname"
+ path default-pathname))))
+ (t (call-function on-error
+ "Cannot ensure ~S is evaluated as an absolute pathname with defaults ~S"
+ path defaults))))
+
(defun subpathp (maybe-subpath base-pathname)
"if MAYBE-SUBPATH is a pathname that is under BASE-PATHNAME, return a pathname object that
when used with MERGE-PATHNAMES* with defaults BASE-PATHNAME, returns MAYBE-SUBPATH."
@@ -2540,11 +2551,9 @@ when used with MERGE-PATHNAMES* with defaults BASE-PATHNAME, returns MAYBE-SUBPA
(defun enough-pathname (maybe-subpath base-pathname)
"if MAYBE-SUBPATH is a pathname that is under BASE-PATHNAME, return a pathname object that
when used with MERGE-PATHNAMES* with defaults BASE-PATHNAME, returns MAYBE-SUBPATH."
- (check-type maybe-subpath (or null pathname))
- (check-type base-pathname (or null pathname))
- (when (pathnamep base-pathname) (assert (absolute-pathname-p base-pathname)))
- (or (and base-pathname (subpathp maybe-subpath base-pathname))
- maybe-subpath))
+ (let ((sub (when maybe-subpath (pathname maybe-subpath)))
+ (base (when base-pathname (ensure-absolute-pathname (pathname base-pathname)))))
+ (or (and base (subpathp sub base)) sub)))
(defun call-with-enough-pathname (maybe-subpath defaults-pathname thunk)
"In a context where *DEFAULT-PATHNAME-DEFAULTS* is bound to DEFAULTS-PATHNAME (if not null,
@@ -2558,35 +2567,16 @@ given DEFAULTS-PATHNAME as a base pathname."
(defaults *default-pathname-defaults*))
&body body)
"Shorthand syntax for CALL-WITH-ENOUGH-PATHNAME"
- `(call-with-enough-pathname ,pathname ,defaults #'(lambda (,pathname-var) , at body)))
-
- (defun ensure-absolute-pathname (path &optional defaults (on-error 'error))
- "Given a pathname designator PATH, return an absolute pathname as specified by PATH
-considering the DEFAULTS, or, if not possible, use CALL-FUNCTION on the specified ON-ERROR behavior,
-with a format control-string and other arguments as arguments"
- (cond
- ((absolute-pathname-p path))
- ((stringp path) (ensure-absolute-pathname (pathname path) defaults on-error))
- ((not (pathnamep path)) (call-function on-error "not a valid pathname designator ~S" path))
- ((let ((default-pathname (if (pathnamep defaults) defaults (call-function defaults))))
- (or (if (absolute-pathname-p default-pathname)
- (absolute-pathname-p (merge-pathnames* path default-pathname))
- (call-function on-error "Default pathname ~S is not an absolute pathname"
- default-pathname))
- (call-function on-error "Failed to merge ~S with ~S into an absolute pathname"
- path default-pathname))))
- (t (call-function on-error
- "Cannot ensure ~S is evaluated as an absolute pathname with defaults ~S"
- path defaults)))))
+ `(call-with-enough-pathname ,pathname ,defaults #'(lambda (,pathname-var) , at body))))
;;; Wildcard pathnames
(with-upgradability ()
(defparameter *wild* (or #+cormanlisp "*" :wild)
"Wild component for use with MAKE-PATHNAME")
- (defparameter *wild-directory-component* (or #+gcl2.6 "*" :wild)
+ (defparameter *wild-directory-component* (or :wild)
"Wild directory component for use with MAKE-PATHNAME")
- (defparameter *wild-inferiors-component* (or #+gcl2.6 "**" :wild-inferiors)
+ (defparameter *wild-inferiors-component* (or :wild-inferiors)
"Wild-inferiors directory component for use with MAKE-PATHNAME")
(defparameter *wild-file*
(make-pathname :directory nil :name *wild* :type *wild*
@@ -2811,32 +2801,27 @@ or the original (parsed) pathname if it is false (the default)."
(or
#+allegro
(probe-file p :follow-symlinks truename)
- #-(or allegro clisp gcl2.6)
+ #+gcl
(if truename
- (probe-file p)
- (ignore-errors
- (let ((pp (physicalize-pathname p)))
- (and
- #+(or cmu scl) (unix:unix-stat (ext:unix-namestring pp))
- #+(and lispworks unix) (system:get-file-stat pp)
- #+sbcl (sb-unix:unix-stat (sb-ext:native-namestring pp))
- #-(or cmu (and lispworks unix) sbcl scl) (file-write-date pp)
- p))))
- #+(or clisp gcl2.6)
+ (truename* p)
+ (let ((kind (car (si::stat p))))
+ (when (eq kind :link)
+ (setf kind (ignore-errors (car (si::stat (truename* p))))))
+ (ecase kind
+ ((nil) nil)
+ ((:file :link)
+ (cond
+ ((file-pathname-p p) p)
+ ((directory-pathname-p p)
+ (subpathname p (car (last (pathname-directory p)))))))
+ (:directory (ensure-directory-pathname p)))))
+ #+clisp
#.(flet ((probe (probe)
`(let ((foundtrue ,probe))
(cond
(truename foundtrue)
(foundtrue p)))))
- #+gcl2.6
- (probe '(or (probe-file p)
- (and (directory-pathname-p p)
- (ignore-errors
- (ensure-directory-pathname
- (truename* (subpathname
- (ensure-directory-pathname p) ".")))))))
- #+clisp
- (let* ((fs (find-symbol* '#:file-stat :posix nil))
+ (let* ((fs (or #-os-windows (find-symbol* '#:file-stat :posix nil)))
(pp (find-symbol* '#:probe-pathname :ext nil))
(resolve (if pp
`(ignore-errors (,pp p))
@@ -2846,11 +2831,29 @@ or the original (parsed) pathname if it is false (the default)."
`(if truename
,resolve
(and (ignore-errors (,fs p)) p))
- (probe resolve)))))
+ (probe resolve))))
+ #-(or allegro clisp gcl)
+ (if truename
+ (probe-file p)
+ (ignore-errors
+ (let ((pp (physicalize-pathname p)))
+ (and
+ #+(or cmu scl) (unix:unix-stat (ext:unix-namestring pp))
+ #+(and lispworks unix) (system:get-file-stat pp)
+ #+sbcl (sb-unix:unix-stat (sb-ext:native-namestring pp))
+ #-(or cmu (and lispworks unix) sbcl scl) (file-write-date pp)
+ p)))))
(file-error () nil)))))))
(defun directory-exists-p (x)
"Is X the name of a directory that exists on the filesystem?"
+ #+allegro
+ (excl:probe-directory x)
+ #+clisp
+ (handler-case (ext:probe-directory x)
+ (sys::simple-file-error ()
+ nil))
+ #-(or allegro clisp)
(let ((p (probe-file* x :truename t)))
(and (directory-pathname-p p) p)))
@@ -2875,26 +2878,33 @@ Try to override the defaults to not resolving symlinks, if implementation allows
"Given ENTRIES in a DIRECTORY, remove if the directory is logical
the entries which are physical yet when transformed by MERGER have a different TRUENAME.
This function is used as a helper to DIRECTORY-FILES to avoid invalid entries when using logical-pathnames."
- (if (logical-pathname-p directory)
- ;; Try hard to not resolve logical-pathname into physical pathnames;
- ;; otherwise logical-pathname users/lovers will be disappointed.
- ;; If directory* could use some implementation-dependent magic,
- ;; we will have logical pathnames already; otherwise,
- ;; we only keep pathnames for which specifying the name and
- ;; translating the LPN commute.
- (loop :for f :in entries
- :for p = (or (and (logical-pathname-p f) f)
- (let* ((u (ignore-errors (call-function merger f))))
- ;; The first u avoids a cumbersome (truename u) error.
- ;; At this point f should already be a truename,
- ;; but isn't quite in CLISP, for it doesn't have :version :newest
- (and u (equal (truename* u) (truename* f)) u)))
- :when p :collect p)
- entries))
+ (remove-duplicates ;; on CLISP, querying ~/ will return duplicates
+ (if (logical-pathname-p directory)
+ ;; Try hard to not resolve logical-pathname into physical pathnames;
+ ;; otherwise logical-pathname users/lovers will be disappointed.
+ ;; If directory* could use some implementation-dependent magic,
+ ;; we will have logical pathnames already; otherwise,
+ ;; we only keep pathnames for which specifying the name and
+ ;; translating the LPN commute.
+ (loop :for f :in entries
+ :for p = (or (and (logical-pathname-p f) f)
+ (let* ((u (ignore-errors (call-function merger f))))
+ ;; The first u avoids a cumbersome (truename u) error.
+ ;; At this point f should already be a truename,
+ ;; but isn't quite in CLISP, for it doesn't have :version :newest
+ (and u (equal (truename* u) (truename* f)) u)))
+ :when p :collect p)
+ entries)
+ :test 'pathname-equal))
+
(defun directory-files (directory &optional (pattern *wild-file*))
- "Return a list of the files in a directory according to the PATTERN,
-which is not very portable to override. Try not resolve symlinks if implementation allows."
+ "Return a list of the files in a directory according to the PATTERN.
+Subdirectories should NOT be returned.
+ PATTERN defaults to a pattern carefully chosen based on the implementation;
+override the default at your own risk.
+ DIRECTORY-FILES tries NOT to resolve symlinks if the implementation
+permits this."
(let ((dir (pathname directory)))
(when (logical-pathname-p dir)
;; Because of the filtering we do below,
@@ -2907,16 +2917,17 @@ which is not very portable to override. Try not resolve symlinks if implementati
(setf pattern (make-pathname-logical pattern (pathname-host dir))))
(let* ((pat (merge-pathnames* pattern dir))
(entries (append (ignore-errors (directory* pat))
- #+clisp
+ #+(or clisp gcl)
(when (equal :wild (pathname-type pattern))
(ignore-errors (directory* (make-pathname :type nil :defaults pat)))))))
- (filter-logical-directory-results
- directory entries
- #'(lambda (f)
- (make-pathname :defaults dir
- :name (make-pathname-component-logical (pathname-name f))
- :type (make-pathname-component-logical (pathname-type f))
- :version (make-pathname-component-logical (pathname-version f))))))))
+ (remove-if 'directory-pathname-p
+ (filter-logical-directory-results
+ directory entries
+ #'(lambda (f)
+ (make-pathname :defaults dir
+ :name (make-pathname-component-logical (pathname-name f))
+ :type (make-pathname-component-logical (pathname-type f))
+ :version (make-pathname-component-logical (pathname-version f)))))))))
(defun subdirectories (directory)
"Given a DIRECTORY pathname designator, return a list of the subdirectories under it."
@@ -2984,13 +2995,19 @@ and recurse each of its subdirectories on which the RECURSEP returns true when C
(down-components ()))
(assert (eq :absolute (first directory)))
(loop :while up-components :do
- (if-let (parent (probe-file* (make-pathname* :directory `(:absolute ,@(reverse up-components))
- :name nil :type nil :version nil :defaults p)))
- (return (merge-pathnames* (make-pathname* :directory `(:relative , at down-components)
- :defaults p)
- (ensure-directory-pathname parent)))
- (push (pop up-components) down-components))
- :finally (return p))))))
+ (if-let (parent
+ (ignore-errors
+ (probe-file* (make-pathname* :directory `(:absolute ,@(reverse up-components))
+ :name nil :type nil :version nil :defaults p))))
+ (if-let (simplified
+ (ignore-errors
+ (merge-pathnames*
+ (make-pathname* :directory `(:relative , at down-components)
+ :defaults p)
+ (ensure-directory-pathname parent))))
+ (return simplified)))
+ (push (pop up-components) down-components)
+ :finally (return p))))))
(defun resolve-symlinks (path)
"Do a best effort at resolving symlinks in PATH, returning a partially or totally resolved PATH."
@@ -3016,7 +3033,7 @@ Defaults to T.")
(defun ensure-pathname
(pathname &key
on-error
- defaults type dot-dot
+ defaults type dot-dot namestring
want-pathname
want-logical want-physical ensure-physical
want-relative want-absolute ensure-absolute ensure-subpath
@@ -3030,10 +3047,17 @@ optionally doing some transformations and checking specified constraints.
If the argument is NIL, then NIL is returned unless the WANT-PATHNAME constraint is specified.
-If the argument is a STRING, it is first converted to a pathname via PARSE-UNIX-NAMESTRING
-reusing the keywords DEFAULTS TYPE DOT-DOT ENSURE-DIRECTORY WANT-RELATIVE;
-then the result is optionally merged into the DEFAULTS if ENSURE-ABSOLUTE is true,
-and the all the checks and transformations are run.
+If the argument is a STRING, it is first converted to a pathname via
+PARSE-UNIX-NAMESTRING, PARSE-NAMESTRING or PARSE-NATIVE-NAMESTRING respectively
+depending on the NAMESTRING argument being :UNIX, :LISP or :NATIVE respectively,
+or else by using CALL-FUNCTION on the NAMESTRING argument;
+if :UNIX is specified (or NIL, the default, which specifies the same thing),
+then PARSE-UNIX-NAMESTRING it is called with the keywords
+DEFAULTS TYPE DOT-DOT ENSURE-DIRECTORY WANT-RELATIVE, and
+the result is optionally merged into the DEFAULTS if ENSURE-ABSOLUTE is true.
+
+The pathname passed or resulting from parsing the string
+is then subjected to all the checks and transformations below are run.
Each non-nil constraint argument can be one of the symbols T, ERROR, CERROR or IGNORE.
The boolean T is an alias for ERROR.
@@ -3092,11 +3116,22 @@ TRUENAMIZE uses TRUENAMIZE to resolve as many symlinks as possible."
(etypecase p
((or null pathname))
(string
- (setf p (parse-unix-namestring
- p :defaults defaults :type type :dot-dot dot-dot
- :ensure-directory ensure-directory :want-relative want-relative))))
- (check want-pathname (pathnamep p) "Expected a pathname, not NIL")
- (unless (pathnamep p) (return nil))
+ (setf p (case namestring
+ ((:unix nil)
+ (parse-unix-namestring
+ p :defaults defaults :type type :dot-dot dot-dot
+ :ensure-directory ensure-directory :want-relative want-relative))
+ ((:native)
+ (parse-native-namestring p))
+ ((:lisp)
+ (parse-namestring p))
+ (t
+ (call-function namestring p))))))
+ (etypecase p
+ (pathname)
+ (null
+ (check want-pathname (pathnamep p) "Expected a pathname, not NIL")
+ (return nil)))
(check want-logical (logical-pathname-p p) "Expected a logical pathname")
(check want-physical (physical-pathname-p p) "Expected a physical pathname")
(transform ensure-physical () (physicalize-pathname p))
@@ -3241,7 +3276,7 @@ in an atomic way if the implementation allows."
(symbol-call :posix :copy-file source target :method :rename))
#-clisp
(rename-file source target
- #+clozure :if-exists #+clozure :rename-and-delete))
+ #+(or clozure ecl) :if-exists #+clozure :rename-and-delete #+ecl t))
(defun delete-file-if-exists (x)
"Delete a file X if it already exists"
@@ -3268,7 +3303,7 @@ in an atomic way if the implementation allows."
`(,dd directory-pathname) ;; requires SBCL 1.0.44 or later
`(progn (require :sb-posix) (symbol-call :sb-posix :rmdir directory-pathname)))
#+xcl (symbol-call :uiop :run-program `("rmdir" ,(native-namestring directory-pathname)))
- #-(or abcl allegro clisp clozure cmu cormanlisp digitool ecl gcl lispworks sbcl scl xcl)
+ #-(or abcl allegro clisp clozure cmu cormanlisp digitool ecl gcl lispworks mkcl sbcl scl xcl)
(error "~S not implemented on ~S" 'delete-empty-directory (implementation-type))) ; genera
(defun delete-directory-tree (directory-pathname &key (validate nil validatep) (if-does-not-exist :error))
@@ -3491,15 +3526,38 @@ It must never be modified, though only good implementations will even enforce th
(with-safe-io-syntax (:package package)
(read-from-string string eof-error-p eof-value :start start :end end :preserve-whitespace preserve-whitespace))))
-;;; Output to a stream or string, FORMAT-style
+;;; Output helpers
(with-upgradability ()
- (defun call-with-output (output function)
+ (defun call-with-output-file (pathname thunk
+ &key
+ (element-type *default-stream-element-type*)
+ (external-format *utf-8-external-format*)
+ (if-exists :error)
+ (if-does-not-exist :create))
+ "Open FILE for input with given recognizes options, call THUNK with the resulting stream.
+Other keys are accepted but discarded."
+ (with-open-file (s pathname :direction :output
+ :element-type element-type
+ :external-format external-format
+ :if-exists if-exists
+ :if-does-not-exist if-does-not-exist)
+ (funcall thunk s)))
+
+ (defmacro with-output-file ((var pathname &rest keys
+ &key element-type external-format if-exists if-does-not-exist)
+ &body body)
+ (declare (ignore element-type external-format if-exists if-does-not-exist))
+ `(call-with-output-file ,pathname #'(lambda (,var) , at body) , at keys))
+
+ (defun call-with-output (output function &key keys)
"Calls FUNCTION with an actual stream argument,
behaving like FORMAT with respect to how stream designators are interpreted:
-If OUTPUT is a stream, use it as the stream.
+If OUTPUT is a STREAM, use it as the stream.
If OUTPUT is NIL, use a STRING-OUTPUT-STREAM as the stream, and return the resulting string.
If OUTPUT is T, use *STANDARD-OUTPUT* as the stream.
-If OUTPUT is a string with a fill-pointer, use it as a string-output-stream.
+If OUTPUT is a STRING with a fill-pointer, use it as a string-output-stream.
+If OUTPUT is a PATHNAME, open the file and write to it, passing KEYS to WITH-OUTPUT-FILE
+-- this latter as an extension since ASDF 3.1.
Otherwise, signal an error."
(etypecase output
(null
@@ -3510,7 +3568,9 @@ Otherwise, signal an error."
(funcall function output))
(string
(assert (fill-pointer output))
- (with-output-to-string (stream output) (funcall function stream)))))
+ (with-output-to-string (stream output) (funcall function stream)))
+ (pathname
+ (apply 'call-with-output-file output function keys))))
(defmacro with-output ((output-var &optional (value output-var)) &body body)
"Bind OUTPUT-VAR to an output stream, coercing VALUE (default: previous binding of OUTPUT-VAR)
@@ -3526,25 +3586,6 @@ as per FORMAT, and evaluate BODY within the scope of this binding."
;;; Input helpers
(with-upgradability ()
- (defun call-with-input (input function)
- "Calls FUNCTION with an actual stream argument, interpreting
-stream designators like READ, but also coercing strings to STRING-INPUT-STREAM.
-If INPUT is a STREAM, use it as the stream.
-If INPUT is NIL, use a *STANDARD-INPUT* as the stream.
-If INPUT is T, use *TERMINAL-IO* as the stream.
-As an extension, if INPUT is a string, use it as a string-input-stream.
-Otherwise, signal an error."
- (etypecase input
- (null (funcall function *standard-input*))
- ((eql t) (funcall function *terminal-io*))
- (stream (funcall function input))
- (string (with-input-from-string (stream input) (funcall function stream)))))
-
- (defmacro with-input ((input-var &optional (value input-var)) &body body)
- "Bind INPUT-VAR to an input stream, coercing VALUE (default: previous binding of INPUT-VAR)
-as per CALL-WITH-INPUT, and evaluate BODY within the scope of this binding."
- `(call-with-input ,value #'(lambda (,input-var) , at body)))
-
(defun call-with-input-file (pathname thunk
&key
(element-type *default-stream-element-type*)
@@ -3552,10 +3593,9 @@ as per CALL-WITH-INPUT, and evaluate BODY within the scope of this binding."
(if-does-not-exist :error))
"Open FILE for input with given recognizes options, call THUNK with the resulting stream.
Other keys are accepted but discarded."
- #+gcl2.6 (declare (ignore external-format))
(with-open-file (s pathname :direction :input
:element-type element-type
- #-gcl2.6 :external-format #-gcl2.6 external-format
+ :external-format external-format
:if-does-not-exist if-does-not-exist)
(funcall thunk s)))
@@ -3565,27 +3605,29 @@ Other keys are accepted but discarded."
(declare (ignore element-type external-format if-does-not-exist))
`(call-with-input-file ,pathname #'(lambda (,var) , at body) , at keys))
- (defun call-with-output-file (pathname thunk
- &key
- (element-type *default-stream-element-type*)
- (external-format *utf-8-external-format*)
- (if-exists :error)
- (if-does-not-exist :create))
- "Open FILE for input with given recognizes options, call THUNK with the resulting stream.
-Other keys are accepted but discarded."
- #+gcl2.6 (declare (ignore external-format))
- (with-open-file (s pathname :direction :output
- :element-type element-type
- #-gcl2.6 :external-format #-gcl2.6 external-format
- :if-exists if-exists
- :if-does-not-exist if-does-not-exist)
- (funcall thunk s)))
+ (defun call-with-input (input function &key keys)
+ "Calls FUNCTION with an actual stream argument, interpreting
+stream designators like READ, but also coercing strings to STRING-INPUT-STREAM,
+and PATHNAME to FILE-STREAM.
+If INPUT is a STREAM, use it as the stream.
+If INPUT is NIL, use a *STANDARD-INPUT* as the stream.
+If INPUT is T, use *TERMINAL-IO* as the stream.
+If INPUT is a STRING, use it as a string-input-stream.
+If INPUT is a PATHNAME, open it, passing KEYS to WITH-INPUT-FILE
+-- the latter is an extension since ASDF 3.1.
+Otherwise, signal an error."
+ (etypecase input
+ (null (funcall function *standard-input*))
+ ((eql t) (funcall function *terminal-io*))
+ (stream (funcall function input))
+ (string (with-input-from-string (stream input) (funcall function stream)))
+ (pathname (apply 'call-with-input-file input function keys))))
+
+ (defmacro with-input ((input-var &optional (value input-var)) &body body)
+ "Bind INPUT-VAR to an input stream, coercing VALUE (default: previous binding of INPUT-VAR)
+as per CALL-WITH-INPUT, and evaluate BODY within the scope of this binding."
+ `(call-with-input ,value #'(lambda (,input-var) , at body))))
- (defmacro with-output-file ((var pathname &rest keys
- &key element-type external-format if-exists if-does-not-exist)
- &body body)
- (declare (ignore element-type external-format if-exists if-does-not-exist))
- `(call-with-output-file ,pathname #'(lambda (,var) , at body) , at keys)))
;;; Null device
(with-upgradability ()
@@ -3597,19 +3639,22 @@ and always returns EOF when read from"
((os-windows-p) #p"NUL") ;; Q: how many Lisps accept the #p"NUL:" syntax?
(t (error "No /dev/null on your OS"))))
(defun call-with-null-input (fun &rest keys &key element-type external-format if-does-not-exist)
+ "Call FUN with an input stream from the null device; pass keyword arguments to OPEN."
(declare (ignore element-type external-format if-does-not-exist))
(apply 'call-with-input-file (null-device-pathname) fun keys))
(defmacro with-null-input ((var &rest keys
&key element-type external-format if-does-not-exist)
&body body)
(declare (ignore element-type external-format if-does-not-exist))
- "Evaluate BODY in a context when VAR is bound to an input stream accessing the null device."
+ "Evaluate BODY in a context when VAR is bound to an input stream accessing the null device.
+Pass keyword arguments to OPEN."
`(call-with-null-input #'(lambda (,var) , at body) , at keys))
(defun call-with-null-output (fun
&key (element-type *default-stream-element-type*)
(external-format *utf-8-external-format*)
(if-exists :overwrite)
(if-does-not-exist :error))
+ "Call FUN with an output stream to the null device; pass keyword arguments to OPEN."
(call-with-output-file
(null-device-pathname) fun
:element-type element-type :external-format external-format
@@ -3617,7 +3662,8 @@ and always returns EOF when read from"
(defmacro with-null-output ((var &rest keys
&key element-type external-format if-does-not-exist if-exists)
&body body)
- "Evaluate BODY in a context when VAR is bound to an output stream accessing the null device."
+ "Evaluate BODY in a context when VAR is bound to an output stream accessing the null device.
+Pass keyword arguments to OPEN."
(declare (ignore element-type external-format if-exists if-does-not-exist))
`(call-with-null-output #'(lambda (,var) , at body) , at keys)))
@@ -3828,11 +3874,11 @@ If a string, repeatedly read and evaluate from it, returning the last values."
(with-upgradability ()
(defun println (x &optional (stream *standard-output*))
"Variant of PRINC that also calls TERPRI afterwards"
- (princ x stream) (terpri stream) (values))
+ (princ x stream) (terpri stream) (finish-output stream) (values))
(defun writeln (x &rest keys &key (stream *standard-output*) &allow-other-keys)
"Variant of WRITE that also calls TERPRI afterwards"
- (apply 'write x keys) (terpri stream) (values)))
+ (apply 'write x keys) (terpri stream) (finish-output stream) (values)))
;;; Using temporary files
@@ -3856,37 +3902,58 @@ If a string, repeatedly read and evaluate from it, returning the last values."
(defun setup-temporary-directory ()
"Configure a default temporary directory to use."
(setf *temporary-directory* (default-temporary-directory))
- ;; basic lack fixed after gcl 2.7.0-61, but ending / required still on 2.7.0-64.1
- #+(and gcl (not gcl2.6)) (setf system::*tmp-dir* *temporary-directory*))
+ #+gcl (setf system::*tmp-dir* *temporary-directory*))
(defun call-with-temporary-file
(thunk &key
- (want-stream-p t) (want-pathname-p t)
- prefix keep (direction :io)
+ (want-stream-p t) (want-pathname-p t) (direction :io) keep after
+ directory (type "tmp" typep) prefix (suffix (when typep "-tmp"))
(element-type *default-stream-element-type*)
(external-format *utf-8-external-format*))
- "Call a THUNK with STREAM and PATHNAME arguments identifying a temporary file.
-The pathname will be based on appending a random suffix to PREFIX.
-This utility will KEEP the file past its extent if and only if explicitly requested.
-The file will be open with specified DIRECTION, ELEMENT-TYPE and EXTERNAL-FORMAT."
- #+gcl2.6 (declare (ignorable external-format))
+ "Call a THUNK with stream and/or pathname arguments identifying a temporary file.
+
+The temporary file's pathname will be based on concatenating
+PREFIX (defaults to \"uiop\"), a random alphanumeric string,
+and optional SUFFIX (defaults to \"-tmp\" if a type was provided)
+and TYPE (defaults to \"tmp\", using a dot as separator if not NIL),
+within DIRECTORY (defaulting to the TEMPORARY-DIRECTORY) if the PREFIX isn't absolute.
+
+The file will be open with specified DIRECTION (defaults to :IO),
+ELEMENT-TYPE (defaults to *DEFAULT-STREAM-ELEMENT-TYPE*) and
+EXTERNAL-FORMAT (defaults to *UTF-8-EXTERNAL-FORMAT*).
+If WANT-STREAM-P is true (the defaults to T), then THUNK will then be CALL-FUNCTION'ed
+with the stream and the pathname (if WANT-PATHNAME-P is true, defaults to T),
+and stream with be closed after the THUNK exits (either normally or abnormally).
+If WANT-STREAM-P is false, then WANT-PATHAME-P must be true, and then
+THUNK is only CALL-FUNCTION'ed after the stream is closed, with the pathname as argument.
+Upon exit of THUNK, the AFTER thunk if defined is CALL-FUNCTION'ed with the pathname as argument.
+If AFTER is defined, its results are returned, otherwise, the results of THUNK are returned.
+Finally, the file will be deleted, unless the KEEP argument when CALL-FUNCTION'ed returns true."
+ #+xcl (declare (ignorable typep))
(check-type direction (member :output :io))
(assert (or want-stream-p want-pathname-p))
(loop
- :with prefix = (namestring (ensure-absolute-pathname (or prefix "tmp") #'temporary-directory))
+ :with prefix = (native-namestring
+ (ensure-absolute-pathname
+ (or prefix "tmp")
+ (or (ensure-pathname directory :namestring :native :ensure-directory t)
+ #'temporary-directory)))
:with results = ()
- :for counter :from (random (ash 1 32))
- :for pathname = (pathname (format nil "~A~36R" prefix counter))
+ :for counter :from (random (expt 36 #-gcl 8 #+gcl 5))
+ :for pathname = (parse-native-namestring
+ (format nil "~A~36R~@[~A~]~@[.~A~]" prefix counter suffix type))
:for okp = nil :do
;; TODO: on Unix, do something about umask
;; TODO: on Unix, audit the code so we make sure it uses O_CREAT|O_EXCL
- ;; TODO: on Unix, use CFFI and mkstemp -- but UIOP is precisely meant to not depend on CFFI or on anything! Grrrr.
+ ;; TODO: on Unix, use CFFI and mkstemp --
+ ;; except UIOP is precisely meant to not depend on CFFI or on anything! Grrrr.
+ ;; Can we at least design some hook?
(unwind-protect
(progn
(with-open-file (stream pathname
:direction direction
:element-type element-type
- #-gcl2.6 :external-format #-gcl2.6 external-format
+ :external-format external-format
:if-exists nil :if-does-not-exist :create)
(when stream
(setf okp pathname)
@@ -3897,57 +3964,77 @@ The file will be open with specified DIRECTION, ELEMENT-TYPE and EXTERNAL-FORMAT
(funcall thunk stream pathname)
(funcall thunk stream)))))))
(when okp
- (if want-stream-p
- (return (apply 'values results))
- (return (funcall thunk pathname)))))
- (when (and okp (not keep))
+ (unless want-stream-p
+ (setf results (multiple-value-list (call-function thunk pathname))))
+ (when after
+ (setf results (multiple-value-list (call-function after pathname))))
+ (return (apply 'values results))))
+ (when (and okp (not (call-function keep)))
(ignore-errors (delete-file-if-exists okp))))))
(defmacro with-temporary-file ((&key (stream (gensym "STREAM") streamp)
(pathname (gensym "PATHNAME") pathnamep)
- prefix keep direction element-type external-format)
+ directory prefix suffix type
+ keep direction element-type external-format)
&body body)
"Evaluate BODY where the symbols specified by keyword arguments
STREAM and PATHNAME (if respectively specified) are bound corresponding
to a newly created temporary file ready for I/O, as per CALL-WITH-TEMPORARY-FILE.
-The STREAM will be closed if no binding is specified.
-Unless KEEP is specified, delete the file afterwards."
+At least one of STREAM or PATHNAME must be specified.
+If the STREAM is not specified, it will be closed before the BODY is evaluated.
+If STREAM is specified, then the :CLOSE-STREAM label if it appears in the BODY,
+separates forms run before and after the stream is closed.
+The values of the last form of the BODY (not counting the separating :CLOSE-STREAM) are returned.
+Upon success, the KEEP form is evaluated and the file is is deleted unless it evaluates to TRUE."
(check-type stream symbol)
(check-type pathname symbol)
(assert (or streamp pathnamep))
- `(flet ((think (,@(when streamp `(,stream)) ,@(when pathnamep `(,pathname)))
- , at body))
- #-gcl (declare (dynamic-extent #'think))
- (call-with-temporary-file
- #'think
- :want-stream-p ,streamp
- :want-pathname-p ,pathnamep
- ,@(when direction `(:direction ,direction))
- ,@(when prefix `(:prefix ,prefix))
- ,@(when keep `(:keep ,keep))
- ,@(when element-type `(:element-type ,element-type))
- ,@(when external-format `(:external-format ,external-format)))))
-
- (defun get-temporary-file (&key prefix)
- (with-temporary-file (:pathname pn :keep t :prefix prefix)
+ (let* ((afterp (position :close-stream body))
+ (before (if afterp (subseq body 0 afterp) body))
+ (after (when afterp (subseq body (1+ afterp))))
+ (beforef (gensym "BEFORE"))
+ (afterf (gensym "AFTER")))
+ `(flet (,@(when before
+ `((,beforef (,@(when streamp `(,stream)) ,@(when pathnamep `(,pathname))) , at before)))
+ ,@(when after
+ (assert pathnamep)
+ `((,afterf (,pathname) , at after))))
+ #-gcl (declare (dynamic-extent ,@(when before `(#',beforef)) ,@(when after `(#',afterf))))
+ (call-with-temporary-file
+ ,(when before `#',beforef)
+ :want-stream-p ,streamp
+ :want-pathname-p ,pathnamep
+ ,@(when direction `(:direction ,direction))
+ ,@(when directory `(:directory ,directory))
+ ,@(when prefix `(:prefix ,prefix))
+ ,@(when suffix `(:suffix ,suffix))
+ ,@(when type `(:type ,type))
+ ,@(when keep `(:keep ,keep))
+ ,@(when after `(:after #',afterf))
+ ,@(when element-type `(:element-type ,element-type))
+ ,@(when external-format `(:external-format ,external-format))))))
+
+ (defun get-temporary-file (&key directory prefix suffix type)
+ (with-temporary-file (:pathname pn :keep t
+ :directory directory :prefix prefix :suffix suffix :type type)
pn))
;; Temporary pathnames in simple cases where no contention is assumed
- (defun add-pathname-suffix (pathname suffix)
- "Add a SUFFIX to the name of a PATHNAME, return a new pathname"
- (make-pathname :name (strcat (pathname-name pathname) suffix)
- :defaults pathname))
+ (defun add-pathname-suffix (pathname suffix &rest keys)
+ "Add a SUFFIX to the name of a PATHNAME, return a new pathname.
+Further KEYS can be passed to MAKE-PATHNAME."
+ (apply 'make-pathname :name (strcat (pathname-name pathname) suffix)
+ :defaults pathname keys))
(defun tmpize-pathname (x)
"Return a new pathname modified from X by adding a trivial deterministic suffix"
- (add-pathname-suffix x "-ASDF-TMP"))
+ (add-pathname-suffix x "-TMP"))
(defun call-with-staging-pathname (pathname fun)
- "Calls fun with a staging pathname, and atomically
-renames the staging pathname to the pathname in the end.
-Note: this protects only against failure of the program,
-not against concurrent attempts.
-For the latter case, we ought pick random suffix and atomically open it."
+ "Calls FUN with a staging pathname, and atomically
+renames the staging pathname to the PATHNAME in the end.
+NB: this protects only against failure of the program, not against concurrent attempts.
+For the latter case, we ought pick a random suffix and atomically open it."
(let* ((pathname (pathname pathname))
(staging (tmpize-pathname pathname)))
(unwind-protect
@@ -3957,6 +4044,7 @@ For the latter case, we ought pick random suffix and atomically open it."
(delete-file-if-exists staging))))
(defmacro with-staging-pathname ((pathname-var &optional (pathname-value pathname-var)) &body body)
+ "Trivial syntax wrapper for CALL-WITH-STAGING-PATHNAME"
`(call-with-staging-pathname ,pathname-value #'(lambda (,pathname-var) , at body))))
;;;; -------------------------------------------------------------------------
@@ -3968,7 +4056,7 @@ For the latter case, we ought pick random suffix and atomically open it."
(:use :uiop/common-lisp :uiop/package :uiop/utility :uiop/pathname :uiop/stream :uiop/os)
(:export
#:*image-dumped-p* #:raw-command-line-arguments #:*command-line-arguments*
- #:command-line-arguments #:raw-command-line-arguments #:setup-command-line-arguments
+ #:command-line-arguments #:raw-command-line-arguments #:setup-command-line-arguments #:argv0
#:*lisp-interaction*
#:*fatal-conditions* #:fatal-condition-p #:handle-fatal-condition
#:call-with-fatal-condition-handler #:with-fatal-condition-handler
@@ -4031,7 +4119,7 @@ This is designed to abstract away the implementation specific quit forms."
#+cormanlisp (win32:exitprocess code)
#+(or cmu scl) (unix:unix-exit code)
#+ecl (si:quit code)
- #+gcl (lisp:quit code)
+ #+gcl (system:quit code)
#+genera (error "You probably don't want to Halt the Machine. (code: ~S)" code)
#+lispworks (lispworks:quit :status code :confirm nil :return nil :ignore-errors-p t)
#+mcl (progn code (ccl:quit)) ;; or should we use FFI to call libc's exit(3) ?
@@ -4051,11 +4139,13 @@ This is designed to abstract away the implementation specific quit forms."
(format! *stderr* "~&~?~&" format arguments)))
(quit code))
- (defun raw-print-backtrace (&key (stream *debug-io*) count)
+ (defun raw-print-backtrace (&key (stream *debug-io*) count condition)
"Print a backtrace, directly accessing the implementation"
- (declare (ignorable stream count))
+ (declare (ignorable stream count condition))
#+abcl
- (let ((*debug-io* stream)) (top-level::backtrace-command count))
+ (loop :for i :from 0
+ :for frame :in (sys:backtrace (or count most-positive-fixnum)) :do
+ (safe-format! stream "~&~D: ~A~%" i frame))
#+allegro
(let ((*terminal-io* stream)
(*standard-output* stream)
@@ -4064,7 +4154,7 @@ This is designed to abstract away the implementation specific quit forms."
(tpl:*zoom-print-length* *print-length*))
(tpl:do-command "zoom"
:from-read-eval-print-loop nil
- :count t
+ :count (or count t)
:all t))
#+clisp
(system::print-backtrace :out stream :limit count)
@@ -4076,9 +4166,23 @@ This is designed to abstract away the implementation specific quit forms."
#+(or cmu scl)
(let ((debug:*debug-print-level* *print-level*)
(debug:*debug-print-length* *print-length*))
- (debug:backtrace most-positive-fixnum stream))
- #+ecl
- (si::tpl-backtrace)
+ (debug:backtrace (or count most-positive-fixnum) stream))
+ #+(or ecl mkcl)
+ (let* ((top (si:ihs-top))
+ (repeats (if count (min top count) top))
+ (backtrace (loop :for ihs :from 0 :below top
+ :collect (list (si::ihs-fun ihs)
+ (si::ihs-env ihs)))))
+ (loop :for i :from 0 :below repeats
+ :for frame :in (nreverse backtrace) :do
+ (safe-format! stream "~&~D: ~S~%" i frame)))
+ #+gcl
+ (let ((*debug-io* stream))
+ (ignore-errors
+ (with-safe-io-syntax ()
+ (if condition
+ (conditions::condition-backtrace condition)
+ (system::simple-backtrace)))))
#+lispworks
(let ((dbg::*debugger-stack*
(dbg::grab-stack nil :how-many (or count most-positive-fixnum)))
@@ -4089,11 +4193,15 @@ This is designed to abstract away the implementation specific quit forms."
#+sbcl
(sb-debug:backtrace
#.(if (find-symbol* "*VERBOSITY*" "SB-DEBUG" nil) :stream '(or count most-positive-fixnum))
- stream))
+ stream)
+ #+xcl
+ (loop :for i :from 0 :below (or count most-positive-fixnum)
+ :for frame :in (extensions:backtrace-as-list) :do
+ (safe-format! stream "~&~D: ~S~%" i frame)))
- (defun print-backtrace (&rest keys &key stream count)
+ (defun print-backtrace (&rest keys &key stream count condition)
"Print a backtrace"
- (declare (ignore stream count))
+ (declare (ignore stream count condition))
(with-safe-io-syntax (:package :cl)
(let ((*print-readably* nil)
(*print-circle* t)
@@ -4108,7 +4216,7 @@ This is designed to abstract away the implementation specific quit forms."
;; We print the condition *after* the backtrace,
;; for the sake of who sees the backtrace at a terminal.
;; It is up to the caller to print the condition *before*, with some context.
- (print-backtrace :stream stream :count count)
+ (print-backtrace :stream stream :count count :condition condition)
(when condition
(safe-format! stream "~&Above backtrace due to this condition:~%~A~&"
condition)))
@@ -4174,49 +4282,96 @@ depending on whether *LISP-INTERACTION* is set, enter debugger or die"
#+gcl si:*command-args*
#+(or genera mcl) nil
#+lispworks sys:*line-arguments-list*
+ #+mkcl (loop :for i :from 0 :below (mkcl:argc) :collect (mkcl:argv i))
#+sbcl sb-ext:*posix-argv*
#+xcl system:*argv*
- #-(or abcl allegro clisp clozure cmu ecl gcl genera lispworks mcl sbcl scl xcl)
+ #-(or abcl allegro clisp clozure cmu ecl gcl genera lispworks mcl mkcl sbcl scl xcl)
(error "raw-command-line-arguments not implemented yet"))
(defun command-line-arguments (&optional (arguments (raw-command-line-arguments)))
"Extract user arguments from command-line invocation of current process.
Assume the calling conventions of a generated script that uses --
if we are not called from a directly executable image."
- #+abcl arguments
- #-abcl
- (let* (#-(or sbcl allegro)
- (arguments
- (if (eq *image-dumped-p* :executable)
- arguments
- (member "--" arguments :test 'string-equal))))
+ (block nil
+ #+abcl (return arguments)
+ ;; SBCL and Allegro already separate user arguments from implementation arguments.
+ #-(or sbcl allegro)
+ (unless (eq *image-dumped-p* :executable)
+ ;; LispWorks command-line processing isn't transparent to the user
+ ;; unless you create a standalone executable; in that case,
+ ;; we rely on cl-launch or some other script to set the arguments for us.
+ #+lispworks (return *command-line-arguments*)
+ ;; On other implementations, on non-standalone executables,
+ ;; we trust cl-launch or whichever script starts the program
+ ;; to use -- as a delimiter between implementation arguments and user arguments.
+ #-lispworks (setf arguments (member "--" arguments :test 'string-equal)))
(rest arguments)))
+ (defun argv0 ()
+ "On supported implementations (most that matter), or when invoked by a proper wrapper script,
+return a string that for the name with which the program was invoked, i.e. argv[0] in C.
+Otherwise, return NIL."
+ (cond
+ ((eq *image-dumped-p* :executable) ; yes, this ARGV0 is our argv0 !
+ ;; NB: not currently available on ABCL, Corman, Genera, MCL
+ (or #+(or allegro clisp clozure cmu gcl lispworks sbcl scl xcl)
+ (first (raw-command-line-arguments))
+ #+ecl (si:argv 0) #+mkcl (mkcl:argv 0)))
+ (t ;; argv[0] is the name of the interpreter.
+ ;; The wrapper script can export __CL_ARGV0. cl-launch does as of 4.0.1.8.
+ (getenvp "__CL_ARGV0"))))
+
(defun setup-command-line-arguments ()
(setf *command-line-arguments* (command-line-arguments)))
(defun restore-image (&key
- ((:lisp-interaction *lisp-interaction*) *lisp-interaction*)
- ((:restore-hook *image-restore-hook*) *image-restore-hook*)
- ((:prelude *image-prelude*) *image-prelude*)
- ((:entry-point *image-entry-point*) *image-entry-point*)
+ (lisp-interaction *lisp-interaction*)
+ (restore-hook *image-restore-hook*)
+ (prelude *image-prelude*)
+ (entry-point *image-entry-point*)
(if-already-restored '(cerror "RUN RESTORE-IMAGE ANYWAY")))
"From a freshly restarted Lisp image, restore the saved Lisp environment
-by setting appropriate variables, running various hooks, and calling any specified entry point."
+by setting appropriate variables, running various hooks, and calling any specified entry point.
+
+If the image has already been restored or is already being restored, as per *IMAGE-RESTORED-P*,
+call the IF-ALREADY-RESTORED error handler (by default, a continuable error), and do return
+immediately to the surrounding restore process if allowed to continue.
+
+Then, comes the restore process itself:
+First, call each function in the RESTORE-HOOK,
+in the order they were registered with REGISTER-RESTORE-HOOK.
+Second, evaluate the prelude, which is often Lisp text that is read,
+as per EVAL-INPUT.
+Third, call the ENTRY-POINT function, if any is specified, with no argument.
+
+The restore process happens in a WITH-FATAL-CONDITION-HANDLER, so that if LISP-INTERACTION is NIL,
+any unhandled error leads to a backtrace and an exit with an error status.
+If LISP-INTERACTION is NIL, the process also exits when no error occurs:
+if neither restart nor entry function is provided, the program will exit with status 0 (success);
+if a function was provided, the program will exit after the function returns (if it returns),
+with status 0 if and only if the primary return value of result is generalized boolean true,
+and with status 1 if this value is NIL.
+
+If LISP-INTERACTION is true, unhandled errors will take you to the debugger, and the result
+of the function will be returned rather than interpreted as a boolean designating an exit code."
(when *image-restored-p*
(if if-already-restored
- (call-function if-already-restored "Image already ~:[being ~;~]restored" (eq *image-restored-p* t))
+ (call-function if-already-restored "Image already ~:[being ~;~]restored"
+ (eq *image-restored-p* t))
(return-from restore-image)))
(with-fatal-condition-handler ()
+ (setf *lisp-interaction* lisp-interaction)
+ (setf *image-restore-hook* restore-hook)
+ (setf *image-prelude* prelude)
(setf *image-restored-p* :in-progress)
(call-image-restore-hook)
- (standard-eval-thunk *image-prelude*)
+ (standard-eval-thunk prelude)
(setf *image-restored-p* t)
(let ((results (multiple-value-list
- (if *image-entry-point*
- (call-function *image-entry-point*)
+ (if entry-point
+ (call-function entry-point)
t))))
- (if *lisp-interaction*
+ (if lisp-interaction
(apply 'values results)
(shell-boolean-exit (first results)))))))
@@ -4225,14 +4380,28 @@ by setting appropriate variables, running various hooks, and calling any specifi
(with-upgradability ()
(defun dump-image (filename &key output-name executable
- ((:postlude *image-postlude*) *image-postlude*)
- ((:dump-hook *image-dump-hook*) *image-dump-hook*)
- #+clozure prepend-symbols #+clozure (purify t))
- "Dump an image of the current Lisp environment at pathname FILENAME, with various options"
+ (postlude *image-postlude*)
+ (dump-hook *image-dump-hook*)
+ #+clozure prepend-symbols #+clozure (purify t)
+ #+sbcl compression
+ #+(and sbcl windows) application-type)
+ "Dump an image of the current Lisp environment at pathname FILENAME, with various options.
+
+First, finalize the image, by evaluating the POSTLUDE as per EVAL-INPUT, then calling each of
+ the functions in DUMP-HOOK, in reverse order of registration by REGISTER-DUMP-HOOK.
+
+If EXECUTABLE is true, create an standalone executable program that calls RESTORE-IMAGE on startup.
+
+Pass various implementation-defined options, such as PREPEND-SYMBOLS and PURITY on CCL,
+or COMPRESSION on SBCL, and APPLICATION-TYPE on SBCL/Windows."
+ ;; Note: at least SBCL saves only global values of variables in the heap image,
+ ;; so make sure things you want to dump are NOT just local bindings shadowing the global values.
(declare (ignorable filename output-name executable))
(setf *image-dumped-p* (if executable :executable t))
(setf *image-restored-p* :in-regress)
+ (setf *image-postlude* postlude)
(standard-eval-thunk *image-postlude*)
+ (setf *image-dump-hook* dump-hook)
(call-image-dump-hook)
(setf *image-restored-p* nil)
#-(or clisp clozure cmu lispworks sbcl scl)
@@ -4268,8 +4437,9 @@ by setting appropriate variables, running various hooks, and calling any specifi
(ext:gc :full t)
(setf ext:*batch-mode* nil)
(setf ext::*gc-run-time* 0)
- (apply 'ext:save-lisp filename #+cmu :executable #+cmu t
- (when executable '(:init-function restore-image :process-command-line nil))))
+ (apply 'ext:save-lisp filename
+ #+cmu :executable #+cmu t
+ (when executable '(:init-function restore-image :process-command-line nil))))
#+gcl
(progn
(si::set-hole-size 500) (si::gbc nil) (si::sgc-on t)
@@ -4284,39 +4454,64 @@ by setting appropriate variables, running various hooks, and calling any specifi
(setf sb-ext::*gc-run-time* 0)
(apply 'sb-ext:save-lisp-and-die filename
:executable t ;--- always include the runtime that goes with the core
- (when executable (list :toplevel #'restore-image :save-runtime-options t)))) ;--- only save runtime-options for standalone executables
+ (append
+ (when compression (list :compression compression))
+ ;;--- only save runtime-options for standalone executables
+ (when executable (list :toplevel #'restore-image :save-runtime-options t))
+ #+(and sbcl windows) ;; passing :application-type :gui will disable the console window.
+ ;; the default is :console - only works with SBCL 1.1.15 or later.
+ (when application-type (list :application-type application-type)))))
#-(or allegro clisp clozure cmu gcl lispworks sbcl scl)
(error "Can't ~S ~S: UIOP doesn't support image dumping with ~A.~%"
'dump-image filename (nth-value 1 (implementation-type))))
- (defun create-image (destination object-files
- &key kind output-name prologue-code epilogue-code
+ (defun create-image (destination lisp-object-files
+ &key kind output-name prologue-code epilogue-code extra-object-files
(prelude () preludep) (postlude () postludep)
- (entry-point () entry-point-p) build-args)
- (declare (ignorable destination object-files kind output-name prologue-code epilogue-code
- prelude preludep postlude postludep entry-point entry-point-p build-args))
+ (entry-point () entry-point-p) build-args no-uiop)
+ (declare (ignorable destination lisp-object-files extra-object-files kind output-name
+ prologue-code epilogue-code prelude preludep postlude postludep
+ entry-point entry-point-p build-args no-uiop))
"On ECL, create an executable at pathname DESTINATION from the specified OBJECT-FILES and options"
;; Is it meaningful to run these in the current environment?
;; only if we also track the object files that constitute the "current" image,
;; and otherwise simulate dump-image, including quitting at the end.
- #-ecl (error "~S not implemented for your implementation (yet)" 'create-image)
- #+ecl
- (progn
- (check-type kind (member :binary :dll :lib :static-library :program :object :fasl :program))
- (apply 'c::builder
- kind (pathname destination)
- :lisp-files object-files
- :init-name (c::compute-init-name (or output-name destination) :kind kind)
- :prologue-code prologue-code
- :epilogue-code
- `(progn
- ,epilogue-code
- ,@(when (eq kind :program)
- `((setf *image-dumped-p* :executable)
- (restore-image ;; default behavior would be (si::top-level)
- ,@(when preludep `(:prelude ',prelude))
- ,@(when entry-point-p `(:entry-point ',entry-point))))))
- build-args))))
+ #-(or ecl mkcl) (error "~S not implemented for your implementation (yet)" 'create-image)
+ #+(or ecl mkcl)
+ (let ((epilogue-code
+ (if no-uiop
+ epilogue-code
+ (let ((forms
+ (append
+ (when epilogue-code `(,epilogue-code))
+ (when postludep `((setf *image-postlude* ',postlude)))
+ (when preludep `((setf *image-prelude* ',prelude)))
+ (when entry-point-p `((setf *image-entry-point* ',entry-point)))
+ (case kind
+ ((:image)
+ (setf kind :program) ;; to ECL, it's just another program.
+ `((setf *image-dumped-p* t)
+ (si::top-level #+ecl t) (quit)))
+ ((:program)
+ `((setf *image-dumped-p* :executable)
+ (shell-boolean-exit
+ (restore-image))))))))
+ (when forms `(progn , at forms))))))
+ #+ecl (check-type kind (member :dll :lib :static-library :program :object :fasl))
+ (apply #+ecl 'c::builder #+ecl kind
+ #+mkcl (ecase kind
+ ((:dll) 'compiler::build-shared-library)
+ ((:lib :static-library) 'compiler::build-static-library)
+ ((:fasl) 'compiler::build-bundle)
+ ((:program) 'compiler::build-program))
+ (pathname destination)
+ #+ecl :lisp-files #+mkcl :lisp-object-files (append lisp-object-files #+ecl extra-object-files)
+ #+ecl :init-name #+ecl (c::compute-init-name (or output-name destination) :kind kind)
+ (append
+ (when prologue-code `(:prologue-code ,prologue-code))
+ (when epilogue-code `(:epilogue-code ,epilogue-code))
+ #+mkcl (when extra-object-files `(:object-files ,extra-object-files))
+ build-args)))))
;;; Some universal image restore hooks
@@ -4331,7 +4526,8 @@ by setting appropriate variables, running various hooks, and calling any specifi
(uiop/package:define-package :uiop/run-program
(:nicknames :asdf/run-program)
(:recycle :uiop/run-program :asdf/run-program :xcvb-driver)
- (:use :uiop/common-lisp :uiop/utility :uiop/pathname :uiop/os :uiop/filesystem :uiop/stream)
+ (:use :uiop/common-lisp :uiop/package :uiop/utility
+ :uiop/pathname :uiop/os :uiop/filesystem :uiop/stream)
(:export
;;; Escaping the command invocation madness
#:easy-sh-character-p #:escape-sh-token #:escape-sh-command
@@ -4497,14 +4693,14 @@ Built-in methods include the following:
Programmers are encouraged to define their own methods for this generic function."))
- #-(or gcl2.6 genera)
+ #-genera
(defmethod slurp-input-stream ((function function) input-stream &key)
(funcall function input-stream))
(defmethod slurp-input-stream ((list cons) input-stream &key)
(apply (first list) input-stream (rest list)))
- #-(or gcl2.6 genera)
+ #-genera
(defmethod slurp-input-stream ((output-stream stream) input-stream
&key linewise prefix (element-type 'character) buffer-size)
(copy-stream-to-stream
@@ -4512,35 +4708,27 @@ Programmers are encouraged to define their own methods for this generic function
:linewise linewise :prefix prefix :element-type element-type :buffer-size buffer-size))
(defmethod slurp-input-stream ((x (eql 'string)) stream &key stripped)
- (declare (ignorable x))
(slurp-stream-string stream :stripped stripped))
(defmethod slurp-input-stream ((x (eql :string)) stream &key stripped)
- (declare (ignorable x))
(slurp-stream-string stream :stripped stripped))
(defmethod slurp-input-stream ((x (eql :lines)) stream &key count)
- (declare (ignorable x))
(slurp-stream-lines stream :count count))
(defmethod slurp-input-stream ((x (eql :line)) stream &key (at 0))
- (declare (ignorable x))
(slurp-stream-line stream :at at))
(defmethod slurp-input-stream ((x (eql :forms)) stream &key count)
- (declare (ignorable x))
(slurp-stream-forms stream :count count))
(defmethod slurp-input-stream ((x (eql :form)) stream &key (at 0))
- (declare (ignorable x))
(slurp-stream-form stream :at at))
(defmethod slurp-input-stream ((x (eql t)) stream &rest keys &key &allow-other-keys)
- (declare (ignorable x))
(apply 'slurp-input-stream *standard-output* stream keys))
- (defmethod slurp-input-stream ((x null) stream &key)
- (declare (ignorable x stream))
+ (defmethod slurp-input-stream ((x null) (stream t) &key)
nil)
(defmethod slurp-input-stream ((pathname pathname) input
@@ -4564,9 +4752,9 @@ Programmers are encouraged to define their own methods for this generic function
&key linewise prefix (element-type 'character) buffer-size)
(declare (ignorable stream linewise prefix element-type buffer-size))
(cond
- #+(or gcl2.6 genera)
+ #+genera
((functionp x) (funcall x stream))
- #+(or gcl2.6 genera)
+ #+genera
((output-stream-p x)
(copy-stream-to-stream
stream x
@@ -4594,14 +4782,14 @@ Built-in methods include the following:
Programmers are encouraged to define their own methods for this generic function."))
- #-(or gcl2.6 genera)
+ #-genera
(defmethod vomit-output-stream ((function function) output-stream &key)
(funcall function output-stream))
(defmethod vomit-output-stream ((list cons) output-stream &key)
(apply (first list) output-stream (rest list)))
- #-(or gcl2.6 genera)
+ #-genera
(defmethod vomit-output-stream ((input-stream stream) output-stream
&key linewise prefix (element-type 'character) buffer-size)
(copy-stream-to-stream
@@ -4615,11 +4803,9 @@ Programmers are encouraged to define their own methods for this generic function
(values))
(defmethod vomit-output-stream ((x (eql t)) stream &rest keys &key &allow-other-keys)
- (declare (ignorable x))
(apply 'vomit-output-stream *standard-input* stream keys))
- (defmethod vomit-output-stream ((x null) stream &key)
- (declare (ignorable x stream))
+ (defmethod vomit-output-stream ((x null) (stream t) &key)
(values))
(defmethod vomit-output-stream ((pathname pathname) input
@@ -4643,9 +4829,9 @@ Programmers are encouraged to define their own methods for this generic function
&key linewise prefix (element-type 'character) buffer-size)
(declare (ignorable stream linewise prefix element-type buffer-size))
(cond
- #+(or gcl2.6 genera)
+ #+genera
((functionp x) (funcall x stream))
- #+(or gcl2.6 genera)
+ #+genera
((input-stream-p x)
(copy-stream-to-stream
x stream
@@ -4677,6 +4863,7 @@ for the implementation's underlying run-program function"
#+os-unix (list command)
#+os-windows
(string
+ #+mkcl (list "cmd" '#:/c command)
;; NB: We do NOT add cmd /c here. You might want to.
#+(or allegro clisp) command
;; On ClozureCL for Windows, we assume you are using
@@ -4686,7 +4873,7 @@ for the implementation's underlying run-program function"
;; NB: On other Windows implementations, this is utterly bogus
;; except in the most trivial cases where no quoting is needed.
;; Use at your own risk.
- #-(or allegro clisp clozure) (list "cmd" "/c" command))
+ #-(or allegro clisp clozure mkcl) (list "cmd" "/c" command))
#+os-windows
(list
#+allegro (escape-windows-command command)
@@ -4706,15 +4893,15 @@ argument to pass to the internal RUN-PROGRAM"
(declare (ignorable role))
(etypecase specifier
(null (or #+(or allegro lispworks) (null-device-pathname)))
- (string (pathname specifier))
+ (string (parse-native-namestring specifier))
(pathname specifier)
(stream specifier)
((eql :stream) :stream)
((eql :interactive)
#+allegro nil
#+clisp :terminal
- #+(or clozure cmu ecl sbcl scl) t)
- #+(or allegro clozure cmu ecl lispworks sbcl scl)
+ #+(or clozure cmu ecl mkcl sbcl scl) t)
+ #+(or allegro clozure cmu ecl lispworks mkcl sbcl scl)
((eql :output)
(if (eq role :error-output)
:output
@@ -4745,12 +4932,12 @@ to be normalized by %NORMALIZE-IO-SPECIFIER.
It returns a process-info plist with possible keys:
PROCESS, EXIT-CODE, INPUT-STREAM, OUTPUT-STREAM, BIDIR-STREAM, ERROR-STREAM."
;; NB: these implementations have unix vs windows set at compile-time.
- (declare (ignorable if-input-does-not-exist if-output-exists if-error-output-exists))
+ (declare (ignorable directory if-input-does-not-exist if-output-exists if-error-output-exists))
(assert (not (and wait (member :stream (list input output error-output)))))
- #-(or allegro clozure cmu (and lispworks os-unix) sbcl scl)
+ #-(or allegro clisp clozure cmu (and lispworks os-unix) mkcl sbcl scl)
(progn command keys directory
(error "run-program not available"))
- #+(or allegro clisp clozure cmu (and lispworks os-unix) sbcl scl)
+ #+(or allegro clisp clozure cmu (and lispworks os-unix) mkcl sbcl scl)
(let* ((%command (%normalize-command command))
(%input (%normalize-io-specifier input :input))
(%output (%normalize-io-specifier output :output))
@@ -4770,23 +4957,23 @@ It returns a process-info plist with possible keys:
#+os-windows :show-window #+os-windows (if interactive nil :hide)
:allow-other-keys t keys))
#-allegro
- (with-current-directory (#-sbcl directory)
+ (with-current-directory (#-(or sbcl mkcl) directory)
#+clisp
- (flet ((run (f &rest args)
+ (flet ((run (f x &rest args)
(multiple-value-list
- (apply f :input %input :output %output
- :allow-other-keys t `(, at args , at keys)))))
+ (apply f x :input %input :output %output
+ :allow-other-keys t `(, at args , at keys)))))
(assert (eq %error-output :terminal))
;;; since we now always return a code, we can't use this code path, anyway!
(etypecase %command
#+os-windows (string (run 'ext:run-shell-command %command))
(list (run 'ext:run-program (car %command)
:arguments (cdr %command)))))
- #+(or clozure cmu ecl sbcl scl)
- (#-ecl progn #+ecl multiple-value-list
+ #+(or clozure cmu ecl mkcl sbcl scl)
+ (#-(or ecl mkcl) progn #+(or ecl mkcl) multiple-value-list
(apply
'#+(or cmu ecl scl) ext:run-program
- #+clozure ccl:run-program #+sbcl sb-ext:run-program
+ #+clozure ccl:run-program #+sbcl sb-ext:run-program #+mkcl mk-ext:run-program
(car %command) (cdr %command)
:input %input
:output %output
@@ -4794,7 +4981,7 @@ It returns a process-info plist with possible keys:
:wait wait
:allow-other-keys t
(append
- #+(or clozure cmu sbcl scl)
+ #+(or clozure cmu mkcl sbcl scl)
`(:if-input-does-not-exist ,if-input-does-not-exist
:if-output-exists ,if-output-exists
:if-error-exists ,if-error-output-exists)
@@ -4861,8 +5048,8 @@ It returns a process-info plist with possible keys:
#+clozure (ccl:external-process-error-stream process*)
#+(or cmu scl) (ext:process-error process*)
#+sbcl (sb-ext:process-error process*))))
- #+ecl
- (destructuring-bind (stream code process) process*
+ #+(or ecl mkcl)
+ (destructuring-bind #+ecl (stream code process) #+mkcl (stream process code) process*
(let ((mode (+ (if (eq input :stream) 1 0) (if (eq output :stream) 2 0))))
(cond
((zerop mode))
@@ -4882,6 +5069,17 @@ It returns a process-info plist with possible keys:
(when (eq error-output :stream) (prop :error-stream err))))))
(nreverse process-info-r))))
+ (defun %process-info-pid (process-info)
+ (let ((process (getf process-info :process)))
+ (declare (ignorable process))
+ #+(or allegro lispworks) process
+ #+clozure (ccl::external-process-pid process)
+ #+ecl (si:external-process-pid process)
+ #+(or cmu scl) (ext:process-pid process)
+ #+mkcl (mkcl:process-id process)
+ #+sbcl (sb-ext:process-pid process)
+ #-(or allegro cmu mkcl sbcl scl) (error "~S not implemented" '%process-info-pid)))
+
(defun %wait-process-result (process-info)
(or (getf process-info :exit-code)
(let ((process (getf process-info :process)))
@@ -4896,8 +5094,16 @@ It returns a process-info plist with possible keys:
#+clozure (nth-value 1 (ccl:external-process-status process))
#+(or cmu scl) (ext:process-exit-code process)
#+ecl (nth-value 1 (ext:external-process-status process))
- #+lispworks (system:pid-exit-status process :wait t)
- #+sbcl (sb-ext:process-exit-code process)))))
+ #+lispworks
+ (if-let ((stream (or (getf process-info :input-stream)
+ (getf process-info :output-stream)
+ (getf process-info :bidir-stream)
+ (getf process-info :error-stream))))
+ (system:pipe-exit-status stream :wait t)
+ (if-let ((f (find-symbol* :pid-exit-status :system nil)))
+ (funcall f process :wait t)))
+ #+sbcl (sb-ext:process-exit-code process)
+ #+mkcl (mkcl:join-process process)))))
(defun %check-result (exit-code &key command process ignore-error-status)
(unless ignore-error-status
@@ -4997,8 +5203,10 @@ It returns a process-info plist with possible keys:
(defun %use-run-program (command &rest keys
&key input output error-output ignore-error-status &allow-other-keys)
;; helper for RUN-PROGRAM when using %run-program
- #+(or abcl cormanlisp gcl (and lispworks os-windows) mcl mkcl xcl)
- (error "Not implemented on this platform")
+ #+(or abcl cormanlisp gcl (and lispworks os-windows) mcl xcl)
+ (progn
+ command keys input output error-output ignore-error-status ;; ignore
+ (error "Not implemented on this platform"))
(assert (not (member :stream (list input output error-output))))
(let* ((active-input-p (%active-io-specifier-p input))
(active-output-p (%active-io-specifier-p output))
@@ -5060,13 +5268,13 @@ It returns a process-info plist with possible keys:
(let ((pathname
(typecase spec
(null (null-device-pathname))
- (string (pathname spec))
+ (string (parse-native-namestring spec))
(pathname spec)
((eql :output)
- (assert (equal operator "2>"))
+ (assert (equal operator " 2>"))
(return-from redirect '(" 2>&1"))))))
(when pathname
- (list " " operator " "
+ (list operator " "
(escape-shell-token (native-namestring pathname)))))))
(multiple-value-bind (before after)
(let ((normalized (%normalize-system-command command)))
@@ -5075,8 +5283,9 @@ It returns a process-info plist with possible keys:
(values (list normalized) ())))
(reduce/strcat
(append
- before (redirect in "<") (redirect out ">") (redirect err "2>")
- (when (and directory (os-unix-p)) `("cd " (escape-shell-token directory) " ; "))
+ before (redirect in " <") (redirect out " >") (redirect err " 2>")
+ (when (and directory (os-unix-p)) ;; NB: unless on Unix, %system uses with-current-directory
+ `(" ; cd " ,(escape-shell-token (native-namestring directory))))
after)))))
(defun %system (command &rest keys
@@ -5086,26 +5295,26 @@ It returns a process-info plist with possible keys:
#+(or allegro clozure cmu (and lispworks os-unix) sbcl scl)
(%wait-process-result
(apply '%run-program (%normalize-system-command command) :wait t keys))
- #+(or abcl clisp cormanlisp ecl gcl (and lispworks os-windows) mkcl xcl)
+ #+(or abcl cormanlisp clisp ecl gcl (and lispworks os-windows) mkcl xcl)
(let ((%command (%redirected-system-command command input output error-output directory)))
#+(and lispworks os-windows)
(system:call-system %command :current-directory directory :wait t)
- #-(and lispworks os-windows)
+ #+clisp
+ (%wait-process-result
+ (apply '%run-program %command :wait t
+ :input :interactive :output :interactive :error-output :interactive keys))
+ #-(or clisp (and lispworks os-windows))
(with-current-directory ((unless (os-unix-p) directory))
- #+(or abcl xcl) (ext:run-shell-command %command)
- #+clisp (clisp-exit-code (ext:shell %command))
+ #+abcl (ext:run-shell-command %command)
#+cormanlisp (win32:system %command)
#+ecl (let ((*standard-input* *stdin*)
(*standard-output* *stdout*)
(*error-output* *stderr*))
(ext:system %command))
- #+gcl (lisp:system %command)
+ #+gcl (system:system %command)
#+mcl (ccl::with-cstrs ((%%command %command)) (_system %%command))
- #+mkcl ;; PROBABLY BOGUS -- ask jcb
- (multiple-value-bind (io process exit-code)
- (mkcl:run-program #+windows %command #+windows ()
- #-windows "/bin/sh" #-windows (list "-c" %command)
- :input t :output t)))))
+ #+mkcl (mkcl:system %command)
+ #+xcl (system:%run-shell-command %command))))
(defun %use-system (command &rest keys
&key input output error-output ignore-error-status &allow-other-keys)
@@ -5144,30 +5353,38 @@ unless IGNORE-ERROR-STATUS is specified.
If OUTPUT is a pathname, a string designating a pathname, or NIL designating the null device,
the file at that path is used as output.
-If it's :INTERACTIVE, output is inherited from the current process.
+If it's :INTERACTIVE, output is inherited from the current process;
+beware that this may be different from your *STANDARD-OUTPUT*,
+and under SLIME will be on your *inferior-lisp* buffer.
+If it's T, output goes to your current *STANDARD-OUTPUT* stream.
Otherwise, OUTPUT should be a value that is a suitable first argument to
SLURP-INPUT-STREAM (qv.), or a list of such a value and keyword arguments.
-In this case, RUN-PROGRAM will create a temporary stream for the program output.
-The program output, in that stream, will be processed by a call to SLURP-INPUT-STREAM,
+In this case, RUN-PROGRAM will create a temporary stream for the program output;
+the program output, in that stream, will be processed by a call to SLURP-INPUT-STREAM,
using OUTPUT as the first argument (or the first element of OUTPUT, and the rest as keywords).
-T designates the *STANDARD-OUTPUT* to be provided to SLURP-INPUT-STREAM.
The primary value resulting from that call (or NIL if no call was needed)
will be the first value returned by RUN-PROGRAM.
E.g., using :OUTPUT :STRING will have it return the entire output stream as a string.
+And using :OUTPUT '(:STRING :STRIPPED T) will have it return the same string
+stripped of any ending newline.
ERROR-OUTPUT is similar to OUTPUT, except that the resulting value is returned
as the second value of RUN-PROGRAM. T designates the *ERROR-OUTPUT*.
-Also :OUTPUT means redirecting the error output to the output stream, and NIL is returned.
+Also :OUTPUT means redirecting the error output to the output stream,
+in which case NIL is returned.
INPUT is similar to OUTPUT, except that VOMIT-OUTPUT-STREAM is used,
no value is returned, and T designates the *STANDARD-INPUT*.
-Use ELEMENT-TYPE and EXTERNAL-FORMAT to specify how streams are created.
+Use ELEMENT-TYPE and EXTERNAL-FORMAT are passed on
+to your Lisp implementation, when applicable, for creation of the output stream.
One and only one of the stream slurping or vomiting may or may not happen
-in parallel in parallel with the subprocess, depending on options and implementation.
-Other streams are completely produced or consumed before or after the subprocess is spawned,
-using temporary files.
+in parallel in parallel with the subprocess,
+depending on options and implementation,
+and with priority being given to output processing.
+Other streams are completely produced or consumed
+before or after the subprocess is spawned, using temporary files.
RUN-PROGRAM returns 3 values:
0- the result of the OUTPUT slurping if any, or NIL
@@ -5175,7 +5392,7 @@ RUN-PROGRAM returns 3 values:
2- either 0 if the subprocess exited with success status,
or an indication of failure via the EXIT-CODE of the process"
(declare (ignorable ignore-error-status))
- #-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl lispworks mcl sbcl scl xcl)
+ #-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl lispworks mcl mkcl sbcl scl xcl)
(error "RUN-PROGRAM not implemented for this Lisp")
(flet ((default (x xp output) (cond (xp x) ((eq output :interactive) :interactive))))
(apply (if (or force-shell
@@ -5183,7 +5400,7 @@ or an indication of failure via the EXIT-CODE of the process"
#+clisp (eq error-output :interactive)
#+(or abcl clisp) (eq :error-output :output)
#+(and lispworks os-unix) (%interactivep input output error-output)
- #+(or abcl cormanlisp gcl (and lispworks os-windows) mcl mkcl xcl) t)
+ #+(or abcl cormanlisp gcl (and lispworks os-windows) mcl xcl) t)
'%use-system '%use-run-program)
command
:input (default input inputp output)
@@ -5210,11 +5427,12 @@ or an indication of failure via the EXIT-CODE of the process"
#:compile-condition #:compile-file-error #:compile-warned-error #:compile-failed-error
#:compile-warned-warning #:compile-failed-warning
#:check-lisp-compile-results #:check-lisp-compile-warnings
- #:*uninteresting-conditions* #:*uninteresting-compiler-conditions* #:*uninteresting-loader-conditions*
+ #:*uninteresting-conditions* #:*usual-uninteresting-conditions*
+ #:*uninteresting-compiler-conditions* #:*uninteresting-loader-conditions*
;; Types
#+sbcl #:sb-grovel-unknown-constant-condition
;; Functions & Macros
- #:get-optimization-settings #:proclaim-optimization-settings
+ #:get-optimization-settings #:proclaim-optimization-settings #:with-optimization-settings
#:call-with-muffled-compiler-conditions #:with-muffled-compiler-conditions
#:call-with-muffled-loader-conditions #:with-muffled-loader-conditions
#:reify-simple-sexp #:unreify-simple-sexp
@@ -5224,7 +5442,7 @@ or an indication of failure via the EXIT-CODE of the process"
#:enable-deferred-warnings-check #:disable-deferred-warnings-check
#:current-lisp-file-pathname #:load-pathname
#:lispize-pathname #:compile-file-type #:call-around-hook
- #:compile-file* #:compile-file-pathname*
+ #:compile-file* #:compile-file-pathname* #:*compile-check*
#:load* #:load-from-string #:combine-fasls)
(:intern #:defaults #:failure-p #:warnings-p #:s #:y #:body))
(in-package :uiop/lisp-build)
@@ -5254,19 +5472,37 @@ This can help you produce more deterministic output for FASLs."))
"Optimization settings to be used by PROCLAIM-OPTIMIZATION-SETTINGS")
(defvar *previous-optimization-settings* nil
"Optimization settings saved by PROCLAIM-OPTIMIZATION-SETTINGS")
+ (defparameter +optimization-variables+
+ ;; TODO: allegro genera corman mcl
+ (or #+(or abcl xcl) '(system::*speed* system::*space* system::*safety* system::*debug*)
+ #+clisp '() ;; system::*optimize* is a constant hash-table! (with non-constant contents)
+ #+clozure '(ccl::*nx-speed* ccl::*nx-space* ccl::*nx-safety*
+ ccl::*nx-debug* ccl::*nx-cspeed*)
+ #+(or cmu scl) '(c::*default-cookie*)
+ #+ecl (unless (use-ecl-byte-compiler-p) '(c::*speed* c::*space* c::*safety* c::*debug*))
+ #+gcl '(compiler::*speed* compiler::*space* compiler::*compiler-new-safety* compiler::*debug*)
+ #+lispworks '(compiler::*optimization-level*)
+ #+mkcl '(si::*speed* si::*space* si::*safety* si::*debug*)
+ #+sbcl '(sb-c::*policy*)))
(defun get-optimization-settings ()
"Get current compiler optimization settings, ready to PROCLAIM again"
- #-(or clisp clozure cmu ecl sbcl scl)
- (warn "~S does not support ~S. Please help me fix that." 'get-optimization-settings (implementation-type))
- #+clozure (ccl:declaration-information 'optimize nil)
- #+(or clisp cmu ecl sbcl scl)
+ #-(or abcl allegro clisp clozure cmu ecl lispworks mkcl sbcl scl xcl)
+ (warn "~S does not support ~S. Please help me fix that."
+ 'get-optimization-settings (implementation-type))
+ #+(or abcl allegro clisp clozure cmu ecl lispworks mkcl sbcl scl xcl)
(let ((settings '(speed space safety debug compilation-speed #+(or cmu scl) c::brevity)))
- #.`(loop :for x :in settings
- ,@(or #+ecl '(:for v :in '(c::*speed* c::*space* c::*safety* c::*debug*))
- #+(or cmu scl) '(:for f :in '(c::cookie-speed c::cookie-space c::cookie-safety c::cookie-debug c::cookie-cspeed c::cookie-brevity)))
- :for y = (or #+clisp (gethash x system::*optimize*)
- #+(or ecl) (symbol-value v)
- #+(or cmu scl) (funcall f c::*default-cookie*)
+ #.`(loop #+(or allegro clozure)
+ ,@'(:with info = #+allegro (sys:declaration-information 'optimize)
+ #+clozure (ccl:declaration-information 'optimize nil))
+ :for x :in settings
+ ,@(or #+(or abcl ecl gcl mkcl xcl) '(:for v :in +optimization-variables+))
+ :for y = (or #+(or allegro clozure) (second (assoc x info)) ; normalize order
+ #+clisp (gethash x system::*optimize* 1)
+ #+(or abcl ecl mkcl xcl) (symbol-value v)
+ #+(or cmu scl) (slot-value c::*default-cookie*
+ (case x (compilation-speed 'c::cspeed)
+ (otherwise x)))
+ #+lispworks (slot-value compiler::*optimization-level* x)
#+sbcl (cdr (assoc x sb-c::*policy*)))
:when y :collect (list x y))))
(defun proclaim-optimization-settings ()
@@ -5274,7 +5510,18 @@ This can help you produce more deterministic output for FASLs."))
(proclaim `(optimize ,@*optimization-settings*))
(let ((settings (get-optimization-settings)))
(unless (equal *previous-optimization-settings* settings)
- (setf *previous-optimization-settings* settings)))))
+ (setf *previous-optimization-settings* settings))))
+ (defmacro with-optimization-settings ((&optional (settings *optimization-settings*)) &body body)
+ #+(or allegro clisp)
+ (let ((previous-settings (gensym "PREVIOUS-SETTINGS")))
+ `(let ((,previous-settings (get-optimization-settings)))
+ ,@(when settings `((proclaim `(optimize ,@,settings))))
+ (unwind-protect (progn , at body)
+ (proclaim `(optimize ,@,previous-settings)))))
+ #-(or allegro clisp)
+ `(let ,(loop :for v :in +optimization-variables+ :collect `(,v ,v))
+ ,@(when settings `((proclaim `(optimize ,@,settings))))
+ , at body)))
;;; Condition control
@@ -5696,7 +5943,7 @@ If that given type is NIL, use the currently configured *WARNINGS-FILE-TYPE* ins
(equal (pathname-type file) type)))
(defun check-deferred-warnings (files &optional context-format context-arguments)
- "Given a list of FILES in which deferred warnings were saved by CALL-WITH-DEFERRED-WARNINGS,
+ "Given a list of FILES containing deferred warnings saved by CALL-WITH-SAVED-DEFERRED-WARNINGS,
re-intern and raise any warnings that are still meaningful."
(let ((file-errors nil)
(failure-p nil)
@@ -5737,12 +5984,13 @@ re-intern and raise any warnings that are still meaningful."
(macroexpand-1 '(with-compilation-unit () foo))
|#
- (defun call-with-saved-deferred-warnings (thunk warnings-file)
+ (defun call-with-saved-deferred-warnings (thunk warnings-file &key source-namestring)
"If WARNINGS-FILE is not nil, record the deferred-warnings around a call to THUNK
and save those warnings to the given file for latter use,
possibly in a different process. Otherwise just call THUNK."
+ (declare (ignorable source-namestring))
(if warnings-file
- (with-compilation-unit (:override t)
+ (with-compilation-unit (:override t #+sbcl :source-namestring #+sbcl source-namestring)
(unwind-protect
(let (#+sbcl (sb-c::*undefined-warnings* nil))
(multiple-value-prog1
@@ -5751,9 +5999,10 @@ possibly in a different process. Otherwise just call THUNK."
(reset-deferred-warnings)))
(funcall thunk)))
- (defmacro with-saved-deferred-warnings ((warnings-file) &body body)
+ (defmacro with-saved-deferred-warnings ((warnings-file &key source-namestring) &body body)
"Trivial syntax for CALL-WITH-SAVED-DEFERRED-WARNINGS"
- `(call-with-saved-deferred-warnings #'(lambda () , at body) ,warnings-file)))
+ `(call-with-saved-deferred-warnings
+ #'(lambda () , at body) ,warnings-file :source-namestring ,source-namestring)))
;;; from ASDF
@@ -5764,7 +6013,7 @@ possibly in a different process. Otherwise just call THUNK."
(defun load-pathname ()
"Portably return the LOAD-PATHNAME of the current source file or fasl"
- *load-pathname*) ;; see magic for GCL in uiop/common-lisp
+ *load-pathname*) ;; magic no longer needed for GCL.
(defun lispize-pathname (input-file)
"From a INPUT-FILE pathname, return a corresponding .lisp source pathname"
@@ -5783,7 +6032,7 @@ possibly in a different process. Otherwise just call THUNK."
(defun compile-file-pathname* (input-file &rest keys &key output-file &allow-other-keys)
"Variant of COMPILE-FILE-PATHNAME that works well with COMPILE-FILE*"
(let* ((keys
- (remove-plist-keys `(#+(and allegro (not (version>= 8 2))) :external-format
+ (remove-plist-keys `(#+(or (and allegro (not (version>= 8 2)))) :external-format
,@(unless output-file '(:output-file))) keys)))
(if (absolute-pathname-p output-file)
;; what cfp should be doing, w/ mp* instead of mp
@@ -5794,8 +6043,11 @@ possibly in a different process. Otherwise just call THUNK."
(funcall *output-translation-function*
(apply 'compile-file-pathname input-file keys)))))
+ (defvar *compile-check* nil
+ "A hook for user-defined compile-time invariants")
+
(defun* (compile-file*) (input-file &rest keys
- &key compile-check output-file warnings-file
+ &key (compile-check *compile-check*) output-file warnings-file
#+clisp lib-file #+(or ecl mkcl) object-file #+sbcl emit-cfasl
&allow-other-keys)
"This function provides a portable wrapper around COMPILE-FILE.
@@ -5822,8 +6074,7 @@ it will filter them appropriately."
(rotatef output-file object-file))
(let* ((keywords (remove-plist-keys
`(:output-file :compile-check :warnings-file
- #+clisp :lib-file #+(or ecl mkcl) :object-file
- #+gcl2.6 ,@'(:external-format :print :verbose)) keys))
+ #+clisp :lib-file #+(or ecl mkcl) :object-file) keys))
(output-file
(or output-file
(apply 'compile-file-pathname* input-file :output-file output-file keywords)))
@@ -5848,9 +6099,9 @@ it will filter them appropriately."
#+clisp
(tmp-lib (make-pathname :type "lib" :defaults tmp-file)))
(multiple-value-bind (output-truename warnings-p failure-p)
- (with-saved-deferred-warnings (warnings-file)
- (with-muffled-compiler-conditions ()
- (with-enough-pathname (input-file :defaults *base-build-directory*)
+ (with-enough-pathname (input-file :defaults *base-build-directory*)
+ (with-saved-deferred-warnings (warnings-file :source-namestring (namestring input-file))
+ (with-muffled-compiler-conditions ()
(or #-(or ecl mkcl)
(apply 'compile-file input-file :output-file tmp-file
#+sbcl (if emit-cfasl (list* :emit-cfasl tmp-cfasl keywords) keywords)
@@ -5892,20 +6143,20 @@ it will filter them appropriately."
(defun load* (x &rest keys &key &allow-other-keys)
"Portable wrapper around LOAD that properly handles loading from a stream."
- (etypecase x
- ((or pathname string #-(or allegro clozure gcl2.6 genera) stream)
- (apply 'load x
- #-gcl2.6 keys #+gcl2.6 (remove-plist-key :external-format keys)))
- ;; GCL 2.6, Genera can't load from a string-input-stream
- ;; ClozureCL 1.6 can only load from file input stream
- ;; Allegro 5, I don't remember but it must have been broken when I tested.
- #+(or allegro clozure gcl2.6 genera)
- (stream ;; make do this way
- (let ((*package* *package*)
- (*readtable* *readtable*)
- (*load-pathname* nil)
- (*load-truename* nil))
- (eval-input x)))))
+ (with-muffled-loader-conditions ()
+ (etypecase x
+ ((or pathname string #-(or allegro clozure genera) stream #+clozure file-stream)
+ (apply 'load x keys))
+ ;; Genera can't load from a string-input-stream
+ ;; ClozureCL 1.6 can only load from file input stream
+ ;; Allegro 5, I don't remember but it must have been broken when I tested.
+ #+(or allegro clozure genera)
+ (stream ;; make do this way
+ (let ((*package* *package*)
+ (*readtable* *readtable*)
+ (*load-pathname* nil)
+ (*load-truename* nil))
+ (eval-input x))))))
(defun load-from-string (string)
"Portably read and evaluate forms from a STRING."
@@ -6071,8 +6322,12 @@ this function tries to locate the Windows FOLDER for one of
:finally
(unless (= inherit 1)
(report-invalid-form invalid-form-reporter
- :arguments (list (compatfmt "~@<One and only one of ~S or ~S is required.~@:>")
- :inherit-configuration :ignore-inherited-configuration)))
+ :form form :location location
+ ;; we throw away the form and location arguments, hence the ~2*
+ ;; this is necessary because of the report in INVALID-CONFIGURATION
+ :format (compatfmt "~@<Invalid source registry ~S~@[ in ~S~]. ~
+ One and only one of ~S or ~S is required.~@:>")
+ :arguments '(:inherit-configuration :ignore-inherited-configuration)))
(return (nreverse x))))
(defun validate-configuration-file (file validator &key description)
@@ -6302,34 +6557,33 @@ directive.")
(uiop/package:define-package :uiop/driver
(:nicknames :uiop :asdf/driver :asdf-driver :asdf-utils)
- (:use :uiop/common-lisp :uiop/package :uiop/utility
- :uiop/os :uiop/pathname :uiop/stream :uiop/filesystem :uiop/image
- :uiop/run-program :uiop/lisp-build
- :uiop/configuration :uiop/backward-driver)
- (:reexport
- ;; NB: excluding uiop/common-lisp
+ (:use :uiop/common-lisp)
+ ;; NB: not reexporting uiop/common-lisp
;; which include all of CL with compatibility modifications on select platforms,
;; that could cause potential conflicts for packages that would :use (cl uiop)
;; or :use (closer-common-lisp uiop), etc.
+ (:use-reexport
:uiop/package :uiop/utility
:uiop/os :uiop/pathname :uiop/stream :uiop/filesystem :uiop/image
:uiop/run-program :uiop/lisp-build
:uiop/configuration :uiop/backward-driver))
+
+#+mkcl (provide :uiop)
;;;; -------------------------------------------------------------------------
;;;; Handle upgrade as forward- and backward-compatibly as possible
;; See https://bugs.launchpad.net/asdf/+bug/485687
-(asdf/package:define-package :asdf/upgrade
+(uiop/package:define-package :asdf/upgrade
(:recycle :asdf/upgrade :asdf)
(:use :uiop/common-lisp :uiop)
(:export
#:asdf-version #:*previous-asdf-versions* #:*asdf-version*
#:asdf-message #:*verbose-out*
- #:upgrading-p #:when-upgrading #:upgrade-asdf #:asdf-upgrade-error
+ #:upgrading-p #:when-upgrading #:upgrade-asdf #:asdf-upgrade-error #:defparameter*
#:*post-upgrade-cleanup-hook* #:*post-upgrade-restart-hook* #:cleanup-upgraded-asdf
;; There will be no symbol left behind!
#:intern*)
- (:import-from :asdf/package #:intern* #:find-symbol*))
+ (:import-from :uiop/package #:intern* #:find-symbol*))
(in-package :asdf/upgrade)
;;; Special magic to detect if this is an upgrade
@@ -6346,16 +6600,31 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
(string rev)
(cons (format nil "~{~D~^.~}" rev))
(null "1.0"))))))
+ ;; Important: define *p-a-v* /before/ *a-v* so that it initializes correctly.
+ (defvar *previous-asdf-versions* (if-let (previous (asdf-version)) (list previous)))
(defvar *asdf-version* nil)
- (defvar *previous-asdf-versions* nil)
+ ;; We need to clear systems from versions yet older than the below:
+ (defparameter *oldest-forward-compatible-asdf-version* "2.33") ;; 2.32.13 renames a slot in component.
(defvar *verbose-out* nil)
(defun asdf-message (format-string &rest format-args)
(when *verbose-out* (apply 'format *verbose-out* format-string format-args)))
(defvar *post-upgrade-cleanup-hook* ())
(defvar *post-upgrade-restart-hook* ())
- (defun upgrading-p ()
- (and *previous-asdf-versions* (not (equal *asdf-version* (first *previous-asdf-versions*)))))
- (defmacro when-upgrading ((&key (upgrading-p '(upgrading-p)) when) &body body)
+ (defun upgrading-p (&optional (oldest-compatible-version *oldest-forward-compatible-asdf-version*))
+ (and *previous-asdf-versions*
+ (version< (first *previous-asdf-versions*) oldest-compatible-version)))
+ (defmacro defparameter* (var value &optional docstring (version *oldest-forward-compatible-asdf-version*))
+ (let* ((name (string-trim "*" var))
+ (valfun (intern (format nil "%~A-~A-~A" :compute name :value))))
+ `(progn
+ (defun ,valfun () ,value)
+ (defvar ,var (,valfun) ,@(ensure-list docstring))
+ (when (upgrading-p ,version)
+ (setf ,var (,valfun))))))
+ (defmacro when-upgrading ((&key (version *oldest-forward-compatible-asdf-version*)
+ (upgrading-p `(upgrading-p ,version)) when) &body body)
+ "A wrapper macro for code that should only be run when upgrading a
+previously-loaded version of ASDF."
`(with-upgradability ()
(when (and ,upgrading-p ,@(when when `(,when)))
(handler-bind ((style-warning #'muffle-warning))
@@ -6363,13 +6632,13 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
(let* (;; For bug reporting sanity, please always bump this version when you modify this file.
;; Please also modify asdf.asd to reflect this change. make bump-version v=3.4.5.67.8
;; can help you do these changes in synch (look at the source for documentation).
- ;; Relying on its automation, the version is now redundantly present on top of this file.
+ ;; Relying on its automation, the version is now redundantly present on top of asdf.lisp.
;; "3.4" would be the general branch for major version 3, minor version 4.
;; "3.4.5" would be an official release in the 3.4 branch.
- ;; "3.4.5.67" would be a development version in the official upstream of 3.4.5.
+ ;; "3.4.5.67" would be a development version in the official branch, on top of 3.4.5.
;; "3.4.5.0.8" would be your eighth local modification of official release 3.4.5
;; "3.4.5.67.8" would be your eighth local modification of development version 3.4.5.67
- (asdf-version "3.0.3")
+ (asdf-version "3.1.2")
(existing-version (asdf-version)))
(setf *asdf-version* asdf-version)
(when (and existing-version (not (equal asdf-version existing-version)))
@@ -6381,47 +6650,39 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
(when-upgrading ()
(let ((redefined-functions ;; gf signature and/or semantics changed incompatibly. Oops.
+ ;; NB: it's too late to do anything about functions in UIOP!
+ ;; If you introduce some critically incompatibility there, you must change name.
'(#:component-relative-pathname #:component-parent-pathname ;; component
#:source-file-type
#:find-system #:system-source-file #:system-relative-pathname ;; system
- #:find-component ;; find-component
- #:explain #:perform #:perform-with-restarts #:input-files #:output-files ;; action
- #:component-depends-on #:operation-done-p #:component-depends-on
- #:traverse ;; backward-interface
- #:operate ;; operate
- #:parse-component-form ;; defsystem
- #:apply-output-translations ;; output-translations
- #:process-output-translations-directive
- #:inherit-source-registry #:process-source-registry ;; source-registry
- #:process-source-registry-directive
- #:trivial-system-p ;; bundle
- ;; NB: it's too late to do anything about uiop functions!
- ))
- (uninterned-symbols
- '(#:*asdf-revision* #:around #:asdf-method-combination
- #:split #:make-collector #:do-dep #:do-one-dep
- #:component-self-dependencies
- #:resolve-relative-location-component #:resolve-absolute-location-component
- #:output-files-for-system-and-operation))) ; obsolete ASDF-BINARY-LOCATION function
- (declare (ignorable redefined-functions uninterned-symbols))
- (loop :for name :in (append redefined-functions)
+ #:find-component ;; find-component
+ #:explain #:perform #:perform-with-restarts #:input-files #:output-files ;; action
+ #:component-depends-on #:operation-done-p #:component-depends-on
+ #:traverse ;; backward-interface
+ #:map-direct-dependencies #:reduce-direct-dependencies #:direct-dependencies ;; plan
+ #:operate ;; operate
+ #:parse-component-form ;; defsystem
+ #:apply-output-translations ;; output-translations
+ #:process-output-translations-directive
+ #:inherit-source-registry #:process-source-registry ;; source-registry
+ #:process-source-registry-directive
+ #:trivial-system-p)) ;; bundle
+ (redefined-classes
+ ;; redefining the classes causes interim circularities
+ ;; with the old ASDF during upgrade, and many implementations bork
+ '((#:compile-concatenated-source-op (#:operation) ()))))
+ (loop :for name :in redefined-functions
:for sym = (find-symbol* name :asdf nil) :do
(when sym
;; On CLISP we seem to be unable to fmakunbound and define a function in the same fasl. Sigh.
#-clisp (fmakunbound sym)))
- (loop :with asdf = (find-package :asdf)
- :for name :in uninterned-symbols
- :for sym = (find-symbol* name :asdf nil)
- :for base-pkg = (and sym (symbol-package sym)) :do
- (when sym
- (cond
- ((or (eq base-pkg asdf) (not base-pkg))
- (unintern* sym asdf)
- (intern* sym asdf))
- (t
- (unintern* sym base-pkg)
- (let ((new (intern* sym base-pkg)))
- (shadowing-import new asdf))))))))
+ (labels ((asym (x) (multiple-value-bind (s p) (if (consp x) (values (car x) (cadr x)) (values x :asdf))
+ (find-symbol* s p nil)))
+ (asyms (l) (mapcar #'asym l)))
+ (loop* :for (name superclasses slots) :in redefined-classes
+ :for sym = (find-symbol* name :asdf nil)
+ :when (and sym (find-class sym))
+ :do (eval `(defclass ,sym ,(asyms superclasses) ,(asyms slots)))))))
;;; Self-upgrade functions
@@ -6443,7 +6704,12 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
old-version new-version)
(asdf-message (compatfmt "~&~@<; ~@;Upgraded ASDF from version ~A to version ~A~@:>~%")
old-version new-version))
- (call-functions (reverse *post-upgrade-cleanup-hook*))
+ ;; In case the previous version was too old to be forward-compatible, clear systems.
+ ;; TODO: if needed, we may have to define a separate hook to run
+ ;; in case of forward-compatible upgrade.
+ ;; Or to move the tests forward-compatibility test inside each hook function?
+ (unless (version<= *oldest-forward-compatible-asdf-version* old-version)
+ (call-functions (reverse *post-upgrade-cleanup-hook*)))
t))))
(defun upgrade-asdf ()
@@ -6459,7 +6725,7 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
;;;; -------------------------------------------------------------------------
;;;; Components
-(asdf/package:define-package :asdf/component
+(uiop/package:define-package :asdf/component
(:recycle :asdf/component :asdf/defsystem :asdf/find-system :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade)
(:export
@@ -6492,9 +6758,9 @@ You can compare this string with e.g.: (ASDF:VERSION-SATISFIES (ASDF:ASDF-VERSIO
;; Internals we'd like to share with the ASDF package, especially for upgrade purposes
#:name #:version #:description #:long-description #:author #:maintainer #:licence
- #:components-by-name #:components
- #:children #:children-by-name #:default-component-class
- #:author #:maintainer #:licence #:source-file #:defsystem-depends-on
+ #:components-by-name #:components #:children #:children-by-name
+ #:default-component-class #:source-file
+ #:defsystem-depends-on ; This symbol retained for backward compatibility.
#:sideway-dependencies #:if-feature #:in-order-to #:inline-methods
#:relative-pathname #:absolute-pathname #:operation-times #:around-compile
#:%encoding #:properties #:component-properties #:parent))
@@ -6519,7 +6785,7 @@ another pathname in a degenerate way."))
(defgeneric component-version (component))
(defgeneric (setf component-version) (new-version component))
(defgeneric component-parent (component))
- (defmethod component-parent ((component null)) (declare (ignorable component)) nil)
+ (defmethod component-parent ((component null)) nil)
;; Backward compatible way of computing the FILE-TYPE of a component.
;; TODO: find users, have them stop using that, remove it for ASDF4.
@@ -6541,11 +6807,6 @@ another pathname in a degenerate way."))
(duplicate-names-name c))))))
-
-(when-upgrading (:when (find-class 'component nil))
- (defmethod reinitialize-instance :after ((c component) &rest initargs &key)
- (declare (ignorable c initargs)) (values)))
-
(with-upgradability ()
(defclass component ()
((name :accessor component-name :initarg :name :type string :documentation
@@ -6600,6 +6861,8 @@ another pathname in a degenerate way."))
:initarg :build-operation :initform nil :reader component-build-operation)))
(defun component-find-path (component)
+ "Return a path from a root system to the COMPONENT.
+The return value is a list of component NAMES; a list of strings."
(check-type component (or null component))
(reverse
(loop :for c = component :then (component-parent c)
@@ -6618,7 +6881,9 @@ another pathname in a degenerate way."))
;;;; Component hierarchy within a system
;; The tree typically but not necessarily follows the filesystem hierarchy.
(with-upgradability ()
- (defclass child-component (component) ())
+ (defclass child-component (component) ()
+ (:documentation "A CHILD-COMPONENT is a component that may be part of
+a PARENT-COMPONENT."))
(defclass file-component (child-component)
((type :accessor file-type :initarg :type))) ; no default
@@ -6647,7 +6912,9 @@ another pathname in a degenerate way."))
(default-component-class
:initform nil
:initarg :default-component-class
- :accessor module-default-component-class))))
+ :accessor module-default-component-class))
+ (:documentation "A PARENT-COMPONENT is a component that may have
+children.")))
(with-upgradability ()
(defun compute-children-by-name (parent &key only-if-needed-p)
@@ -6661,19 +6928,6 @@ another pathname in a degenerate way."))
(setf (gethash name hash) c))
hash))))
-(when-upgrading (:when (find-class 'module nil))
- (defmethod reinitialize-instance :after ((m module) &rest initargs &key)
- (declare (ignorable m initargs)) (values))
- (defmethod update-instance-for-redefined-class :after
- ((m module) added deleted plist &key)
- (declare (ignorable m added deleted plist))
- (when (and (member 'children added) (member 'components deleted))
- (setf (slot-value m 'children)
- ;; old ECLs provide an alist instead of a plist(!)
- (if (or #+ecl (consp (first plist))) (or #+ecl (cdr (assoc 'components plist)))
- (getf plist 'components)))
- (compute-children-by-name m))))
-
(with-upgradability ()
(defclass module (child-component parent-component)
(#+clisp (components)))) ;; backward compatibility during upgrade only
@@ -6699,9 +6953,10 @@ another pathname in a degenerate way."))
pathname)))
(defmethod component-relative-pathname ((component component))
- ;; source-file-type is backward-compatibility with ASDF1;
- ;; we ought to be able to extract this from the component alone with COMPONENT-TYPE.
- ;; TODO: track who uses it, and have them not use it anymore.
+ ;; SOURCE-FILE-TYPE below is strictly for backward-compatibility with ASDF1.
+ ;; We ought to be able to extract this from the component alone with COMPONENT-TYPE.
+ ;; TODO: track who uses it, and have them not use it anymore;
+ ;; maybe issue a WARNING (then eventually CERROR) if the two methods diverge?
(parse-unix-namestring
(or (and (slot-boundp component 'relative-pathname)
(slot-value component 'relative-pathname))
@@ -6710,12 +6965,10 @@ another pathname in a degenerate way."))
:type (source-file-type component (component-system component))
:defaults (component-parent-pathname component)))
- (defmethod source-file-type ((component parent-component) system)
- (declare (ignorable component system))
+ (defmethod source-file-type ((component parent-component) (system parent-component))
:directory)
- (defmethod source-file-type ((component file-component) system)
- (declare (ignorable system))
+ (defmethod source-file-type ((component file-component) (system parent-component))
(file-type component)))
@@ -6743,11 +6996,15 @@ another pathname in a degenerate way."))
;;;; version-satisfies
(with-upgradability ()
+ ;; short-circuit testing of null version specifications.
+ ;; this is an all-pass, without warning
+ (defmethod version-satisfies :around ((c t) (version null))
+ t)
(defmethod version-satisfies ((c component) version)
- (unless (and version (slot-boundp c 'version))
+ (unless (and version (slot-boundp c 'version) (component-version c))
(when version
- (warn "Requested version ~S but component ~S has no version" version c))
- (return-from version-satisfies t))
+ (warn "Requested version ~S but ~S has no version" version c))
+ (return-from version-satisfies nil))
(version-satisfies (component-version c) version))
(defmethod version-satisfies ((cver string) version)
@@ -6769,7 +7026,7 @@ another pathname in a degenerate way."))
;;;; -------------------------------------------------------------------------
;;;; Systems
-(asdf/package:define-package :asdf/system
+(uiop/package:define-package :asdf/system
(:recycle :asdf :asdf/system)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/component)
(:export
@@ -6778,7 +7035,7 @@ another pathname in a degenerate way."))
#:reset-system
#:system-description #:system-long-description
#:system-author #:system-maintainer #:system-licence #:system-license
- #:system-defsystem-depends-on
+ #:system-defsystem-depends-on #:system-depends-on #:system-weakly-depends-on
#:component-build-pathname #:build-pathname
#:component-entry-point #:entry-point
#:homepage #:system-homepage
@@ -6791,13 +7048,12 @@ another pathname in a degenerate way."))
(with-upgradability ()
(defgeneric* (find-system) (system &optional error-p))
- (defgeneric* (system-source-file) (system)
+ (defgeneric* (system-source-file :supersede #-clisp t #+clisp nil) (system)
(:documentation "Return the source file in which system is defined."))
(defgeneric component-build-pathname (component))
(defgeneric component-entry-point (component))
(defmethod component-entry-point ((c component))
- (declare (ignorable c))
nil))
@@ -6831,7 +7087,11 @@ another pathname in a degenerate way."))
(entry-point
:initform nil :initarg :entry-point :accessor component-entry-point)
(source-file :initform nil :initarg :source-file :accessor system-source-file)
- (defsystem-depends-on :reader system-defsystem-depends-on :initarg :defsystem-depends-on)))
+ (defsystem-depends-on :reader system-defsystem-depends-on :initarg :defsystem-depends-on
+ :initform nil)
+ ;; these two are specially set in parse-component-form, so have no :INITARGs.
+ (depends-on :reader system-depends-on :initform nil)
+ (weakly-depends-on :reader system-weakly-depends-on :initform nil)))
(defun reset-system (system &rest keys &key &allow-other-keys)
(change-class (change-class system 'proto-system) 'system)
@@ -6874,16 +7134,16 @@ in which the system specification (.asd file) is located."
(system-source-directory system))
(defmethod component-build-pathname ((c component))
- (declare (ignorable c))
nil))
;;;; -------------------------------------------------------------------------
;;;; Stamp cache
-(asdf/package:define-package :asdf/cache
+(uiop/package:define-package :asdf/cache
(:use :uiop/common-lisp :uiop :asdf/upgrade)
(:export #:get-file-stamp #:compute-file-stamp #:register-file-stamp
- #:consult-asdf-cache #:do-asdf-cache #:normalize-namestring
+ #:set-asdf-cache-entry #:unset-asdf-cache-entry #:consult-asdf-cache
+ #:do-asdf-cache #:normalize-namestring
#:call-with-asdf-cache #:with-asdf-cache #:*asdf-cache*))
(in-package :asdf/cache)
@@ -6901,6 +7161,10 @@ in which the system specification (.asd file) is located."
(setf (gethash key *asdf-cache*) value-list)
value-list)))
+ (defun unset-asdf-cache-entry (key)
+ (when *asdf-cache*
+ (remhash key *asdf-cache*)))
+
(defun consult-asdf-cache (key &optional thunk)
(if *asdf-cache*
(multiple-value-bind (results foundp) (gethash key *asdf-cache*)
@@ -6912,14 +7176,15 @@ in which the system specification (.asd file) is located."
(defmacro do-asdf-cache (key &body body)
`(consult-asdf-cache ,key #'(lambda () , at body)))
- (defun call-with-asdf-cache (thunk &key override)
- (if (and *asdf-cache* (not override))
- (funcall thunk)
- (let ((*asdf-cache* (make-hash-table :test 'equal)))
- (funcall thunk))))
+ (defun call-with-asdf-cache (thunk &key override key)
+ (let ((fun (if key #'(lambda () (consult-asdf-cache key thunk)) thunk)))
+ (if (and *asdf-cache* (not override))
+ (funcall fun)
+ (let ((*asdf-cache* (make-hash-table :test 'equal)))
+ (funcall fun)))))
- (defmacro with-asdf-cache ((&key override) &body body)
- `(call-with-asdf-cache #'(lambda () , at body) :override ,override))
+ (defmacro with-asdf-cache ((&key key override) &body body)
+ `(call-with-asdf-cache #'(lambda () , at body) :override ,override :key ,key))
(defun normalize-namestring (pathname)
(let ((resolved (resolve-symlinks*
@@ -6938,30 +7203,32 @@ in which the system specification (.asd file) is located."
(set-asdf-cache-entry `(get-file-stamp ,namestring) (list stamp))))
(defun get-file-stamp (file)
- (let ((namestring (normalize-namestring file)))
- (do-asdf-cache `(get-file-stamp ,namestring) (compute-file-stamp namestring)))))
+ (when file
+ (let ((namestring (normalize-namestring file)))
+ (do-asdf-cache `(get-file-stamp ,namestring) (compute-file-stamp namestring))))))
;;;; -------------------------------------------------------------------------
;;;; Finding systems
-(asdf/package:define-package :asdf/find-system
+(uiop/package:define-package :asdf/find-system
(:recycle :asdf/find-system :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
- :asdf/component :asdf/system :asdf/cache)
+ :asdf/cache :asdf/component :asdf/system)
(:export
#:remove-entry-from-registry #:coerce-entry-to-directory
#:coerce-name #:primary-system-name #:coerce-filename
- #:find-system #:locate-system #:load-asd #:with-system-definitions
+ #:find-system #:locate-system #:load-asd
#:system-registered-p #:register-system #:registered-systems #:clear-system #:map-systems
#:missing-component #:missing-requires #:missing-parent
#:formatted-system-definition-error #:format-control #:format-arguments #:sysdef-error
#:load-system-definition-error #:error-name #:error-pathname #:error-condition
#:*system-definition-search-functions* #:search-for-system-definition
#:*central-registry* #:probe-asd #:sysdef-central-registry-search
- #:find-system-if-being-defined #:*systems-being-defined*
+ #:find-system-if-being-defined
#:contrib-sysdef-search #:sysdef-find-asdf ;; backward compatibility symbols, functions removed
#:sysdef-preloaded-system-search #:register-preloaded-system #:*preloaded-systems*
- #:clear-defined-systems #:*defined-systems*
+ #:clear-defined-system #:clear-defined-systems #:*defined-systems*
+ #:*immutable-systems*
;; defined in source-registry, but specially mentioned here:
#:initialize-source-registry #:sysdef-source-registry-search))
(in-package :asdf/find-system)
@@ -7031,15 +7298,18 @@ of which is a system object.")
(get-file-stamp file))
system)))))
+ (defun clear-defined-system (system)
+ (let ((name (coerce-name system)))
+ (remhash name *defined-systems*)
+ (unset-asdf-cache-entry `(locate-system ,name))
+ (unset-asdf-cache-entry `(find-system ,name))
+ nil))
+
(defun clear-defined-systems ()
;; Invalidate all systems but ASDF itself, if registered.
- (let ((asdf (cdr (system-registered-p :asdf))))
- (setf *defined-systems* (make-hash-table :test 'equal))
- (when asdf
- (setf (component-version asdf) *asdf-version*)
- (setf (builtin-system-p asdf) t)
- (register-system asdf)))
- (values))
+ (loop :for name :being :the :hash-keys :of *defined-systems*
+ :unless (equal name "asdf")
+ :do (clear-defined-system name)))
(register-hook-function '*post-upgrade-cleanup-hook* 'clear-defined-systems nil)
@@ -7080,12 +7350,12 @@ called with an object of type asdf:system."
(cleanup-system-definition-search-functions)
(defun search-for-system-definition (system)
- (block ()
- (let ((name (coerce-name system)))
- (flet ((try (f) (if-let ((x (funcall f name))) (return x))))
- (try 'find-system-if-being-defined)
- (map () #'try *system-definition-search-functions*)
- (try 'sysdef-preloaded-system-search)))))
+ (let ((name (coerce-name system)))
+ (flet ((try (f) (if-let ((x (funcall f name))) (return-from search-for-system-definition x))))
+ (try 'find-system-if-being-defined)
+ (try 'sysdef-immutable-system-search)
+ (map () #'try *system-definition-search-functions*)
+ (try 'sysdef-preloaded-system-search))))
(defvar *central-registry* nil
"A list of 'system directory designators' ASDF uses to find systems.
@@ -7120,9 +7390,7 @@ Going forward, we recommend new users should be using the source-registry.
:name (strcat name ".asd")
:type "lnk")))
(when (probe-file* shortcut)
- (let ((target (parse-windows-shortcut shortcut)))
- (when target
- (return (pathname target))))))))))
+ (ensure-pathname (parse-windows-shortcut shortcut) :namestring :native)))))))
(defun sysdef-central-registry-search (system)
(let ((name (primary-system-name system))
@@ -7187,45 +7455,24 @@ Going forward, we recommend new users should be using the source-registry.
(defun register-preloaded-system (system-name &rest keys)
(setf (gethash (coerce-name system-name) *preloaded-systems*) keys))
- (register-preloaded-system "asdf" :version *asdf-version*)
- (register-preloaded-system "uiop" :version *asdf-version*)
- (register-preloaded-system "asdf-driver" :version *asdf-version*)
- (register-preloaded-system "asdf-defsystem" :version *asdf-version*)
+ (dolist (s '("asdf" "uiop" "asdf-driver" "asdf-defsystem" "asdf-package-system"))
+ ;; don't bother with these, no one relies on them: "asdf-utils" "asdf-bundle"
+ (register-preloaded-system s :version *asdf-version*))
(defmethod find-system ((name null) &optional (error-p t))
- (declare (ignorable name))
(when error-p
(sysdef-error (compatfmt "~@<NIL is not a valid system name~@:>"))))
(defmethod find-system (name &optional (error-p t))
(find-system (coerce-name name) error-p))
- (defvar *systems-being-defined* nil
- "A hash-table of systems currently being defined keyed by name, or NIL")
-
(defun find-system-if-being-defined (name)
- (when *systems-being-defined*
- ;; notable side effect: mark the system as being defined, to avoid infinite loops
- (ensure-gethash (coerce-name name) *systems-being-defined* nil)))
-
- (defun call-with-system-definitions (thunk)
- (if *systems-being-defined*
- (call-with-asdf-cache thunk)
- (let ((*systems-being-defined* (make-hash-table :test 'equal)))
- (call-with-asdf-cache thunk))))
-
- (defun clear-systems-being-defined ()
- (when *systems-being-defined*
- (clrhash *systems-being-defined*)))
-
- (register-hook-function '*post-upgrade-cleanup-hook* 'clear-systems-being-defined)
-
- (defmacro with-system-definitions ((&optional) &body body)
- `(call-with-system-definitions #'(lambda () , at body)))
+ ;; notable side effect: mark the system as being defined, to avoid infinite loops
+ (first (gethash `(find-system ,(coerce-name name)) *asdf-cache*)))
(defun load-asd (pathname &key name (external-format (encoding-external-format (detect-encoding pathname))) &aux (readtable *readtable*) (print-pprint-dispatch *print-pprint-dispatch*))
;; Tries to load system definition with canonical NAME from PATHNAME.
- (with-system-definitions ()
+ (with-asdf-cache ()
(with-standard-io-syntax
(let ((*package* (find-package :asdf-user))
;; Note that our backward-compatible *readtable* is
@@ -7245,8 +7492,7 @@ Going forward, we recommend new users should be using the source-registry.
:condition condition))))
(asdf-message (compatfmt "~&~@<; ~@;Loading system definition~@[ for ~A~] from ~A~@:>~%")
name pathname)
- (with-muffled-loader-conditions ()
- (load* pathname :external-format external-format)))))))
+ (load* pathname :external-format external-format))))))
(defvar *old-asdf-systems* (make-hash-table :test 'equal))
@@ -7257,14 +7503,17 @@ Going forward, we recommend new users should be using the source-registry.
(version (and (probe-file* version-pathname :truename nil)
(read-file-form version-pathname)))
(old-version (asdf-version)))
- (or (version<= old-version version)
- (ensure-gethash
- (list pathname old-version) *old-asdf-systems*
- #'(lambda ()
- (let ((old-pathname
- (if-let (pair (system-registered-p "asdf"))
- (system-source-file (cdr pair)))))
- (warn "~@<~
+ (cond
+ ((version< old-version version) t) ;; newer version: good!
+ ((equal old-version version) nil) ;; same version: don't load, but don't warn
+ (t ;; old version: bad
+ (ensure-gethash
+ (list (namestring pathname) version) *old-asdf-systems*
+ #'(lambda ()
+ (let ((old-pathname
+ (if-let (pair (system-registered-p "asdf"))
+ (system-source-file (cdr pair)))))
+ (warn "~@<~
You are using ASDF version ~A ~:[(probably from (require \"asdf\") ~
or loaded by quicklisp)~;from ~:*~S~] and have an older version of ASDF ~
~:[(and older than 2.27 at that)~;~:*~A~] registered at ~S. ~
@@ -7286,8 +7535,27 @@ Going forward, we recommend new users should be using the source-registry.
then you might indeed want to either install and register a more recent version, ~
or use :ignore-inherited-configuration to avoid registering the old one. ~
Please consult ASDF documentation and/or experts.~@:>~%"
- old-version old-pathname version pathname)
- t)))))))
+ old-version old-pathname version pathname))))
+ nil))))) ;; only issue the warning the first time, but always return nil
+
+ (defvar *immutable-systems* nil
+ "An hash-set (equal hash-table mapping keys to T) of systems that are immutable,
+i.e. already loaded in memory and not to be refreshed from the filesystem.
+They will be treated specially by find-system, and passed as :force-not argument to make-plan.
+
+If you deliver an image with many systems precompiled, *and* do not want to check the filesystem
+for them every time a user loads an extension, what more risk a problematic upgrade or catastrophic
+downgrade, before you dump an image, use:
+ (setf asdf::*immutable-systems* (uiop:list-to-hash-set (asdf:already-loaded-systems)))")
+
+ (defun sysdef-immutable-system-search (requested)
+ (let ((name (coerce-name requested)))
+ (when (and *immutable-systems* (gethash name *immutable-systems*))
+ (or (cdr (system-registered-p requested))
+ (error 'formatted-system-definition-error
+ :format-control "Requested system ~A is in the *immutable-systems* set, ~
+but not loaded in memory"
+ :format-arguments (list name))))))
(defun locate-system (name)
"Given a system NAME designator, try to locate where to load the system from.
@@ -7299,39 +7567,43 @@ PATHNAME when not null is a path from where to load the system,
either associated with FOUND-SYSTEM, or with the PREVIOUS system.
PREVIOUS when not null is a previously loaded SYSTEM object of same name.
PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded."
- (let* ((name (coerce-name name))
- (in-memory (system-registered-p name)) ; load from disk if absent or newer on disk
- (previous (cdr in-memory))
- (previous (and (typep previous 'system) previous))
- (previous-time (car in-memory))
- (found (search-for-system-definition name))
- (found-system (and (typep found 'system) found))
- (pathname (ensure-pathname
- (or (and (typep found '(or pathname string)) (pathname found))
- (and found-system (system-source-file found-system))
- (and previous (system-source-file previous)))
- :want-absolute t :resolve-symlinks *resolve-symlinks*))
- (foundp (and (or found-system pathname previous) t)))
- (check-type found (or null pathname system))
- (unless (check-not-old-asdf-system name pathname)
- (cond
- (previous (setf found nil pathname nil))
- (t
- (setf found (sysdef-preloaded-system-search "asdf"))
- (assert (typep found 'system))
- (setf found-system found pathname nil))))
- (values foundp found-system pathname previous previous-time)))
+ (with-asdf-cache (:key `(locate-system ,name))
+ (let* ((name (coerce-name name))
+ (in-memory (system-registered-p name)) ; load from disk if absent or newer on disk
+ (previous (cdr in-memory))
+ (previous (and (typep previous 'system) previous))
+ (previous-time (car in-memory))
+ (found (search-for-system-definition name))
+ (found-system (and (typep found 'system) found))
+ (pathname (ensure-pathname
+ (or (and (typep found '(or pathname string)) (pathname found))
+ (and found-system (system-source-file found-system))
+ (and previous (system-source-file previous)))
+ :want-absolute t :resolve-symlinks *resolve-symlinks*))
+ (foundp (and (or found-system pathname previous) t)))
+ (check-type found (or null pathname system))
+ (unless (check-not-old-asdf-system name pathname)
+ (cond
+ (previous (setf found nil pathname nil))
+ (t
+ (setf found (sysdef-preloaded-system-search "asdf"))
+ (assert (typep found 'system))
+ (setf found-system found pathname nil))))
+ (values foundp found-system pathname previous previous-time))))
(defmethod find-system ((name string) &optional (error-p t))
- (with-system-definitions ()
+ (with-asdf-cache (:key `(find-system ,name))
(let ((primary-name (primary-system-name name)))
- (unless (or (equal name primary-name)
- (nth-value 1 (gethash primary-name *systems-being-defined*)))
+ (unless (equal name primary-name)
(find-system primary-name nil)))
(loop
(restart-case
(multiple-value-bind (foundp found-system pathname previous previous-time)
(locate-system name)
+ (when (and found-system (eq found-system previous)
+ (or (first (gethash `(find-system ,name) *asdf-cache*))
+ (and *immutable-systems* (gethash name *immutable-systems*))))
+ (return found-system))
(assert (eq foundp (and (or found-system pathname previous) t)))
(let ((previous-pathname (and previous (system-source-file previous)))
(system (or previous found-system)))
@@ -7363,14 +7635,15 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(reinitialize-source-registry-and-retry ()
:report (lambda (s)
(format s (compatfmt "~@<Retry finding system ~A after reinitializing the source-registry.~@:>") name))
+ (unset-asdf-cache-entry `(locate-system ,name))
(initialize-source-registry)))))))
;;;; -------------------------------------------------------------------------
;;;; Finding components
-(asdf/package:define-package :asdf/find-component
+(uiop/package:define-package :asdf/find-component
(:recycle :asdf/find-component :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade
+ (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
:asdf/component :asdf/system :asdf/find-system)
(:export
#:find-component
@@ -7446,8 +7719,7 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(defmethod find-component ((c component) (name cons))
(find-component (find-component c (car name)) (cdr name)))
- (defmethod find-component (base (actual component))
- (declare (ignorable base))
+ (defmethod find-component ((base t) (actual component))
actual)
(defun resolve-dependency-name (component name &optional version)
@@ -7474,7 +7746,12 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(or (null c)
(and (typep c 'missing-dependency)
(eq (missing-required-by c) component)
- (equal (missing-requires c) name))))))))
+ (equal (missing-requires c) name))))
+ (unless (component-parent component)
+ (let ((name (coerce-name name)))
+ (unset-asdf-cache-entry `(find-system ,name))
+ (unset-asdf-cache-entry `(locate-system ,name))))))))
+
(defun resolve-dependency-spec (component dep-spec)
(let ((component (find-component () component)))
@@ -7487,41 +7764,42 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(cons combinator arguments) component))
(defmethod resolve-dependency-combination (component (combinator (eql :feature)) arguments)
- (declare (ignorable combinator))
(when (featurep (first arguments))
(resolve-dependency-spec component (second arguments))))
(defmethod resolve-dependency-combination (component (combinator (eql :version)) arguments)
- (declare (ignorable combinator)) ;; See https://bugs.launchpad.net/asdf/+bug/527788
- (resolve-dependency-name component (first arguments) (second arguments))))
+ (resolve-dependency-name component (first arguments) (second arguments)))) ;; See lp#527788
;;;; -------------------------------------------------------------------------
;;;; Operations
-(asdf/package:define-package :asdf/operation
+(uiop/package:define-package :asdf/operation
(:recycle :asdf/operation :asdf/action :asdf) ;; asdf/action for FEATURE pre 2.31.5.
- (:use :uiop/common-lisp :uiop :asdf/upgrade)
+ (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/find-system)
(:export
#:operation
#:operation-original-initargs #:original-initargs ;; backward-compatibility only. DO NOT USE.
- #:build-op ;; THE generic operation
- #:*operations* #:make-operation #:find-operation #:feature))
+ #:*operations* #:make-operation #:find-operation
+ #:feature)) ;; TODO: stop exporting the deprecated FEATURE feature.
(in-package :asdf/operation)
;;; Operation Classes
(when-upgrading (:when (find-class 'operation nil))
- (defmethod shared-initialize :after ((o operation) slot-names &rest initargs &key)
- (declare (ignorable o slot-names initargs)) (values)))
+ ;; override any obsolete shared-initialize method when upgrading from ASDF2.
+ (defmethod shared-initialize :after ((o operation) (slot-names t) &key)
+ (values)))
(with-upgradability ()
(defclass operation ()
((original-initargs ;; for backward-compat -- used by GBBopen and swank (via operation-forced)
:initform nil :initarg :original-initargs :accessor operation-original-initargs)))
+ ;; Cache a copy of the INITARGS in the ORIGINAL-INITARGS slot, if that slot is not
+ ;; already bound.
(defmethod initialize-instance :after ((o operation) &rest initargs
&key force force-not system verbose &allow-other-keys)
- (declare (ignorable force force-not system verbose))
+ (declare (ignore force force-not system verbose))
(unless (slot-boundp o 'original-initargs)
(setf (operation-original-initargs o) initargs)))
@@ -7533,32 +7811,31 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
;;; make-operation, find-operation
(with-upgradability ()
- (defparameter *operations* (make-hash-table :test 'equal))
+ (defparameter* *operations* (make-hash-table :test 'equal))
+
(defun make-operation (operation-class &rest initargs)
- (ensure-gethash (cons operation-class initargs) *operations*
- (list* 'make-instance operation-class initargs)))
+ (let ((class (coerce-class operation-class
+ :package :asdf/interface :super 'operation :error 'sysdef-error)))
+ (ensure-gethash (cons class initargs) *operations*
+ (list* 'make-instance class initargs))))
(defgeneric find-operation (context spec)
(:documentation "Find an operation by resolving the SPEC in the CONTEXT"))
- (defmethod find-operation (context (spec operation))
- (declare (ignorable context))
+ (defmethod find-operation ((context t) (spec operation))
spec)
(defmethod find-operation (context (spec symbol))
- (unless (member spec '(nil feature))
- ;; NIL designates itself, i.e. absence of operation
- ;; FEATURE is the ASDF1 misfeature that comes with IF-COMPONENT-DEP-FAILS
+ (when spec ;; NIL designates itself, i.e. absence of operation
(apply 'make-operation spec (operation-original-initargs context))))
+ (defmethod find-operation (context (spec string))
+ (apply 'make-operation spec (operation-original-initargs context)))
(defmethod operation-original-initargs ((context symbol))
(declare (ignorable context))
- nil)
-
- (defclass build-op (operation) ()))
-
+ nil))
;;;; -------------------------------------------------------------------------
;;;; Actions
-(asdf/package:define-package :asdf/action
+(uiop/package:define-package :asdf/action
(:nicknames :asdf-action)
(:recycle :asdf/action :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
@@ -7566,18 +7843,26 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
(:export
#:action #:define-convenience-action-methods
#:explain #:action-description
- #:downward-operation #:upward-operation #:sideway-operation #:selfward-operation
+ #:downward-operation #:upward-operation #:sideway-operation #:selfward-operation #:non-propagating-operation
#:component-depends-on
#:input-files #:output-files #:output-file #:operation-done-p
#:action-status #:action-stamp #:action-done-p
#:component-operation-time #:mark-operation-done #:compute-action-stamp
#:perform #:perform-with-restarts #:retry #:accept
#:traverse-actions #:traverse-sub-actions #:required-components ;; in plan
- #:action-path #:find-action #:stamp #:done-p))
+ #:action-path #:find-action #:stamp #:done-p
+ #:operation-definition-warning #:operation-definition-error ;; condition
+ ))
(in-package :asdf/action)
-(eval-when (#-lispworks :compile-toplevel :load-toplevel :execute)
- (deftype action () '(cons operation component))) ;; a step to be performed while building
+(eval-when (#-lispworks :compile-toplevel :load-toplevel :execute) ;; LispWorks issues spurious warning
+ (deftype action () '(cons operation component)) ;; a step to be performed while building
+
+ (deftype operation-designator ()
+ ;; an operation designates itself,
+ ;; nil designates a context-dependent current operation, and
+ ;; class-name or class designates an instance of the designated class.
+ '(or operation null symbol class)))
(with-upgradability ()
(defgeneric traverse-actions (actions &key &allow-other-keys))
@@ -7614,7 +7899,10 @@ PREVIOUS-TIME when not null is the time at which the PREVIOUS system was loaded.
`(apply ',function , at prefix ,o ,c , at suffix ,rest)
`(,function , at prefix ,o ,c , at suffix))))
`(progn
- (defmethod ,function (, at prefix (,operation symbol) component , at suffix , at more-args)
+ (defmethod ,function (, at prefix (,operation string) ,component , at suffix , at more-args)
+ (let ((,component (find-component () ,component))) ;; do it first, for defsystem-depends-on
+ ,(next-method `(safe-read-from-string ,operation :package :asdf/interface) component)))
+ (defmethod ,function (, at prefix (,operation symbol) ,component , at suffix , at more-args)
(if ,operation
,(next-method
(if operation-initargs ;backward-compatibility with ASDF1's operate. Yuck.
@@ -7663,11 +7951,12 @@ You can put together sentences using this phrase."))
and each <component> is a component designator with respect to
FIND-COMPONENT in the context of the COMPONENT argument,
and means that the component depends on
- <operation> having been performed on each <component>; or
+ <operation> having been performed on each <component>;
- (FEATURE <feature>), which means that the component depends
- on the <feature> expression satisfying FEATUREP.
- (This is DEPRECATED -- use :IF-FEATURE instead.)
+ [Note: an <operation> is an operation designator -- it can be either an
+ operation name or an operation object. Similarly, a <component> may be
+ a component name or a component object. Also note that, the degenerate
+ case of (<operation>) is a no-op.]
Methods specialized on subclasses of existing component types
should usually append the results of CALL-NEXT-METHOD to the list."))
@@ -7675,54 +7964,132 @@ You can put together sentences using this phrase."))
(defmethod component-depends-on :around ((o operation) (c component))
(do-asdf-cache `(component-depends-on ,o ,c)
- (call-next-method)))
-
- (defmethod component-depends-on ((o operation) (c component))
- (cdr (assoc (type-of o) (component-in-order-to c))))) ; User-specified in-order dependencies
+ (call-next-method))))
-;;;; upward-operation, downward-operation
-;; These together handle actions that propagate along the component hierarchy.
-;; Downward operations like load-op or compile-op propagate down the hierarchy:
-;; operation on a parent depends-on operation on its children.
-;; By default, an operation propagates itself, but it may propagate another one instead.
+;;;; upward-operation, downward-operation, sideway-operation, selfward-operation
+;; These together handle actions that propagate along the component hierarchy or operation universe.
(with-upgradability ()
(defclass downward-operation (operation)
((downward-operation
- :initform nil :initarg :downward-operation :reader downward-operation :allocation :class)))
+ :initform nil :reader downward-operation
+ :type operation-designator :allocation :class))
+ (:documentation "A DOWNWARD-OPERATION's dependencies propagate down the component hierarchy.
+I.e., if O is a DOWNWARD-OPERATION and its DOWNWARD-OPERATION slot designates operation D, then
+the action (O . M) of O on module M will depends on each of (D . C) for each child C of module M.
+The default value for slot DOWNWARD-OPERATION is NIL, which designates the operation O itself.
+E.g. in order for a MODULE to be loaded with LOAD-OP (resp. compiled with COMPILE-OP), all the
+children of the MODULE must have been loaded with LOAD-OP (resp. compiled with COMPILE-OP."))
+ (defun downward-operation-depends-on (o c)
+ `((,(or (downward-operation o) o) ,@(component-children c))))
(defmethod component-depends-on ((o downward-operation) (c parent-component))
- `((,(or (downward-operation o) o) ,@(component-children c)) ,@(call-next-method)))
- ;; Upward operations like prepare-op propagate up the component hierarchy:
- ;; operation on a child depends-on operation on its parent.
- ;; By default, an operation propagates itself, but it may propagate another one instead.
+ `(,@(downward-operation-depends-on o c) ,@(call-next-method)))
+
(defclass upward-operation (operation)
((upward-operation
- :initform nil :initarg :downward-operation :reader upward-operation :allocation :class)))
+ :initform nil :reader upward-operation
+ :type operation-designator :allocation :class))
+ (:documentation "An UPWARD-OPERATION has dependencies that propagate up the component hierarchy.
+I.e., if O is an instance of UPWARD-OPERATION, and its UPWARD-OPERATION slot designates operation U,
+then the action (O . C) of O on a component C that has the parent P will depends on (U . P).
+The default value for slot UPWARD-OPERATION is NIL, which designates the operation O itself.
+E.g. in order for a COMPONENT to be prepared for loading or compiling with PREPARE-OP, its PARENT
+must first be prepared for loading or compiling with PREPARE-OP."))
;; For backward-compatibility reasons, a system inherits from module and is a child-component
;; so we must guard against this case. ASDF4: remove that.
+ (defun upward-operation-depends-on (o c)
+ (if-let (p (component-parent c)) `((,(or (upward-operation o) o) ,p))))
(defmethod component-depends-on ((o upward-operation) (c child-component))
- `(,@(if-let (p (component-parent c))
- `((,(or (upward-operation o) o) ,p))) ,@(call-next-method)))
- ;; Sibling operations propagate to siblings in the component hierarchy:
- ;; operation on a child depends-on operation on its parent.
- ;; By default, an operation propagates itself, but it may propagate another one instead.
+ `(,@(upward-operation-depends-on o c) ,@(call-next-method)))
+
(defclass sideway-operation (operation)
((sideway-operation
- :initform nil :initarg :sideway-operation :reader sideway-operation :allocation :class)))
+ :initform nil :reader sideway-operation
+ :type operation-designator :allocation :class))
+ (:documentation "A SIDEWAY-OPERATION has dependencies that propagate \"sideway\" to siblings
+that a component depends on. I.e. if O is a SIDEWAY-OPERATION, and its SIDEWAY-OPERATION slot
+designates operation S (where NIL designates O itself), then the action (O . C) of O on component C
+depends on each of (S . D) where D is a declared dependency of C.
+E.g. in order for a COMPONENT to be prepared for loading or compiling with PREPARE-OP,
+each of its declared dependencies must first be loaded as by LOAD-OP."))
+ (defun sideway-operation-depends-on (o c)
+ `((,(or (sideway-operation o) o) ,@(component-sideway-dependencies c))))
(defmethod component-depends-on ((o sideway-operation) (c component))
- `((,(or (sideway-operation o) o)
- ,@(loop :for dep :in (component-sideway-dependencies c)
- :collect (resolve-dependency-spec c dep)))
- ,@(call-next-method)))
- ;; Selfward operations propagate to themselves a sub-operation:
- ;; they depend on some other operation being acted on the same component.
+ `(,@(sideway-operation-depends-on o c) ,@(call-next-method)))
+
(defclass selfward-operation (operation)
((selfward-operation
- :initform nil :initarg :selfward-operation :reader selfward-operation :allocation :class)))
+ ;; NB: no :initform -- if an operation depends on others, it must explicitly specify which
+ :type (or operation-designator list) :reader selfward-operation :allocation :class))
+ (:documentation "A SELFWARD-OPERATION depends on another operation on the same component.
+I.e., if O is a SELFWARD-OPERATION, and its SELFWARD-OPERATION designates a list of operations L,
+then the action (O . C) of O on component C depends on each (S . C) for S in L.
+E.g. before a component may be loaded by LOAD-OP, it must have been compiled by COMPILE-OP.
+A operation-designator designates a singleton list of the designated operation;
+a list of operation-designators designates the list of designated operations;
+NIL is not a valid operation designator in that context. Note that any dependency
+ordering between the operations in a list of SELFWARD-OPERATION should be specified separately
+in the respective operation's COMPONENT-DEPENDS-ON methods so that they be scheduled properly."))
+ (defun selfward-operation-depends-on (o c)
+ (loop :for op :in (ensure-list (selfward-operation o)) :collect `(,op ,c)))
(defmethod component-depends-on ((o selfward-operation) (c component))
- `(,@(loop :for op :in (ensure-list (selfward-operation o))
- :collect `(,op ,c))
- ,@(call-next-method))))
+ `(,@(selfward-operation-depends-on o c) ,@(call-next-method)))
+
+ (defclass non-propagating-operation (operation)
+ ()
+ (:documentation "A NON-PROPAGATING-OPERATION is an operation that propagates
+no dependencies whatsoever. It is supplied in order that the programmer be able
+to specify that s/he is intentionally specifying an operation which invokes no
+dependencies.")))
+
+
+;;;---------------------------------------------------------------------------
+;;; Help programmers catch obsolete OPERATION subclasses
+;;;---------------------------------------------------------------------------
+(with-upgradability ()
+ (define-condition operation-definition-warning (simple-warning)
+ ()
+ (:documentation "Warning condition related to definition of obsolete OPERATION objects."))
+
+ (define-condition operation-definition-error (simple-error)
+ ()
+ (:documentation "Error condition related to definition of incorrect OPERATION objects."))
+
+ (defmethod initialize-instance :before ((o operation) &key)
+ (unless (typep o '(or downward-operation upward-operation sideway-operation
+ selfward-operation non-propagating-operation))
+ (warn 'operation-definition-warning
+ :format-control
+ "No dependency propagating scheme specified for operation class ~S.
+The class needs to be updated for ASDF 3.1 and specify appropriate propagation mixins."
+ :format-arguments (list (type-of o)))))
+
+ (defmethod initialize-instance :before ((o non-propagating-operation) &key)
+ (when (typep o '(or downward-operation upward-operation sideway-operation selfward-operation))
+ (error 'operation-definition-error
+ :format-control
+ "Inconsistent class: ~S
+ NON-PROPAGATING-OPERATION is incompatible with propagating operation classes as superclasses."
+ :format-arguments
+ (list (type-of o)))))
+
+ (defmethod component-depends-on ((o operation) (c component))
+ `(;; Normal behavior, to allow user-specified in-order-to dependencies
+ ,@(cdr (assoc (type-of o) (component-in-order-to c)))
+ ;; For backward-compatibility with ASDF2, any operation that doesn't specify propagation
+ ;; or non-propagation through an appropriate mixin will be downward and sideway.
+ ,@(unless (typep o '(or downward-operation upward-operation sideway-operation
+ selfward-operation non-propagating-operation))
+ `(,@(sideway-operation-depends-on o c)
+ ,@(when (typep c 'parent-component) (downward-operation-depends-on o c))))))
+
+ (defmethod downward-operation ((o operation)) nil)
+ (defmethod sideway-operation ((o operation)) nil))
+
+
+;;;---------------------------------------------------------------------------
+;;; End of OPERATION class checking
+;;;---------------------------------------------------------------------------
;;;; Inputs, Outputs, and invisible dependencies
@@ -7736,7 +8103,6 @@ You can put together sentences using this phrase."))
(define-convenience-action-methods operation-done-p (operation component))
(defmethod operation-done-p ((o operation) (c component))
- (declare (ignorable o c))
t)
(defmethod output-files :around (operation component)
@@ -7758,7 +8124,6 @@ You can put together sentences using this phrase."))
(mapcar *output-translation-function* absolute-pathnames))))
t)))
(defmethod output-files ((o operation) (c component))
- (declare (ignorable o c))
nil)
(defun output-file (operation component)
"The unique output file of performing OPERATION on COMPONENT"
@@ -7772,7 +8137,6 @@ You can put together sentences using this phrase."))
(call-next-method)))
(defmethod input-files ((o operation) (c component))
- (declare (ignorable o c))
nil)
(defmethod input-files ((o selfward-operation) (c component))
@@ -7838,12 +8202,14 @@ in some previous image, or T if it needs to be done.")
(defmethod perform :after ((o operation) (c component))
(mark-operation-done o c))
(defmethod perform ((o operation) (c parent-component))
- (declare (ignorable o c))
nil)
(defmethod perform ((o operation) (c source-file))
- (sysdef-error
- (compatfmt "~@<Required method PERFORM not implemented for operation ~A, component ~A~@:>")
- (class-of o) (class-of c)))
+ ;; For backward compatibility, don't error on operations that don't specify propagation.
+ (when (typep o '(or downward-operation upward-operation sideway-operation
+ selfward-operation non-propagating-operation))
+ (sysdef-error
+ (compatfmt "~@<Required method ~S not implemented for ~/asdf-action:format-action/~@:>")
+ 'perform (cons o c))))
(defmethod perform-with-restarts (operation component)
;; TOO verbose, especially as the default. Add your own :before method
@@ -7866,16 +8232,10 @@ in some previous image, or T if it needs to be done.")
(action-description operation component)))
(mark-operation-done operation component)
(return))))))
-
-;;; Generic build operation
-(with-upgradability ()
- (defmethod component-depends-on ((o build-op) (c component))
- `((,(or (component-build-operation c) 'load-op) ,c))))
-
;;;; -------------------------------------------------------------------------
;;;; Actions to build Common Lisp software
-(asdf/package:define-package :asdf/lisp-action
+(uiop/package:define-package :asdf/lisp-action
(:recycle :asdf/lisp-action :asdf)
(:intern #:proclamations #:flags)
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
@@ -7912,22 +8272,22 @@ in some previous image, or T if it needs to be done.")
;;; Our default operations: loading into the current lisp image
(with-upgradability ()
(defclass prepare-op (upward-operation sideway-operation)
- ((sideway-operation :initform 'load-op)))
- (defclass load-op (basic-load-op downward-operation sideway-operation selfward-operation)
+ ((sideway-operation :initform 'load-op :allocation :class))
+ (:documentation "Load dependencies necessary for COMPILE-OP or LOAD-OP of a given COMPONENT."))
+ (defclass load-op (basic-load-op downward-operation selfward-operation)
;; NB: even though compile-op depends on prepare-op it is not needed-in-image-p,
;; so we need to directly depend on prepare-op for its side-effects in the current image.
- ((selfward-operation :initform '(prepare-op compile-op))))
+ ((selfward-operation :initform '(prepare-op compile-op) :allocation :class)))
(defclass compile-op (basic-compile-op downward-operation selfward-operation)
- ((selfward-operation :initform 'prepare-op)
- (downward-operation :initform 'load-op)))
+ ((selfward-operation :initform 'prepare-op :allocation :class)))
(defclass prepare-source-op (upward-operation sideway-operation)
- ((sideway-operation :initform 'load-source-op)))
+ ((sideway-operation :initform 'load-source-op :allocation :class)))
(defclass load-source-op (basic-load-op downward-operation selfward-operation)
- ((selfward-operation :initform 'prepare-source-op)))
+ ((selfward-operation :initform 'prepare-source-op :allocation :class)))
(defclass test-op (selfward-operation)
- ((selfward-operation :initform 'load-op))))
+ ((selfward-operation :initform 'load-op :allocation :class))))
;;;; prepare-op, compile-op and load-op
@@ -7935,25 +8295,17 @@ in some previous image, or T if it needs to be done.")
;;; prepare-op
(with-upgradability ()
(defmethod action-description ((o prepare-op) (c component))
- (declare (ignorable o))
(format nil (compatfmt "~@<loading dependencies of ~3i~_~A~@:>") c))
(defmethod perform ((o prepare-op) (c component))
- (declare (ignorable o c))
- nil)
- (defmethod input-files ((o prepare-op) (c component))
- (declare (ignorable o c))
nil)
(defmethod input-files ((o prepare-op) (s system))
- (declare (ignorable o))
(if-let (it (system-source-file s)) (list it))))
;;; compile-op
(with-upgradability ()
(defmethod action-description ((o compile-op) (c component))
- (declare (ignorable o))
(format nil (compatfmt "~@<compiling ~3i~_~A~@:>") c))
(defmethod action-description ((o compile-op) (c parent-component))
- (declare (ignorable o))
(format nil (compatfmt "~@<completing compilation for ~3i~_~A~@:>") c))
(defgeneric call-with-around-compile-hook (component thunk))
(defmethod call-with-around-compile-hook ((c component) function)
@@ -7974,15 +8326,14 @@ in some previous image, or T if it needs to be done.")
warnings-file) outputs
(call-with-around-compile-hook
c #'(lambda (&rest flags)
- (with-muffled-compiler-conditions ()
- (apply 'compile-file* input-file
- :output-file output-file
- :external-format (component-external-format c)
- :warnings-file warnings-file
- (append
- #+clisp (list :lib-file lib-file)
- #+(or ecl mkcl) (list :object-file object-file)
- flags (compile-op-flags o)))))))
+ (apply 'compile-file* input-file
+ :output-file output-file
+ :external-format (component-external-format c)
+ :warnings-file warnings-file
+ (append
+ #+clisp (list :lib-file lib-file)
+ #+(or ecl mkcl) (list :object-file object-file)
+ flags (compile-op-flags o))))))
(check-lisp-compile-results output warnings-p failure-p
"~/asdf-action::format-action/" (list (cons o c))))))
@@ -8020,10 +8371,6 @@ in some previous image, or T if it needs to be done.")
(defmethod output-files ((o compile-op) (c cl-source-file))
(lisp-compilation-output-files o c))
(defmethod perform ((o compile-op) (c static-file))
- (declare (ignorable o c))
- nil)
- (defmethod output-files ((o compile-op) (c static-file))
- (declare (ignorable o c))
nil)
(defmethod perform ((o compile-op) (c system))
(when (and *warnings-file-type* (not (builtin-system-p c)))
@@ -8043,15 +8390,11 @@ in some previous image, or T if it needs to be done.")
;;; load-op
(with-upgradability ()
(defmethod action-description ((o load-op) (c cl-source-file))
- (declare (ignorable o))
(format nil (compatfmt "~@<loading FASL for ~3i~_~A~@:>") c))
(defmethod action-description ((o load-op) (c parent-component))
- (declare (ignorable o))
(format nil (compatfmt "~@<completing load for ~3i~_~A~@:>") c))
- (defmethod action-description ((o load-op) component)
- (declare (ignorable o))
- (format nil (compatfmt "~@<loading ~3i~_~A~@:>")
- component))
+ (defmethod action-description ((o load-op) (c component))
+ (format nil (compatfmt "~@<loading ~3i~_~A~@:>") c))
(defmethod perform-with-restarts ((o load-op) (c cl-source-file))
(loop
(restart-case
@@ -8063,11 +8406,10 @@ in some previous image, or T if it needs to be done.")
(perform (find-operation o 'compile-op) c)))))
(defun perform-lisp-load-fasl (o c)
(if-let (fasl (first (input-files o c)))
- (with-muffled-loader-conditions () (load* fasl))))
+ (load* fasl)))
(defmethod perform ((o load-op) (c cl-source-file))
(perform-lisp-load-fasl o c))
(defmethod perform ((o load-op) (c static-file))
- (declare (ignorable o c))
nil))
@@ -8076,57 +8418,42 @@ in some previous image, or T if it needs to be done.")
;;; prepare-source-op
(with-upgradability ()
(defmethod action-description ((o prepare-source-op) (c component))
- (declare (ignorable o))
(format nil (compatfmt "~@<loading source for dependencies of ~3i~_~A~@:>") c))
- (defmethod input-files ((o prepare-source-op) (c component))
- (declare (ignorable o c))
- nil)
(defmethod input-files ((o prepare-source-op) (s system))
- (declare (ignorable o))
(if-let (it (system-source-file s)) (list it)))
(defmethod perform ((o prepare-source-op) (c component))
- (declare (ignorable o c))
nil))
;;; load-source-op
(with-upgradability ()
- (defmethod action-description ((o load-source-op) c)
- (declare (ignorable o))
+ (defmethod action-description ((o load-source-op) (c component))
(format nil (compatfmt "~@<Loading source of ~3i~_~A~@:>") c))
(defmethod action-description ((o load-source-op) (c parent-component))
- (declare (ignorable o))
(format nil (compatfmt "~@<Loaded source of ~3i~_~A~@:>") c))
(defun perform-lisp-load-source (o c)
(call-with-around-compile-hook
c #'(lambda ()
- (with-muffled-loader-conditions ()
- (load* (first (input-files o c))
- :external-format (component-external-format c))))))
+ (load* (first (input-files o c))
+ :external-format (component-external-format c)))))
(defmethod perform ((o load-source-op) (c cl-source-file))
(perform-lisp-load-source o c))
(defmethod perform ((o load-source-op) (c static-file))
- (declare (ignorable o c))
- nil)
- (defmethod output-files ((o load-source-op) (c component))
- (declare (ignorable o c))
nil))
;;;; test-op
(with-upgradability ()
(defmethod perform ((o test-op) (c component))
- (declare (ignorable o c))
nil)
(defmethod operation-done-p ((o test-op) (c system))
"Testing a system is _never_ done."
- (declare (ignorable o c))
nil))
;;;; -------------------------------------------------------------------------
;;;; Plan
-(asdf/package:define-package :asdf/plan
+(uiop/package:define-package :asdf/plan
(:recycle :asdf/plan :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
:asdf/component :asdf/operation :asdf/system
@@ -8134,7 +8461,7 @@ in some previous image, or T if it needs to be done.")
:asdf/operation :asdf/action :asdf/lisp-action)
(:export
#:component-operation-time #:mark-operation-done
- #:plan-traversal #:sequential-plan #:*default-plan-class*
+ #:plan #:plan-traversal #:sequential-plan #:*default-plan-class*
#:planned-action-status #:plan-action-status #:action-already-done-p
#:circular-dependency #:circular-dependency-actions
#:node-for #:needed-in-image-p
@@ -8142,7 +8469,7 @@ in some previous image, or T if it needs to be done.")
#:plan-record-dependency
#:normalize-forced-systems #:action-forced-p #:action-forced-not-p
#:map-direct-dependencies #:reduce-direct-dependencies #:direct-dependencies
- #:visit-dependencies #:compute-action-stamp #:traverse-action
+ #:compute-action-stamp #:traverse-action
#:circular-dependency #:circular-dependency-actions
#:call-while-visiting-action #:while-visiting-action
#:make-plan #:plan-actions #:perform-plan #:plan-operates-on-p
@@ -8157,7 +8484,8 @@ in some previous image, or T if it needs to be done.")
;;;; Generic plan traversal class
(with-upgradability ()
- (defclass plan-traversal ()
+ (defclass plan () ())
+ (defclass plan-traversal (plan)
((system :initform nil :initarg :system :accessor plan-system)
(forced :initform nil :initarg :force :accessor plan-forced)
(forced-not :initform nil :initarg :force-not :accessor plan-forced-not)
@@ -8193,9 +8521,8 @@ the action of OPERATION on COMPONENT in the PLAN"))
(with-slots (stamp done-p planned-p index) status
(format stream "~@{~S~^ ~}" :stamp stamp :done-p done-p :planned-p planned-p :index index))))
- (defmethod action-planned-p (action-status)
- (declare (ignorable action-status)) ; default method for non planned-action-status objects
- t)
+ (defmethod action-planned-p ((action-status t))
+ t) ; default method for non planned-action-status objects
;; TODO: eliminate NODE-FOR, use CONS.
;; Supposes cleaner protocol for operation initargs passed to MAKE-OPERATION.
@@ -8206,12 +8533,10 @@ the action of OPERATION on COMPONENT in the PLAN"))
(action-done-p (plan-action-status plan operation component)))
(defmethod plan-action-status ((plan null) (o operation) (c component))
- (declare (ignorable plan))
(multiple-value-bind (stamp done-p) (component-operation-time o c)
(make-instance 'action-status :stamp stamp :done-p done-p)))
(defmethod (setf plan-action-status) (new-status (plan null) (o operation) (c component))
- (declare (ignorable plan))
(let ((to (type-of o))
(times (component-operation-times c)))
(if (action-done-p new-status)
@@ -8227,17 +8552,26 @@ the action of OPERATION on COMPONENT in the PLAN"))
(defun normalize-forced-systems (x system)
(etypecase x
- ((member nil :all) x)
+ ((or (member nil :all) hash-table function) x)
(cons (list-to-hash-set (mapcar #'coerce-name x)))
((eql t) (when system (list-to-hash-set (list (coerce-name system)))))))
+ (defun normalize-forced-not-systems (x system)
+ (let ((requested
+ (etypecase x
+ ((or (member nil :all) hash-table function) x)
+ (cons (list-to-hash-set (mapcar #'coerce-name x)))
+ ((eql t) (if system (let ((name (coerce-name system)))
+ #'(lambda (x) (not (equal x name))))
+ t)))))
+ (if (and *immutable-systems* requested)
+ #'(lambda (x) (or (call-function requested x) (call-function *immutable-systems* x)))
+ (or *immutable-systems* requested))))
+
(defun action-override-p (plan operation component override-accessor)
- (declare (ignorable operation))
- (let* ((override (funcall override-accessor plan)))
- (and override
- (if (typep override 'hash-table)
- (gethash (coerce-name (component-system (find-component () component))) override)
- t))))
+ (declare (ignore operation))
+ (call-function (funcall override-accessor plan)
+ (coerce-name (component-system (find-component () component)))))
(defmethod action-forced-p (plan operation component)
(and
@@ -8250,18 +8584,14 @@ the action of OPERATION on COMPONENT in the PLAN"))
(not (eq system (plan-system plan))))))))
(defmethod action-forced-not-p (plan operation component)
- (and
- ;; Did the user ask us to not re-perform the action?
- (action-override-p plan operation component 'plan-forced-not)
- ;; Force takes precedence over force-not
- (not (action-forced-p plan operation component))))
+ ;; Did the user ask us to not re-perform the action?
+ ;; NB: force-not takes precedence over force, as it should
+ (action-override-p plan operation component 'plan-forced-not))
- (defmethod action-forced-p ((plan null) operation component)
- (declare (ignorable plan operation component))
+ (defmethod action-forced-p ((plan null) (operation operation) (component component))
nil)
- (defmethod action-forced-not-p ((plan null) operation component)
- (declare (ignorable plan operation component))
+ (defmethod action-forced-not-p ((plan null) (operation operation) (component component))
nil))
@@ -8269,15 +8599,11 @@ the action of OPERATION on COMPONENT in the PLAN"))
(with-upgradability ()
(defgeneric action-valid-p (plan operation component)
(:documentation "Is this action valid to include amongst dependencies?"))
- (defmethod action-valid-p (plan operation (c component))
- (declare (ignorable plan operation))
+ (defmethod action-valid-p ((plan t) (o operation) (c component))
(if-let (it (component-if-feature c)) (featurep it) t))
- (defmethod action-valid-p (plan (o null) c) (declare (ignorable plan o c)) nil)
- (defmethod action-valid-p (plan o (c null)) (declare (ignorable plan o c)) nil)
- (defmethod action-valid-p ((plan null) operation component)
- (declare (ignorable plan operation component))
- (and operation component t)))
-
+ (defmethod action-valid-p ((plan t) (o null) (c t)) nil)
+ (defmethod action-valid-p ((plan t) (o t) (c null)) nil)
+ (defmethod action-valid-p ((plan null) (o operation) (c component)) t))
;;;; Is the action needed in this image?
(with-upgradability ()
@@ -8295,82 +8621,98 @@ the action of OPERATION on COMPONENT in the PLAN"))
;;;; Visiting dependencies of an action and computing action stamps
(with-upgradability ()
- (defun map-direct-dependencies (operation component fun)
+ (defun (map-direct-dependencies) (plan operation component fun)
(loop* :for (dep-o-spec . dep-c-specs) :in (component-depends-on operation component)
:for dep-o = (find-operation operation dep-o-spec)
:when dep-o
:do (loop :for dep-c-spec :in dep-c-specs
:for dep-c = (and dep-c-spec (resolve-dependency-spec component dep-c-spec))
- :when dep-c
+ :when (and dep-c (action-valid-p plan dep-o dep-c))
:do (funcall fun dep-o dep-c))))
- (defun reduce-direct-dependencies (operation component combinator seed)
+ (defun (reduce-direct-dependencies) (plan operation component combinator seed)
(map-direct-dependencies
- operation component
+ plan operation component
#'(lambda (dep-o dep-c)
(setf seed (funcall combinator dep-o dep-c seed))))
seed)
- (defun direct-dependencies (operation component)
- (reduce-direct-dependencies operation component #'acons nil))
+ (defun (direct-dependencies) (plan operation component)
+ (reduce-direct-dependencies plan operation component #'acons nil))
- (defun visit-dependencies (plan operation component dependency-stamper &aux stamp)
- (map-direct-dependencies
- operation component
- #'(lambda (dep-o dep-c)
- (when (action-valid-p plan dep-o dep-c)
- (latest-stamp-f stamp (funcall dependency-stamper dep-o dep-c)))))
- stamp)
+ ;; In a distant future, get-file-stamp, component-operation-time and latest-stamp
+ ;; shall also be parametrized by the plan, or by a second model object,
+ ;; so they need not refer to the state of the filesystem,
+ ;; and the stamps could be cryptographic checksums rather than timestamps.
+ ;; Such a change remarkably would only affect COMPUTE-ACTION-STAMP.
(defmethod compute-action-stamp (plan (o operation) (c component) &key just-done)
- ;; In a distant future, get-file-stamp and component-operation-time
- ;; shall also be parametrized by the plan, or by a second model object.
- (let* ((stamp-lookup #'(lambda (o c)
- (if-let (it (plan-action-status plan o c)) (action-stamp it) t)))
- (out-files (output-files o c))
- (in-files (input-files o c))
- ;; Three kinds of actions:
- (out-op (and out-files t)) ; those that create files on the filesystem
- ;;(image-op (and in-files (null out-files))) ; those that load stuff into the image
- ;;(null-op (and (null out-files) (null in-files))) ; placeholders that do nothing
- ;; When was the thing last actually done? (Now, or ask.)
- (op-time (or just-done (component-operation-time o c)))
- ;; Accumulated timestamp from dependencies (or T if forced or out-of-date)
- (dep-stamp (visit-dependencies plan o c stamp-lookup))
- ;; Time stamps from the files at hand, and whether any is missing
- (out-stamps (mapcar (if just-done 'register-file-stamp 'get-file-stamp) out-files))
- (in-stamps (mapcar #'get-file-stamp in-files))
- (missing-in
- (loop :for f :in in-files :for s :in in-stamps :unless s :collect f))
- (missing-out
- (loop :for f :in out-files :for s :in out-stamps :unless s :collect f))
- (all-present (not (or missing-in missing-out)))
- ;; Has any input changed since we last generated the files?
- (earliest-out (stamps-earliest out-stamps))
- (latest-in (stamps-latest (cons dep-stamp in-stamps)))
- (up-to-date-p (stamp<= latest-in earliest-out))
- ;; If everything is up to date, the latest of inputs and outputs is our stamp
- (done-stamp (stamps-latest (cons latest-in out-stamps))))
- ;; Warn if some files are missing:
- ;; either our model is wrong or some other process is messing with our files.
- (when (and just-done (not all-present))
- (warn "~A completed without ~:[~*~;~*its input file~:p~2:*~{ ~S~}~*~]~
- ~:[~; or ~]~:[~*~;~*its output file~:p~2:*~{ ~S~}~*~]"
- (action-description o c)
- missing-in (length missing-in) (and missing-in missing-out)
- missing-out (length missing-out)))
- ;; Note that we use stamp<= instead of stamp< to play nice with generated files.
- ;; Any race condition is intrinsic to the limited timestamp resolution.
- (if (or just-done ;; The done-stamp is valid: if we're just done, or
- ;; if all filesystem effects are up-to-date and there's no invalidating reason.
- (and all-present up-to-date-p (operation-done-p o c) (not (action-forced-p plan o c))))
- (values done-stamp ;; return the hard-earned timestamp
- (or just-done
- out-op ;; a file-creating op is done when all files are up to date
- ;; a image-effecting a placeholder op is done when it was actually run,
- (and op-time (eql op-time done-stamp)))) ;; with the matching stamp
- ;; done-stamp invalid: return a timestamp in an indefinite future, action not done yet
- (values t nil)))))
+ ;; Given an action, figure out at what time in the past it has been done,
+ ;; or if it has just been done, return the time that it has.
+ ;; Returns two values:
+ ;; 1- the TIMESTAMP of the action if it has already been done and is up to date,
+ ;; or T is either hasn't been done or is out of date.
+ ;; 2- the DONE-IN-IMAGE-P boolean flag that is T if the action has already been done
+ ;; in the current image, or NIL if it hasn't.
+ ;; Note that if e.g. LOAD-OP only depends on up-to-date files, but
+ ;; hasn't been done in the current image yet, then it can have a non-T timestamp,
+ ;; yet a NIL done-in-image-p flag.
+ (nest
+ (block ())
+ (let ((dep-stamp ; collect timestamp from dependencies (or T if forced or out-of-date)
+ (reduce-direct-dependencies
+ plan o c
+ #'(lambda (o c stamp)
+ (if-let (it (plan-action-status plan o c))
+ (latest-stamp stamp (action-stamp it))
+ t))
+ nil)))
+ ;; out-of-date dependency: don't bother expensively querying the filesystem
+ (when (and (eq dep-stamp t) (not just-done)) (return (values t nil))))
+ ;; collect timestamps from inputs, and exit early if any is missing
+ (let* ((in-files (input-files o c))
+ (in-stamps (mapcar #'get-file-stamp in-files))
+ (missing-in (loop :for f :in in-files :for s :in in-stamps :unless s :collect f))
+ (latest-in (stamps-latest (cons dep-stamp in-stamps))))
+ (when (and missing-in (not just-done)) (return (values t nil))))
+ ;; collect timestamps from outputs, and exit early if any is missing
+ (let* ((out-files (output-files o c))
+ (out-stamps (mapcar (if just-done 'register-file-stamp 'get-file-stamp) out-files))
+ (missing-out (loop :for f :in out-files :for s :in out-stamps :unless s :collect f))
+ (earliest-out (stamps-earliest out-stamps)))
+ (when (and missing-out (not just-done)) (return (values t nil))))
+ (let* (;; There are three kinds of actions:
+ (out-op (and out-files t)) ; those that create files on the filesystem
+ ;;(image-op (and in-files (null out-files))) ; those that load stuff into the image
+ ;;(null-op (and (null out-files) (null in-files))) ; placeholders that do nothing
+ ;; When was the thing last actually done? (Now, or ask.)
+ (op-time (or just-done (component-operation-time o c)))
+ ;; Time stamps from the files at hand, and whether any is missing
+ (all-present (not (or missing-in missing-out)))
+ ;; Has any input changed since we last generated the files?
+ (up-to-date-p (stamp<= latest-in earliest-out))
+ ;; If everything is up to date, the latest of inputs and outputs is our stamp
+ (done-stamp (stamps-latest (cons latest-in out-stamps))))
+ ;; Warn if some files are missing:
+ ;; either our model is wrong or some other process is messing with our files.
+ (when (and just-done (not all-present))
+ (warn "~A completed without ~:[~*~;~*its input file~:p~2:*~{ ~S~}~*~]~
+ ~:[~; or ~]~:[~*~;~*its output file~:p~2:*~{ ~S~}~*~]"
+ (action-description o c)
+ missing-in (length missing-in) (and missing-in missing-out)
+ missing-out (length missing-out))))
+ ;; Note that we use stamp<= instead of stamp< to play nice with generated files.
+ ;; Any race condition is intrinsic to the limited timestamp resolution.
+ (if (or just-done ;; The done-stamp is valid: if we're just done, or
+ ;; if all filesystem effects are up-to-date and there's no invalidating reason.
+ (and all-present up-to-date-p (operation-done-p o c) (not (action-forced-p plan o c))))
+ (values done-stamp ;; return the hard-earned timestamp
+ (or just-done
+ out-op ;; a file-creating op is done when all files are up to date
+ ;; a image-effecting a placeholder op is done when it was actually run,
+ (and op-time (eql op-time done-stamp)))) ;; with the matching stamp
+ ;; done-stamp invalid: return a timestamp in an indefinite future, action not done yet
+ (values t nil)))))
;;;; Generic support for plan-traversal
@@ -8381,11 +8723,11 @@ the action of OPERATION on COMPONENT in the PLAN"))
(:documentation "Detect circular dependencies"))
(defmethod initialize-instance :after ((plan plan-traversal)
- &key (force () fp) (force-not () fnp) system
+ &key force force-not system
&allow-other-keys)
(with-slots (forced forced-not) plan
- (when fp (setf forced (normalize-forced-systems force system)))
- (when fnp (setf forced-not (normalize-forced-systems force-not system)))))
+ (setf forced (normalize-forced-systems force system))
+ (setf forced-not (normalize-forced-not-systems force-not system))))
(defmethod (setf plan-action-status) (new-status (plan plan-traversal) (o operation) (c component))
(setf (gethash (node-for o c) (plan-visited-actions plan)) new-status))
@@ -8425,42 +8767,63 @@ the action of OPERATION on COMPONENT in the PLAN"))
(defgeneric traverse-action (plan operation component needed-in-image-p))
+ ;; TRAVERSE-ACTION, in the context of a given PLAN object that accumulates dependency data,
+ ;; visits the action defined by its OPERATION and COMPONENT arguments,
+ ;; and all its transitive dependencies (unless already visited),
+ ;; in the context of the action being (or not) NEEDED-IN-IMAGE-P,
+ ;; i.e. needs to be done in the current image vs merely have been done in a previous image.
+ ;; For actions that are up-to-date, it returns a STAMP identifying the state of the action
+ ;; (that's timestamp, but it could be a cryptographic digest in some ASDF extension),
+ ;; or T if the action needs to be done again.
+ ;;
+ ;; Note that for an XCVB-like plan with one-image-per-file-outputting-action,
+ ;; the below method would be insufficient, since it assumes a single image
+ ;; to traverse each node at most twice; non-niip actions would be traversed only once,
+ ;; but niip nodes could be traversed once per image, i.e. once plus once per non-niip action.
+
(defmethod traverse-action (plan operation component needed-in-image-p)
(block nil
+ ;; ACTION-VALID-P among other things, handles forcing logic, including FORCE-NOT,
+ ;; and IF-FEATURE filtering.
(unless (action-valid-p plan operation component) (return nil))
+ ;; the following hook is needed by POIU, which tracks a full dependency graph,
+ ;; instead of just a dependency order as in vanilla ASDF
(plan-record-dependency plan operation component)
- (let* ((aniip (needed-in-image-p operation component))
+ ;; needed in image distinguishes b/w things that must happen in the
+ ;; current image and those things that simply need to have been done in a previous one.
+ (let* ((aniip (needed-in-image-p operation component)) ; action-specific needed-in-image
+ ;; effective niip: meaningful for the action and required by the plan as traversed
(eniip (and aniip needed-in-image-p))
+ ;; status: have we traversed that action previously, and if so what was its status?
(status (plan-action-status plan operation component)))
(when (and status (or (action-done-p status) (action-planned-p status) (not eniip)))
- ;; Already visited with sufficient need-in-image level: just return the stamp.
- (return (action-stamp status)))
- (labels ((visit-action (niip)
- (visit-dependencies plan operation component
- #'(lambda (o c) (traverse-action plan o c niip)))
- (multiple-value-bind (stamp done-p)
- (compute-action-stamp plan operation component)
+ (return (action-stamp status))) ; Already visited with sufficient need-in-image level!
+ (labels ((visit-action (niip) ; We may visit the action twice, once with niip NIL, then T
+ (map-direct-dependencies ; recursively traverse dependencies
+ plan operation component #'(lambda (o c) (traverse-action plan o c niip)))
+ (multiple-value-bind (stamp done-p) ; AFTER dependencies have been traversed,
+ (compute-action-stamp plan operation component) ; compute action stamp
(let ((add-to-plan-p (or (eql stamp t) (and niip (not done-p)))))
- (cond
- ((and add-to-plan-p (not niip)) ;; if we need to do it,
- (visit-action t)) ;; then we need to do it in the image!
+ (cond ; it needs be done if it's out of date or needed in image but absent
+ ((and add-to-plan-p (not niip)) ; if we need to do it,
+ (visit-action t)) ; then we need to do it *in the (current) image*!
(t
- (setf (plan-action-status plan operation component)
+ (setf (plan-action-status plan operation component) ; update status:
(make-instance
'planned-action-status
- :stamp stamp
- :done-p (and done-p (not add-to-plan-p))
- :planned-p add-to-plan-p
- :index (if status
- (action-index status)
- (incf (plan-total-action-count plan)))))
- (when add-to-plan-p
- (incf (plan-planned-action-count plan))
- (unless aniip
- (incf (plan-planned-output-action-count plan))))
- stamp))))))
+ :stamp stamp ; computed stamp
+ :done-p (and done-p (not add-to-plan-p)) ; done *and* up-to-date?
+ :planned-p add-to-plan-p ; included in list of things to be done?
+ :index (if status ; index of action amongst all nodes in traversal
+ (action-index status) ;; if already visited, keep index
+ (incf (plan-total-action-count plan))))) ; else new index
+ (when add-to-plan-p ; if it needs to be added to the plan,
+ (incf (plan-planned-action-count plan)) ; count it
+ (unless aniip ; if it's output-producing,
+ (incf (plan-planned-output-action-count plan)))) ; count it
+ stamp)))))) ; return the stamp
(while-visiting-action (plan operation component) ; maintain context, handle circularity.
- (visit-action eniip)))))))
+ (visit-action eniip))))))) ; visit the action
;;;; Sequential plans (the default)
@@ -8474,9 +8837,7 @@ the action of OPERATION on COMPONENT in the PLAN"))
(defmethod plan-actions ((plan sequential-plan))
(reverse (plan-actions-r plan)))
- (defmethod plan-record-dependency ((plan sequential-plan)
- (operation operation) (component component))
- (declare (ignorable plan operation component))
+ (defmethod plan-record-dependency ((plan sequential-plan) (o operation) (c component))
(values))
(defmethod (setf plan-action-status) :after
@@ -8484,8 +8845,7 @@ the action of OPERATION on COMPONENT in the PLAN"))
(when (action-planned-p new-status)
(push (cons o c) (plan-actions-r p)))))
-
-;;;; high-level interface: traverse, perform-plan, plan-operates-on-p
+;;;; High-level interface: traverse, perform-plan, plan-operates-on-p
(with-upgradability ()
(defgeneric make-plan (plan-class operation component &key &allow-other-keys)
(:documentation
@@ -8498,13 +8858,13 @@ the action of OPERATION on COMPONENT in the PLAN"))
(defvar *default-plan-class* 'sequential-plan)
(defmethod make-plan (plan-class (o operation) (c component) &rest keys &key &allow-other-keys)
- (let ((plan (apply 'make-instance
- (or plan-class *default-plan-class*)
+ (let ((plan (apply 'make-instance (or plan-class *default-plan-class*)
:system (component-system c) keys)))
(traverse-action plan o c t)
plan))
(defmethod perform-plan :around ((plan t) &key)
+ #+xcl (declare (ignorable plan))
(let ((*package* *package*)
(*readtable* *readtable*))
(with-compilation-unit () ;; backward-compatibility.
@@ -8527,6 +8887,9 @@ the action of OPERATION on COMPONENT in the PLAN"))
;;;; Incidental traversals
+
+;;; Making a FILTERED-SEQUENTIAL-PLAN can be used to, e.g., all of the source
+;;; files required by a bundling operation.
(with-upgradability ()
(defclass filtered-sequential-plan (sequential-plan)
((action-filter :initform t :initarg :action-filter :reader plan-action-filter)
@@ -8535,12 +8898,12 @@ the action of OPERATION on COMPONENT in the PLAN"))
(keep-component :initform t :initarg :keep-component :reader plan-keep-component)))
(defmethod initialize-instance :after ((plan filtered-sequential-plan)
- &key (force () fp) (force-not () fnp)
+ &key force force-not
other-systems)
(declare (ignore force force-not))
(with-slots (forced forced-not action-filter system) plan
- (unless fp (setf forced (normalize-forced-systems (if other-systems :all t) system)))
- (unless fnp (setf forced-not (normalize-forced-systems (if other-systems nil :all) system)))
+ (setf forced (normalize-forced-systems (if other-systems :all t) system))
+ (setf forced-not (normalize-forced-not-systems (if other-systems nil t) system))
(setf action-filter (ensure-function action-filter))))
(defmethod action-valid-p ((plan filtered-sequential-plan) o c)
@@ -8554,8 +8917,9 @@ the action of OPERATION on COMPONENT in the PLAN"))
plan))
(define-convenience-action-methods traverse-sub-actions (operation component &key))
- (defmethod traverse-sub-actions ((operation operation) (component component) &rest keys &key &allow-other-keys)
- (apply 'traverse-actions (direct-dependencies operation component)
+ (defmethod traverse-sub-actions ((operation operation) (component component)
+ &rest keys &key &allow-other-keys)
+ (apply 'traverse-actions (direct-dependencies t operation component)
:system (component-system component) keys))
(defmethod plan-actions ((plan filtered-sequential-plan))
@@ -8574,15 +8938,15 @@ the action of OPERATION on COMPONENT in the PLAN"))
;;;; -------------------------------------------------------------------------
;;;; Invoking Operations
-(asdf/package:define-package :asdf/operate
+(uiop/package:define-package :asdf/operate
(:recycle :asdf/operate :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade
+ (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
:asdf/component :asdf/system :asdf/operation :asdf/action
:asdf/find-system :asdf/find-component :asdf/lisp-action :asdf/plan)
(:export
#:operate #:oos
#:*systems-being-operated*
- #:build-system
+ #:build-op #:make
#:load-system #:load-systems #:load-systems*
#:compile-system #:test-system #:require-system
#:*load-system-operation* #:module-provide-asdf
@@ -8596,11 +8960,11 @@ the action of OPERATION on COMPONENT in the PLAN"))
1. It creates an instance of OPERATION-CLASS using any keyword parameters as initargs.
2. It finds the asdf-system specified by SYSTEM (possibly loading it from disk).
-3. It then calls TRAVERSE with the operation and system as arguments
+3. It then calls MAKE-PLAN with the operation and system as arguments
-The traverse operation is wrapped in WITH-COMPILATION-UNIT and error handling code.
-If a VERSION argument is supplied, then operate also ensures that the system found
-satisfies it using the VERSION-SATISFIES method.
+The operation of making a plan is wrapped in WITH-COMPILATION-UNIT and error
+handling code. If a VERSION argument is supplied, then operate also ensures
+that the system found satisfies it using the VERSION-SATISFIES method.
Note that dependencies may cause the operation to invoke other operations on the system
or its components: the new operations will be created with the same initargs as the original one.
@@ -8626,13 +8990,15 @@ The :FORCE or :FORCE-NOT argument to OPERATE can be:
&key verbose
(on-warnings *compile-file-warnings-behaviour*)
(on-failure *compile-file-failure-behaviour*) &allow-other-keys)
- (declare (ignorable operation component))
(let* ((systems-being-operated *systems-being-operated*)
(*systems-being-operated* (or systems-being-operated (make-hash-table :test 'equal)))
- (operation-name (reify-symbol (etypecase operation
- (operation (type-of operation))
- (symbol operation))))
- (component-path (typecase component
+ (operation-remaker ;; how to remake the operation after ASDF was upgraded (if it was)
+ (etypecase operation
+ (operation (let ((name (type-of operation))
+ (initargs (operation-original-initargs operation)))
+ #'(lambda () (make-operation name :original-initargs initargs initargs))))
+ ((or symbol string) (constantly operation))))
+ (component-path (typecase component ;; to remake the component after ASDF upgrade
(component (component-find-path component))
(t component))))
;; Before we operate on any system, make sure ASDF is up-to-date,
@@ -8642,11 +9008,9 @@ The :FORCE or :FORCE-NOT argument to OPERATE can be:
;; If we were upgraded, restart OPERATE the hardest of ways, for
;; its function may have been redefined, its symbol uninterned, its package deleted.
(return-from operate
- (apply (find-symbol* 'operate :asdf)
- (unreify-symbol operation-name)
- component-path keys))))
+ (apply 'operate (funcall operation-remaker) component-path keys))))
;; Setup proper bindings around any operate call.
- (with-system-definitions ()
+ (with-asdf-cache ()
(let* ((*verbose-out* (and verbose *standard-output*))
(*compile-file-warnings-behaviour* on-warnings)
(*compile-file-failure-behaviour* on-failure))
@@ -8677,14 +9041,32 @@ The :FORCE or :FORCE-NOT argument to OPERATE can be:
(with-upgradability ()
(defvar *load-system-operation* 'load-op
"Operation used by ASDF:LOAD-SYSTEM. By default, ASDF:LOAD-OP.
-You may override it with e.g. ASDF:LOAD-FASL-OP from asdf-bundle,
+You may override it with e.g. ASDF:LOAD-FASL-OP from asdf-bundle
or ASDF:LOAD-SOURCE-OP if your fasl loading is somehow broken.
-This may change in the future as we will implement component-based strategy
-for how to load or compile stuff")
+The default operation may change in the future if we implement a
+component-directed strategy for how to load or compile systems.")
- (defun build-system (system &rest keys)
- "Shorthand for `(operate 'asdf:build-op system)`."
+ (defmethod component-depends-on ((o prepare-op) (s system))
+ `((,*load-system-operation* ,@(component-sideway-dependencies s))))
+
+ (defclass build-op (non-propagating-operation) ()
+ (:documentation "Since ASDF3, BUILD-OP is the recommended 'master' operation,
+to operate by default on a system or component, via the function BUILD.
+Its meaning is configurable via the :BUILD-OPERATION option of a component.
+which typically specifies the name of a specific operation to which to delegate the build,
+as a symbol or as a string later read as a symbol (after loading the defsystem-depends-on);
+if NIL is specified (the default), BUILD-OP falls back to the *LOAD-SYSTEM-OPERATION*
+that will load the system in the current image, and its typically LOAD-OP."))
+ (defmethod component-depends-on ((o build-op) (c component))
+ `((,(or (component-build-operation c) *load-system-operation*) ,c)))
+
+ (defun make (system &rest keys)
+ "The recommended way to interact with ASDF3.1 is via (ASDF:MAKE :FOO).
+It will build system FOO using the operation BUILD-OP,
+the meaning of which is configurable by the system, and
+defaults to *LOAD-SYSTEM-OPERATION*, usually LOAD-OP,
+to load it in current image."
(apply 'operate 'build-op system keys)
t)
@@ -8730,21 +9112,20 @@ for how to load or compile stuff")
(defvar *modules-being-required* nil)
(defclass require-system (system)
- ((module :initarg :module :initform nil :accessor required-module)))
+ ((module :initarg :module :initform nil :accessor required-module))
+ (:documentation "A SYSTEM subclass whose processing is handled by
+the implementation's REQUIRE rather than by internal ASDF mechanisms."))
(defmethod perform ((o compile-op) (c require-system))
- (declare (ignorable o c))
nil)
(defmethod perform ((o load-op) (s require-system))
- (declare (ignorable o))
(let* ((module (or (required-module s) (coerce-name s)))
(*modules-being-required* (cons module *modules-being-required*)))
(assert (null (component-children s)))
(require module)))
(defmethod resolve-dependency-combination (component (combinator (eql :require)) arguments)
- (declare (ignorable component combinator))
(unless (length=n-p arguments 1)
(error (compatfmt "~@<Bad dependency ~S for ~S. ~S takes only one argument~@:>")
(cons combinator arguments) component combinator))
@@ -8781,178 +9162,788 @@ for how to load or compile stuff")
(with-upgradability ()
(defun restart-upgraded-asdf ()
;; If we're in the middle of something, restart it.
- (when *systems-being-defined*
- (let ((l (loop :for name :being :the :hash-keys :of *systems-being-defined* :collect name)))
- (clrhash *systems-being-defined*)
+ (when *asdf-cache*
+ (let ((l (loop* :for (x y) :being :the hash-keys :of *asdf-cache*
+ :when (eq x 'find-system) :collect y)))
+ (clrhash *asdf-cache*)
(dolist (s l) (find-system s nil)))))
-
(register-hook-function '*post-upgrade-restart-hook* 'restart-upgraded-asdf))
-;;;; -------------------------------------------------------------------------
-;;; Internal hacks for backward-compatibility
+;;;; ---------------------------------------------------------------------------
+;;;; asdf-output-translations
-(asdf/package:define-package :asdf/backward-internals
- (:recycle :asdf/backward-internals :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade
- :asdf/system :asdf/component :asdf/operation
- :asdf/find-system :asdf/action :asdf/lisp-action)
- (:export ;; for internal use
- #:load-sysdef #:make-temporary-package
- #:%refresh-component-inline-methods
- #:%resolve-if-component-dep-fails
- #:make-sub-operation
- #:load-sysdef #:make-temporary-package))
-(in-package :asdf/backward-internals)
+(uiop/package:define-package :asdf/output-translations
+ (:recycle :asdf/output-translations :asdf)
+ (:use :uiop/common-lisp :uiop :asdf/upgrade)
+ (:export
+ #:*output-translations* #:*output-translations-parameter*
+ #:invalid-output-translation
+ #:output-translations #:output-translations-initialized-p
+ #:initialize-output-translations #:clear-output-translations
+ #:disable-output-translations #:ensure-output-translations
+ #:apply-output-translations
+ #:validate-output-translations-directive #:validate-output-translations-form
+ #:validate-output-translations-file #:validate-output-translations-directory
+ #:parse-output-translations-string #:wrapping-output-translations
+ #:user-output-translations-pathname #:system-output-translations-pathname
+ #:user-output-translations-directory-pathname #:system-output-translations-directory-pathname
+ #:environment-output-translations #:process-output-translations
+ #:compute-output-translations
+ #+abcl #:translate-jar-pathname
+ ))
+(in-package :asdf/output-translations)
+
+(when-upgrading () (undefine-function '(setf output-translations)))
-;;;; Backward compatibility with "inline methods"
(with-upgradability ()
- (defparameter +asdf-methods+
- '(perform-with-restarts perform explain output-files operation-done-p))
+ (define-condition invalid-output-translation (invalid-configuration warning)
+ ((format :initform (compatfmt "~@<Invalid asdf output-translation ~S~@[ in ~S~]~@{ ~@?~}~@:>"))))
- (defun %remove-component-inline-methods (component)
- (dolist (name +asdf-methods+)
- (map ()
- ;; this is inefficient as most of the stored
- ;; methods will not be for this particular gf
- ;; But this is hardly performance-critical
- #'(lambda (m)
- (remove-method (symbol-function name) m))
- (component-inline-methods component)))
- (component-inline-methods component) nil)
+ (defvar *output-translations* ()
+ "Either NIL (for uninitialized), or a list of one element,
+said element itself being a sorted list of mappings.
+Each mapping is a pair of a source pathname and destination pathname,
+and the order is by decreasing length of namestring of the source pathname.")
- (defun %define-component-inline-methods (ret rest)
- (loop* :for (key value) :on rest :by #'cddr
- :for name = (and (keywordp key) (find key +asdf-methods+ :test 'string=))
- :when name :do
- (destructuring-bind (op &rest body) value
- (loop :for arg = (pop body)
- :while (atom arg)
- :collect arg :into qualifiers
- :finally
- (destructuring-bind (o c) arg
- (pushnew
- (eval `(defmethod ,name , at qualifiers ((,o ,op) (,c (eql ,ret))) , at body))
- (component-inline-methods ret)))))))
+ (defun output-translations ()
+ (car *output-translations*))
- (defun %refresh-component-inline-methods (component rest)
- ;; clear methods, then add the new ones
- (%remove-component-inline-methods component)
- (%define-component-inline-methods component rest)))
+ (defun set-output-translations (new-value)
+ (setf *output-translations*
+ (list
+ (stable-sort (copy-list new-value) #'>
+ :key #'(lambda (x)
+ (etypecase (car x)
+ ((eql t) -1)
+ (pathname
+ (let ((directory (pathname-directory (car x))))
+ (if (listp directory) (length directory) 0))))))))
+ new-value)
+ (defun* ((setf output-translations)) (new-value) (set-output-translations new-value))
-;;;; PARTIAL SUPPORT for the :if-component-dep-fails component attribute
-;; and the companion asdf:feature pseudo-dependency.
-;; This won't recurse into dependencies to accumulate feature conditions.
-;; Therefore it will accept the SB-ROTATE-BYTE of an old SBCL
-;; (older than 1.1.2.20-fe6da9f) but won't suffice to load an old nibbles.
-(with-upgradability ()
- (defun %resolve-if-component-dep-fails (if-component-dep-fails component)
- (asdf-message "The system definition for ~S uses deprecated ~
- ASDF option :IF-COMPONENT-DEP-DAILS. ~
- Starting with ASDF 3, please use :IF-FEATURE instead"
- (coerce-name (component-system component)))
- ;; This only supports the pattern of use of the "feature" seen in the wild
- (check-type component parent-component)
- (check-type if-component-dep-fails (member :fail :ignore :try-next))
- (unless (eq if-component-dep-fails :fail)
- (loop :with o = (make-operation 'compile-op)
- :for c :in (component-children component) :do
- (loop* :for (feature? feature) :in (component-depends-on o c)
- :when (eq feature? 'feature) :do
- (setf (component-if-feature c) feature))))))
+ (defun output-translations-initialized-p ()
+ (and *output-translations* t))
-(when-upgrading (:when (fboundp 'make-sub-operation))
- (defun make-sub-operation (c o dep-c dep-o)
- (declare (ignore c o dep-c dep-o)) (asdf-upgrade-error)))
+ (defun clear-output-translations ()
+ "Undoes any initialization of the output translations."
+ (setf *output-translations* '())
+ (values))
+ (register-clear-configuration-hook 'clear-output-translations)
+ (defun validate-output-translations-directive (directive)
+ (or (member directive '(:enable-user-cache :disable-cache nil))
+ (and (consp directive)
+ (or (and (length=n-p directive 2)
+ (or (and (eq (first directive) :include)
+ (typep (second directive) '(or string pathname null)))
+ (and (location-designator-p (first directive))
+ (or (location-designator-p (second directive))
+ (location-function-p (second directive))))))
+ (and (length=n-p directive 1)
+ (location-designator-p (first directive)))))))
-;;;; load-sysdef
-(with-upgradability ()
- (defun load-sysdef (name pathname)
- (load-asd pathname :name name))
+ (defun validate-output-translations-form (form &key location)
+ (validate-configuration-form
+ form
+ :output-translations
+ 'validate-output-translations-directive
+ :location location :invalid-form-reporter 'invalid-output-translation))
- (defun make-temporary-package ()
- ;; For loading a .asd file, we dont't make a temporary package anymore,
- ;; but use ASDF-USER. I'd like to have this function do this,
- ;; but since whoever uses it is likely to delete-package the result afterwards,
- ;; this would be a bad idea, so preserve the old behavior.
- (make-package (fresh-package-name :prefix :asdf :index 0) :use '(:cl :asdf))))
+ (defun validate-output-translations-file (file)
+ (validate-configuration-file
+ file 'validate-output-translations-form :description "output translations"))
+ (defun validate-output-translations-directory (directory)
+ (validate-configuration-directory
+ directory :output-translations 'validate-output-translations-directive
+ :invalid-form-reporter 'invalid-output-translation))
-;;;; -------------------------------------------------------------------------
-;;;; Defsystem
+ (defun parse-output-translations-string (string &key location)
+ (cond
+ ((or (null string) (equal string ""))
+ '(:output-translations :inherit-configuration))
+ ((not (stringp string))
+ (error (compatfmt "~@<Environment string isn't: ~3i~_~S~@:>") string))
+ ((eql (char string 0) #\")
+ (parse-output-translations-string (read-from-string string) :location location))
+ ((eql (char string 0) #\()
+ (validate-output-translations-form (read-from-string string) :location location))
+ (t
+ (loop
+ :with inherit = nil
+ :with directives = ()
+ :with start = 0
+ :with end = (length string)
+ :with source = nil
+ :with separator = (inter-directory-separator)
+ :for i = (or (position separator string :start start) end) :do
+ (let ((s (subseq string start i)))
+ (cond
+ (source
+ (push (list source (if (equal "" s) nil s)) directives)
+ (setf source nil))
+ ((equal "" s)
+ (when inherit
+ (error (compatfmt "~@<Only one inherited configuration allowed: ~3i~_~S~@:>")
+ string))
+ (setf inherit t)
+ (push :inherit-configuration directives))
+ (t
+ (setf source s)))
+ (setf start (1+ i))
+ (when (> start end)
+ (when source
+ (error (compatfmt "~@<Uneven number of components in source to destination mapping: ~3i~_~S~@:>")
+ string))
+ (unless inherit
+ (push :ignore-inherited-configuration directives))
+ (return `(:output-translations ,@(nreverse directives)))))))))
-(asdf/package:define-package :asdf/defsystem
- (:recycle :asdf/defsystem :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade
- :asdf/component :asdf/system :asdf/cache
- :asdf/find-system :asdf/find-component :asdf/lisp-action :asdf/operate
- :asdf/backward-internals)
- (:export
- #:defsystem #:register-system-definition
- #:class-for-type #:*default-component-class*
- #:determine-system-directory #:parse-component-form
- #:non-toplevel-system #:non-system-system
- #:sysdef-error-component #:check-component-input))
-(in-package :asdf/defsystem)
+ (defparameter* *default-output-translations*
+ '(environment-output-translations
+ user-output-translations-pathname
+ user-output-translations-directory-pathname
+ system-output-translations-pathname
+ system-output-translations-directory-pathname))
-;;; Pathname
-(with-upgradability ()
- (defun determine-system-directory (pathname)
- ;; The defsystem macro calls this function to determine
- ;; the pathname of a system as follows:
- ;; 1. if the pathname argument is an pathname object (NOT a namestring),
- ;; that is already an absolute pathname, return it.
- ;; 2. otherwise, the directory containing the LOAD-PATHNAME
- ;; is considered (as deduced from e.g. *LOAD-PATHNAME*), and
- ;; if it is indeed available and an absolute pathname, then
- ;; the PATHNAME argument is normalized to a relative pathname
- ;; as per PARSE-UNIX-NAMESTRING (with ENSURE-DIRECTORY T)
- ;; and merged into that DIRECTORY as per SUBPATHNAME.
- ;; Note: avoid *COMPILE-FILE-PATHNAME* because .asd is loaded,
- ;; and may be from within the EVAL-WHEN of a file compilation.
- ;; If no absolute pathname was found, we return NIL.
- (check-type pathname (or null string pathname))
- (pathname-directory-pathname
- (resolve-symlinks*
- (ensure-absolute-pathname
- (parse-unix-namestring pathname :type :directory)
- #'(lambda () (ensure-absolute-pathname
- (load-pathname) 'get-pathname-defaults nil))
- nil)))))
+ (defun wrapping-output-translations ()
+ `(:output-translations
+ ;; Some implementations have precompiled ASDF systems,
+ ;; so we must disable translations for implementation paths.
+ #+(or #|clozure|# ecl mkcl sbcl)
+ ,@(let ((h (resolve-symlinks* (lisp-implementation-directory))))
+ (when h `(((,h ,*wild-path*) ()))))
+ #+mkcl (,(translate-logical-pathname "CONTRIB:") ())
+ ;; All-import, here is where we want user stuff to be:
+ :inherit-configuration
+ ;; These are for convenience, and can be overridden by the user:
+ #+abcl (#p"/___jar___file___root___/**/*.*" (:user-cache #p"**/*.*"))
+ #+abcl (#p"jar:file:/**/*.jar!/**/*.*" (:function translate-jar-pathname))
+ ;; We enable the user cache by default, and here is the place we do:
+ :enable-user-cache))
+ (defparameter *output-translations-file* (parse-unix-namestring "asdf-output-translations.conf"))
+ (defparameter *output-translations-directory* (parse-unix-namestring "asdf-output-translations.conf.d/"))
-;;; Component class
-(with-upgradability ()
- (defvar *default-component-class* 'cl-source-file)
+ (defun user-output-translations-pathname (&key (direction :input))
+ (in-user-configuration-directory *output-translations-file* :direction direction))
+ (defun system-output-translations-pathname (&key (direction :input))
+ (in-system-configuration-directory *output-translations-file* :direction direction))
+ (defun user-output-translations-directory-pathname (&key (direction :input))
+ (in-user-configuration-directory *output-translations-directory* :direction direction))
+ (defun system-output-translations-directory-pathname (&key (direction :input))
+ (in-system-configuration-directory *output-translations-directory* :direction direction))
+ (defun environment-output-translations ()
+ (getenv "ASDF_OUTPUT_TRANSLATIONS"))
- (defun class-for-type (parent type)
- (or (loop :for symbol :in (list
- type
- (find-symbol* type *package* nil)
- (find-symbol* type :asdf/interface nil)
- (and (stringp type) (safe-read-from-string type :package :asdf/interface)))
- :for class = (and symbol (symbolp symbol) (find-class* symbol nil))
- :when (and class
- (#-cormanlisp subtypep #+cormanlisp cl::subclassp
- class (find-class* 'component)))
- :return class)
- (and (eq type :file)
- (find-class*
- (or (loop :for p = parent :then (component-parent p) :while p
- :thereis (module-default-component-class p))
- *default-component-class*) nil))
- (sysdef-error "don't recognize component type ~A" type))))
+ (defgeneric process-output-translations (spec &key inherit collect))
+ (defun inherit-output-translations (inherit &key collect)
+ (when inherit
+ (process-output-translations (first inherit) :collect collect :inherit (rest inherit))))
-;;; Check inputs
-(with-upgradability ()
- (define-condition non-system-system (system-definition-error)
- ((name :initarg :name :reader non-system-system-name)
- (class-name :initarg :class-name :reader non-system-system-class-name))
- (:report (lambda (c s)
- (format s (compatfmt "~@<Error while defining system ~S: class ~S isn't a subclass of ~S~@:>")
- (non-system-system-name c) (non-system-system-class-name c) 'system))))
+ (defun* (process-output-translations-directive) (directive &key inherit collect)
+ (if (atom directive)
+ (ecase directive
+ ((:enable-user-cache)
+ (process-output-translations-directive '(t :user-cache) :collect collect))
+ ((:disable-cache)
+ (process-output-translations-directive '(t t) :collect collect))
+ ((:inherit-configuration)
+ (inherit-output-translations inherit :collect collect))
+ ((:ignore-inherited-configuration :ignore-invalid-entries nil)
+ nil))
+ (let ((src (first directive))
+ (dst (second directive)))
+ (if (eq src :include)
+ (when dst
+ (process-output-translations (pathname dst) :inherit nil :collect collect))
+ (when src
+ (let ((trusrc (or (eql src t)
+ (let ((loc (resolve-location src :ensure-directory t :wilden t)))
+ (if (absolute-pathname-p loc) (resolve-symlinks* loc) loc)))))
+ (cond
+ ((location-function-p dst)
+ (funcall collect
+ (list trusrc (ensure-function (second dst)))))
+ ((eq dst t)
+ (funcall collect (list trusrc t)))
+ (t
+ (let* ((trudst (if dst
+ (resolve-location dst :ensure-directory t :wilden t)
+ trusrc)))
+ (funcall collect (list trudst t))
+ (funcall collect (list trusrc trudst)))))))))))
+
+ (defmethod process-output-translations ((x symbol) &key
+ (inherit *default-output-translations*)
+ collect)
+ (process-output-translations (funcall x) :inherit inherit :collect collect))
+ (defmethod process-output-translations ((pathname pathname) &key inherit collect)
+ (cond
+ ((directory-pathname-p pathname)
+ (process-output-translations (validate-output-translations-directory pathname)
+ :inherit inherit :collect collect))
+ ((probe-file* pathname :truename *resolve-symlinks*)
+ (process-output-translations (validate-output-translations-file pathname)
+ :inherit inherit :collect collect))
+ (t
+ (inherit-output-translations inherit :collect collect))))
+ (defmethod process-output-translations ((string string) &key inherit collect)
+ (process-output-translations (parse-output-translations-string string)
+ :inherit inherit :collect collect))
+ (defmethod process-output-translations ((x null) &key inherit collect)
+ (inherit-output-translations inherit :collect collect))
+ (defmethod process-output-translations ((form cons) &key inherit collect)
+ (dolist (directive (cdr (validate-output-translations-form form)))
+ (process-output-translations-directive directive :inherit inherit :collect collect)))
+
+ (defun compute-output-translations (&optional parameter)
+ "read the configuration, return it"
+ (remove-duplicates
+ (while-collecting (c)
+ (inherit-output-translations
+ `(wrapping-output-translations ,parameter ,@*default-output-translations*) :collect #'c))
+ :test 'equal :from-end t))
+
+ (defvar *output-translations-parameter* nil)
+
+ (defun initialize-output-translations (&optional (parameter *output-translations-parameter*))
+ "read the configuration, initialize the internal configuration variable,
+return the configuration"
+ (setf *output-translations-parameter* parameter
+ (output-translations) (compute-output-translations parameter)))
+
+ (defun disable-output-translations ()
+ "Initialize output translations in a way that maps every file to itself,
+effectively disabling the output translation facility."
+ (initialize-output-translations
+ '(:output-translations :disable-cache :ignore-inherited-configuration)))
+
+ ;; checks an initial variable to see whether the state is initialized
+ ;; or cleared. In the former case, return current configuration; in
+ ;; the latter, initialize. ASDF will call this function at the start
+ ;; of (asdf:find-system).
+ (defun ensure-output-translations ()
+ (if (output-translations-initialized-p)
+ (output-translations)
+ (initialize-output-translations)))
+
+ (defun* (apply-output-translations) (path)
+ (etypecase path
+ (logical-pathname
+ path)
+ ((or pathname string)
+ (ensure-output-translations)
+ (loop* :with p = (resolve-symlinks* path)
+ :for (source destination) :in (car *output-translations*)
+ :for root = (when (or (eq source t)
+ (and (pathnamep source)
+ (not (absolute-pathname-p source))))
+ (pathname-root p))
+ :for absolute-source = (cond
+ ((eq source t) (wilden root))
+ (root (merge-pathnames* source root))
+ (t source))
+ :when (or (eq source t) (pathname-match-p p absolute-source))
+ :return (translate-pathname* p absolute-source destination root source)
+ :finally (return p)))))
+
+ ;; Hook into uiop's output-translation mechanism
+ #-cormanlisp
+ (setf *output-translation-function* 'apply-output-translations)
+
+ #+abcl
+ (defun translate-jar-pathname (source wildcard)
+ (declare (ignore wildcard))
+ (flet ((normalize-device (pathname)
+ (if (find :windows *features*)
+ pathname
+ (make-pathname :defaults pathname :device :unspecific))))
+ (let* ((jar
+ (pathname (first (pathname-device source))))
+ (target-root-directory-namestring
+ (format nil "/___jar___file___root___/~@[~A/~]"
+ (and (find :windows *features*)
+ (pathname-device jar))))
+ (relative-source
+ (relativize-pathname-directory source))
+ (relative-jar
+ (relativize-pathname-directory (ensure-directory-pathname jar)))
+ (target-root-directory
+ (normalize-device
+ (pathname-directory-pathname
+ (parse-namestring target-root-directory-namestring))))
+ (target-root
+ (merge-pathnames* relative-jar target-root-directory))
+ (target
+ (merge-pathnames* relative-source target-root)))
+ (normalize-device (apply-output-translations target))))))
+
+;;;; -----------------------------------------------------------------
+;;;; Source Registry Configuration, by Francois-Rene Rideau
+;;;; See the Manual and https://bugs.launchpad.net/asdf/+bug/485918
+
+(uiop/package:define-package :asdf/source-registry
+ (:recycle :asdf/source-registry :asdf)
+ (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/find-system)
+ (:export
+ #:*source-registry-parameter* #:*default-source-registries*
+ #:invalid-source-registry
+ #:source-registry-initialized-p
+ #:initialize-source-registry #:clear-source-registry #:*source-registry*
+ #:ensure-source-registry #:*source-registry-parameter*
+ #:*default-source-registry-exclusions* #:*source-registry-exclusions*
+ #:*wild-asd* #:directory-asd-files #:register-asd-directory
+ #:collect-asds-in-directory #:collect-sub*directories-asd-files
+ #:validate-source-registry-directive #:validate-source-registry-form
+ #:validate-source-registry-file #:validate-source-registry-directory
+ #:parse-source-registry-string #:wrapping-source-registry
+ #:default-user-source-registry #:default-system-source-registry
+ #:user-source-registry #:system-source-registry
+ #:user-source-registry-directory #:system-source-registry-directory
+ #:environment-source-registry #:process-source-registry
+ #:compute-source-registry #:flatten-source-registry
+ #:sysdef-source-registry-search))
+(in-package :asdf/source-registry)
+
+(with-upgradability ()
+ (define-condition invalid-source-registry (invalid-configuration warning)
+ ((format :initform (compatfmt "~@<Invalid source registry ~S~@[ in ~S~]~@{ ~@?~}~@:>"))))
+
+ ;; Using ack 1.2 exclusions
+ (defvar *default-source-registry-exclusions*
+ '(".bzr" ".cdv"
+ ;; "~.dep" "~.dot" "~.nib" "~.plst" ; we don't support ack wildcards
+ ".git" ".hg" ".pc" ".svn" "CVS" "RCS" "SCCS" "_darcs"
+ "_sgbak" "autom4te.cache" "cover_db" "_build"
+ "debian")) ;; debian often builds stuff under the debian directory... BAD.
+
+ (defvar *source-registry-exclusions* *default-source-registry-exclusions*)
+
+ (defvar *source-registry* nil
+ "Either NIL (for uninitialized), or an equal hash-table, mapping
+system names to pathnames of .asd files")
+
+ (defun source-registry-initialized-p ()
+ (typep *source-registry* 'hash-table))
+
+ (defun clear-source-registry ()
+ "Undoes any initialization of the source registry."
+ (setf *source-registry* nil)
+ (values))
+ (register-clear-configuration-hook 'clear-source-registry)
+
+ (defparameter *wild-asd*
+ (make-pathname* :directory nil :name *wild* :type "asd" :version :newest))
+
+ (defun directory-asd-files (directory)
+ (directory-files directory *wild-asd*))
+
+ (defun collect-asds-in-directory (directory collect)
+ (map () collect (directory-asd-files directory)))
+
+ (defun collect-sub*directories-asd-files
+ (directory &key (exclude *default-source-registry-exclusions*) collect)
+ (collect-sub*directories
+ directory
+ (constantly t)
+ #'(lambda (x &aux (l (car (last (pathname-directory x))))) (not (member l exclude :test #'equal)))
+ #'(lambda (dir) (collect-asds-in-directory dir collect))))
+
+ (defun validate-source-registry-directive (directive)
+ (or (member directive '(:default-registry))
+ (and (consp directive)
+ (let ((rest (rest directive)))
+ (case (first directive)
+ ((:include :directory :tree)
+ (and (length=n-p rest 1)
+ (location-designator-p (first rest))))
+ ((:exclude :also-exclude)
+ (every #'stringp rest))
+ ((:default-registry)
+ (null rest)))))))
+
+ (defun validate-source-registry-form (form &key location)
+ (validate-configuration-form
+ form :source-registry 'validate-source-registry-directive
+ :location location :invalid-form-reporter 'invalid-source-registry))
+
+ (defun validate-source-registry-file (file)
+ (validate-configuration-file
+ file 'validate-source-registry-form :description "a source registry"))
+
+ (defun validate-source-registry-directory (directory)
+ (validate-configuration-directory
+ directory :source-registry 'validate-source-registry-directive
+ :invalid-form-reporter 'invalid-source-registry))
+
+ (defun parse-source-registry-string (string &key location)
+ (cond
+ ((or (null string) (equal string ""))
+ '(:source-registry :inherit-configuration))
+ ((not (stringp string))
+ (error (compatfmt "~@<Environment string isn't: ~3i~_~S~@:>") string))
+ ((find (char string 0) "\"(")
+ (validate-source-registry-form (read-from-string string) :location location))
+ (t
+ (loop
+ :with inherit = nil
+ :with directives = ()
+ :with start = 0
+ :with end = (length string)
+ :with separator = (inter-directory-separator)
+ :for pos = (position separator string :start start) :do
+ (let ((s (subseq string start (or pos end))))
+ (flet ((check (dir)
+ (unless (absolute-pathname-p dir)
+ (error (compatfmt "~@<source-registry string must specify absolute pathnames: ~3i~_~S~@:>") string))
+ dir))
+ (cond
+ ((equal "" s) ; empty element: inherit
+ (when inherit
+ (error (compatfmt "~@<Only one inherited configuration allowed: ~3i~_~S~@:>")
+ string))
+ (setf inherit t)
+ (push ':inherit-configuration directives))
+ ((string-suffix-p s "//") ;; TODO: allow for doubling of separator even outside Unix?
+ (push `(:tree ,(check (subseq s 0 (- (length s) 2)))) directives))
+ (t
+ (push `(:directory ,(check s)) directives))))
+ (cond
+ (pos
+ (setf start (1+ pos)))
+ (t
+ (unless inherit
+ (push '(:ignore-inherited-configuration) directives))
+ (return `(:source-registry ,@(nreverse directives))))))))))
+
+ (defun register-asd-directory (directory &key recurse exclude collect)
+ (if (not recurse)
+ (collect-asds-in-directory directory collect)
+ (collect-sub*directories-asd-files
+ directory :exclude exclude :collect collect)))
+
+ (defparameter* *default-source-registries*
+ '(environment-source-registry
+ user-source-registry
+ user-source-registry-directory
+ default-user-source-registry
+ system-source-registry
+ system-source-registry-directory
+ default-system-source-registry)
+ "List of default source registries" "3.1.0.102")
+
+ (defparameter *source-registry-file* (parse-unix-namestring "source-registry.conf"))
+ (defparameter *source-registry-directory* (parse-unix-namestring "source-registry.conf.d/"))
+
+ (defun wrapping-source-registry ()
+ `(:source-registry
+ #+(or ecl sbcl) (:tree ,(resolve-symlinks* (lisp-implementation-directory)))
+ :inherit-configuration
+ #+mkcl (:tree ,(translate-logical-pathname "CONTRIB:"))
+ #+cmu (:tree #p"modules:")
+ #+scl (:tree #p"file://modules/")))
+ (defun default-user-source-registry ()
+ `(:source-registry
+ (:tree (:home "common-lisp/"))
+ #+sbcl (:directory (:home ".sbcl/systems/"))
+ ,@(loop :for dir :in
+ `(,@(when (os-unix-p)
+ `(,(or (getenv-absolute-directory "XDG_DATA_HOME")
+ (subpathname (user-homedir-pathname) ".local/share/"))))
+ ,@(when (os-windows-p)
+ (mapcar 'get-folder-path '(:local-appdata :appdata))))
+ :collect `(:directory ,(subpathname* dir "common-lisp/systems/"))
+ :collect `(:tree ,(subpathname* dir "common-lisp/source/")))
+ :inherit-configuration))
+ (defun default-system-source-registry ()
+ `(:source-registry
+ ,@(loop :for dir :in
+ `(,@(when (os-unix-p)
+ (or (getenv-absolute-directories "XDG_DATA_DIRS")
+ '("/usr/local/share" "/usr/share")))
+ ,@(when (os-windows-p)
+ (list (get-folder-path :common-appdata))))
+ :collect `(:directory ,(subpathname* dir "common-lisp/systems/"))
+ :collect `(:tree ,(subpathname* dir "common-lisp/source/")))
+ :inherit-configuration))
+ (defun user-source-registry (&key (direction :input))
+ (in-user-configuration-directory *source-registry-file* :direction direction))
+ (defun system-source-registry (&key (direction :input))
+ (in-system-configuration-directory *source-registry-file* :direction direction))
+ (defun user-source-registry-directory (&key (direction :input))
+ (in-user-configuration-directory *source-registry-directory* :direction direction))
+ (defun system-source-registry-directory (&key (direction :input))
+ (in-system-configuration-directory *source-registry-directory* :direction direction))
+ (defun environment-source-registry ()
+ (getenv "CL_SOURCE_REGISTRY"))
+
+ (defgeneric* (process-source-registry) (spec &key inherit register))
+
+ (defun* (inherit-source-registry) (inherit &key register)
+ (when inherit
+ (process-source-registry (first inherit) :register register :inherit (rest inherit))))
+
+ (defun* (process-source-registry-directive) (directive &key inherit register)
+ (destructuring-bind (kw &rest rest) (if (consp directive) directive (list directive))
+ (ecase kw
+ ((:include)
+ (destructuring-bind (pathname) rest
+ (process-source-registry (resolve-location pathname) :inherit nil :register register)))
+ ((:directory)
+ (destructuring-bind (pathname) rest
+ (when pathname
+ (funcall register (resolve-location pathname :ensure-directory t)))))
+ ((:tree)
+ (destructuring-bind (pathname) rest
+ (when pathname
+ (funcall register (resolve-location pathname :ensure-directory t)
+ :recurse t :exclude *source-registry-exclusions*))))
+ ((:exclude)
+ (setf *source-registry-exclusions* rest))
+ ((:also-exclude)
+ (appendf *source-registry-exclusions* rest))
+ ((:default-registry)
+ (inherit-source-registry '(default-source-registry) :register register))
+ ((:inherit-configuration)
+ (inherit-source-registry inherit :register register))
+ ((:ignore-inherited-configuration)
+ nil)))
+ nil)
+
+ (defmethod process-source-registry ((x symbol) &key inherit register)
+ (process-source-registry (funcall x) :inherit inherit :register register))
+ (defmethod process-source-registry ((pathname pathname) &key inherit register)
+ (cond
+ ((directory-pathname-p pathname)
+ (let ((*here-directory* (resolve-symlinks* pathname)))
+ (process-source-registry (validate-source-registry-directory pathname)
+ :inherit inherit :register register)))
+ ((probe-file* pathname :truename *resolve-symlinks*)
+ (let ((*here-directory* (pathname-directory-pathname pathname)))
+ (process-source-registry (validate-source-registry-file pathname)
+ :inherit inherit :register register)))
+ (t
+ (inherit-source-registry inherit :register register))))
+ (defmethod process-source-registry ((string string) &key inherit register)
+ (process-source-registry (parse-source-registry-string string)
+ :inherit inherit :register register))
+ (defmethod process-source-registry ((x null) &key inherit register)
+ (inherit-source-registry inherit :register register))
+ (defmethod process-source-registry ((form cons) &key inherit register)
+ (let ((*source-registry-exclusions* *default-source-registry-exclusions*))
+ (dolist (directive (cdr (validate-source-registry-form form)))
+ (process-source-registry-directive directive :inherit inherit :register register))))
+
+ (defun flatten-source-registry (&optional parameter)
+ (remove-duplicates
+ (while-collecting (collect)
+ (with-pathname-defaults () ;; be location-independent
+ (inherit-source-registry
+ `(wrapping-source-registry
+ ,parameter
+ ,@*default-source-registries*)
+ :register #'(lambda (directory &key recurse exclude)
+ (collect (list directory :recurse recurse :exclude exclude))))))
+ :test 'equal :from-end t))
+
+ ;; Will read the configuration and initialize all internal variables.
+ (defun compute-source-registry (&optional parameter (registry *source-registry*))
+ (dolist (entry (flatten-source-registry parameter))
+ (destructuring-bind (directory &key recurse exclude) entry
+ (let* ((h (make-hash-table :test 'equal))) ; table to detect duplicates
+ (register-asd-directory
+ directory :recurse recurse :exclude exclude :collect
+ #'(lambda (asd)
+ (let* ((name (pathname-name asd))
+ (name (if (typep asd 'logical-pathname)
+ ;; logical pathnames are upper-case,
+ ;; at least in the CLHS and on SBCL,
+ ;; yet (coerce-name :foo) is lower-case.
+ ;; won't work well with (load-system "Foo")
+ ;; instead of (load-system 'foo)
+ (string-downcase name)
+ name)))
+ (cond
+ ((gethash name registry) ; already shadowed by something else
+ nil)
+ ((gethash name h) ; conflict at current level
+ (when *verbose-out*
+ (warn (compatfmt "~@<In source-registry entry ~A~@[/~*~] ~
+ found several entries for ~A - picking ~S over ~S~:>")
+ directory recurse name (gethash name h) asd)))
+ (t
+ (setf (gethash name registry) asd)
+ (setf (gethash name h) asd))))))
+ h)))
+ (values))
+
+ (defvar *source-registry-parameter* nil)
+
+ (defun initialize-source-registry (&optional (parameter *source-registry-parameter*))
+ ;; Record the parameter used to configure the registry
+ (setf *source-registry-parameter* parameter)
+ ;; Clear the previous registry database:
+ (setf *source-registry* (make-hash-table :test 'equal))
+ ;; Do it!
+ (compute-source-registry parameter))
+
+ ;; Checks an initial variable to see whether the state is initialized
+ ;; or cleared. In the former case, return current configuration; in
+ ;; the latter, initialize. ASDF will call this function at the start
+ ;; of (asdf:find-system) to make sure the source registry is initialized.
+ ;; However, it will do so *without* a parameter, at which point it
+ ;; will be too late to provide a parameter to this function, though
+ ;; you may override the configuration explicitly by calling
+ ;; initialize-source-registry directly with your parameter.
+ (defun ensure-source-registry (&optional parameter)
+ (unless (source-registry-initialized-p)
+ (initialize-source-registry parameter))
+ (values))
+
+ (defun sysdef-source-registry-search (system)
+ (ensure-source-registry)
+ (values (gethash (primary-system-name system) *source-registry*))))
+
+
+;;;; -------------------------------------------------------------------------
+;;; Internal hacks for backward-compatibility
+
+(uiop/package:define-package :asdf/backward-internals
+ (:recycle :asdf/backward-internals :asdf)
+ (:use :uiop/common-lisp :uiop :asdf/upgrade
+ :asdf/system :asdf/component :asdf/operation
+ :asdf/find-system :asdf/action :asdf/lisp-action)
+ (:export ;; for internal use
+ #:load-sysdef #:make-temporary-package
+ #:%refresh-component-inline-methods
+ #:make-sub-operation
+ #:load-sysdef #:make-temporary-package))
+(in-package :asdf/backward-internals)
+
+;;;; Backward compatibility with "inline methods"
+(with-upgradability ()
+ (defparameter* +asdf-methods+
+ '(perform-with-restarts perform explain output-files operation-done-p))
+
+ (defun %remove-component-inline-methods (component)
+ (dolist (name +asdf-methods+)
+ (map ()
+ ;; this is inefficient as most of the stored
+ ;; methods will not be for this particular gf
+ ;; But this is hardly performance-critical
+ #'(lambda (m)
+ (remove-method (symbol-function name) m))
+ (component-inline-methods component)))
+ (component-inline-methods component) nil)
+
+ (defun %define-component-inline-methods (ret rest)
+ (loop* :for (key value) :on rest :by #'cddr
+ :for name = (and (keywordp key) (find key +asdf-methods+ :test 'string=))
+ :when name :do
+ (destructuring-bind (op &rest body) value
+ (loop :for arg = (pop body)
+ :while (atom arg)
+ :collect arg :into qualifiers
+ :finally
+ (destructuring-bind (o c) arg
+ (pushnew
+ (eval `(defmethod ,name , at qualifiers ((,o ,op) (,c (eql ,ret))) , at body))
+ (component-inline-methods ret)))))))
+
+ (defun %refresh-component-inline-methods (component rest)
+ ;; clear methods, then add the new ones
+ (%remove-component-inline-methods component)
+ (%define-component-inline-methods component rest)))
+
+(when-upgrading (:when (fboundp 'make-sub-operation))
+ (defun make-sub-operation (c o dep-c dep-o)
+ (declare (ignore c o dep-c dep-o)) (asdf-upgrade-error)))
+
+
+;;;; load-sysdef
+(with-upgradability ()
+ (defun load-sysdef (name pathname)
+ (load-asd pathname :name name))
+
+ (defun make-temporary-package ()
+ ;; For loading a .asd file, we don't make a temporary package anymore,
+ ;; but use ASDF-USER. I'd like to have this function do this,
+ ;; but since whoever uses it is likely to delete-package the result afterwards,
+ ;; this would be a bad idea, so preserve the old behavior.
+ (make-package (fresh-package-name :prefix :asdf :index 0) :use '(:cl :asdf))))
+
+
+;;;; -------------------------------------------------------------------------
+;;;; Defsystem
+
+(uiop/package:define-package :asdf/parse-defsystem
+ (:recycle :asdf/parse-defsystem :asdf/defsystem :asdf)
+ (:nicknames :asdf/defsystem) ;; previous name, to be compatible with, in case anyone cares
+ (:use :uiop/common-lisp :asdf/driver :asdf/upgrade
+ :asdf/cache :asdf/component :asdf/system
+ :asdf/find-system :asdf/find-component :asdf/lisp-action :asdf/operate
+ :asdf/backward-internals)
+ (:import-from :asdf/system #:depends-on #:weakly-depends-on)
+ (:export
+ #:defsystem #:register-system-definition
+ #:class-for-type #:*default-component-class*
+ #:determine-system-directory #:parse-component-form
+ #:non-toplevel-system #:non-system-system
+ #:sysdef-error-component #:check-component-input))
+(in-package :asdf/parse-defsystem)
+
+;;; Pathname
+(with-upgradability ()
+ (defun determine-system-directory (pathname)
+ ;; The defsystem macro calls this function to determine
+ ;; the pathname of a system as follows:
+ ;; 1. if the pathname argument is an pathname object (NOT a namestring),
+ ;; that is already an absolute pathname, return it.
+ ;; 2. otherwise, the directory containing the LOAD-PATHNAME
+ ;; is considered (as deduced from e.g. *LOAD-PATHNAME*), and
+ ;; if it is indeed available and an absolute pathname, then
+ ;; the PATHNAME argument is normalized to a relative pathname
+ ;; as per PARSE-UNIX-NAMESTRING (with ENSURE-DIRECTORY T)
+ ;; and merged into that DIRECTORY as per SUBPATHNAME.
+ ;; Note: avoid *COMPILE-FILE-PATHNAME* because .asd is loaded,
+ ;; and may be from within the EVAL-WHEN of a file compilation.
+ ;; If no absolute pathname was found, we return NIL.
+ (check-type pathname (or null string pathname))
+ (pathname-directory-pathname
+ (resolve-symlinks*
+ (ensure-absolute-pathname
+ (parse-unix-namestring pathname :type :directory)
+ #'(lambda () (ensure-absolute-pathname
+ (load-pathname) 'get-pathname-defaults nil))
+ nil)))))
+
+
+;;; Component class
+(with-upgradability ()
+ (defvar *default-component-class* 'cl-source-file)
+
+ (defun class-for-type (parent type)
+ (or (coerce-class type :package :asdf/interface :super 'component :error nil)
+ (and (eq type :file)
+ (coerce-class
+ (or (loop :for p = parent :then (component-parent p) :while p
+ :thereis (module-default-component-class p))
+ *default-component-class*)
+ :package :asdf/interface :super 'component :error nil))
+ (sysdef-error "don't recognize component type ~S" type))))
+
+
+;;; Check inputs
+(with-upgradability ()
+ (define-condition non-system-system (system-definition-error)
+ ((name :initarg :name :reader non-system-system-name)
+ (class-name :initarg :class-name :reader non-system-system-class-name))
+ (:report (lambda (c s)
+ (format s (compatfmt "~@<Error while defining system ~S: class ~S isn't a subclass of ~S~@:>")
+ (non-system-system-name c) (non-system-system-class-name c) 'system))))
(define-condition non-toplevel-system (system-definition-error)
((parent :initarg :parent :reader non-toplevel-system-parent)
@@ -8983,7 +9974,7 @@ for how to load or compile stuff")
(warn (compatfmt "~@<Invalid :version specifier ~S~@[ for component ~S~]~@[ in ~S~]~@[ from file ~S~]~@[, ~A~]~@:>")
form component parent pathname continuation))
(invalid-parse (control &rest args)
- (unless (builtin-system-p (find-component parent component))
+ (unless (if-let (target (find-component parent component)) (builtin-system-p target))
(apply 'warn control args)
(invalid))))
(if-let (v (typecase form
@@ -9012,6 +10003,32 @@ for how to load or compile stuff")
;;; Main parsing function
(with-upgradability ()
+ (defun* parse-dependency-def (dd)
+ (if (listp dd)
+ (case (first dd)
+ (:feature
+ (unless (= (length dd) 3)
+ (sysdef-error "Ill-formed feature dependency: ~s" dd))
+ (let ((embedded (parse-dependency-def (third dd))))
+ `(:feature ,(second dd) ,embedded)))
+ (feature
+ (sysdef-error "`feature' has been removed from the dependency spec language of ASDF. Use :feature instead in ~s." dd))
+ (:require
+ (unless (= (length dd) 2)
+ (sysdef-error "Ill-formed require dependency: ~s" dd))
+ dd)
+ (:version
+ (unless (= (length dd) 3)
+ (sysdef-error "Ill-formed version dependency: ~s" dd))
+ `(:version ,(coerce-name (second dd)) ,(third dd)))
+ (otherwise (sysdef-error "Ill-formed dependency: ~s" dd)))
+ (coerce-name dd)))
+
+ (defun* parse-dependency-defs (dd-list)
+ "Parse the dependency defs in DD-LIST into canonical form by translating all
+system names contained using COERCE-NAME. Return the result."
+ (mapcar 'parse-dependency-def dd-list))
+
(defun* (parse-component-form) (parent options &key previous-serial-component)
(destructuring-bind
(type name &rest rest &key
@@ -9023,7 +10040,7 @@ for how to load or compile stuff")
do-first if-component-dep-fails version
;; list ends
&allow-other-keys) options
- (declare (ignorable perform explain output-files operation-done-p builtin-system-p))
+ (declare (ignore perform explain output-files operation-done-p builtin-system-p))
(check-component-input type name weakly-depends-on depends-on components)
(when (and parent
(find-component parent name)
@@ -9049,6 +10066,13 @@ for how to load or compile stuff")
(apply 'reinitialize-instance component args)
(setf component (apply 'make-instance class args)))
(component-pathname component) ; eagerly compute the absolute pathname
+ (when (typep component 'system)
+ ;; cache information for introspection
+ (setf (slot-value component 'depends-on)
+ (parse-dependency-defs depends-on)
+ (slot-value component 'weakly-depends-on)
+ ;; these must be a list of systems, cannot be features or versioned systems
+ (mapcar 'coerce-name weakly-depends-on)))
(let ((sysfile (system-source-file (component-system component)))) ;; requires the previous
(when (and (typep component 'system) (not bspp))
(setf (builtin-system-p component) (lisp-implementation-pathname-p sysfile)))
@@ -9077,7 +10101,10 @@ for how to load or compile stuff")
(setf (component-sideway-dependencies component) depends-on)
(%refresh-component-inline-methods component rest)
(when if-component-dep-fails
- (%resolve-if-component-dep-fails if-component-dep-fails component))
+ (error "The system definition for ~S uses deprecated ~
+ ASDF option :IF-COMPONENT-DEP-FAILS. ~
+ Starting with ASDF 3, please use :IF-FEATURE instead"
+ (coerce-name (component-system component))))
component)))
(defun register-system-definition
@@ -9088,8 +10115,8 @@ for how to load or compile stuff")
;; of the same name to reuse options (e.g. pathname) from.
;; To avoid infinite recursion in cases where you defsystem a system
;; that is registered to a different location to find-system,
- ;; we also need to remember it in a special variable *systems-being-defined*.
- (with-system-definitions ()
+ ;; we also need to remember it in the asdf-cache.
+ (with-asdf-cache ()
(let* ((name (coerce-name name))
(source-file (if sfp source-file (resolve-symlinks* (load-pathname))))
(registered (system-registered-p name))
@@ -9099,10 +10126,16 @@ for how to load or compile stuff")
(make-instance 'system :name name :source-file source-file))))
(system (reset-system (cdr registered!)
:name name :source-file source-file))
- (component-options (remove-plist-key :class options))
+ (component-options
+ (remove-plist-keys '(:defsystem-depends-on :class) options))
(defsystem-dependencies (loop :for spec :in defsystem-depends-on :collect
(resolve-dependency-spec nil spec))))
- (setf (gethash name *systems-being-defined*) system)
+ ;; cache defsystem-depends-on in canonical form
+ (when defsystem-depends-on
+ (setf component-options
+ (append `(:defsystem-depends-on ,(parse-dependency-defs defsystem-depends-on))
+ component-options)))
+ (set-asdf-cache-entry `(find-system ,name) (list system))
(load-systems* defsystem-dependencies)
;; We change-class AFTER we loaded the defsystem-depends-on
;; since the class might be defined as part of those.
@@ -9122,99 +10155,152 @@ for how to load or compile stuff")
;;;; -------------------------------------------------------------------------
;;;; ASDF-Bundle
-(asdf/package:define-package :asdf/bundle
+(uiop/package:define-package :asdf/bundle
(:recycle :asdf/bundle :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
:asdf/component :asdf/system :asdf/find-system :asdf/find-component :asdf/operation
- :asdf/action :asdf/lisp-action :asdf/plan :asdf/operate)
+ :asdf/action :asdf/lisp-action :asdf/plan :asdf/operate :asdf/defsystem)
(:export
- #:bundle-op #:bundle-op-build-args #:bundle-type
+ #:bundle-op #:bundle-type #:program-system
#:bundle-system #:bundle-pathname-type #:bundlable-file-p #:direct-dependency-files
#:monolithic-op #:monolithic-bundle-op #:operation-monolithic-p
- #:basic-fasl-op #:prepare-fasl-op #:fasl-op #:load-fasl-op #:monolithic-fasl-op
+ #:fasl-op #:load-fasl-op #:monolithic-fasl-op #:binary-op #:monolithic-binary-op
+ #:basic-compile-bundle-op #:prepare-bundle-op
+ #:compile-bundle-op #:load-bundle-op #:monolithic-compile-bundle-op #:monolithic-load-bundle-op
#:lib-op #:monolithic-lib-op
#:dll-op #:monolithic-dll-op
- #:binary-op #:monolithic-binary-op
- #:program-op #:compiled-file #:precompiled-system #:prebuilt-system
+ #:deliver-asd-op #:monolithic-deliver-asd-op
+ #:program-op #:image-op #:compiled-file #:precompiled-system #:prebuilt-system
#:user-system-p #:user-system #:trivial-system-p
- #+ecl #:make-build
- #:register-pre-built-system
+ #:make-build
#:build-args #:name-suffix #:prologue-code #:epilogue-code #:static-library))
(in-package :asdf/bundle)
(with-upgradability ()
- (defclass bundle-op (operation)
- ((build-args :initarg :args :initform nil :accessor bundle-op-build-args)
+ (defclass bundle-op (basic-compile-op)
+ ((build-args :initarg :args :initform nil :accessor extra-build-args)
(name-suffix :initarg :name-suffix :initform nil)
(bundle-type :initform :no-output-file :reader bundle-type)
- #+ecl (lisp-files :initform nil :accessor bundle-op-lisp-files)
- #+mkcl (do-fasb :initarg :do-fasb :initform t :reader bundle-op-do-fasb-p)
- #+mkcl (do-static-library :initarg :do-static-library :initform t :reader bundle-op-do-static-library-p)))
+ #+ecl (lisp-files :initform nil :accessor extra-object-files)))
- (defclass bundle-compile-op (bundle-op basic-compile-op)
- ()
- (:documentation "Abstract operation for ways to bundle the outputs of compiling *Lisp* files"))
+ (defclass monolithic-op (operation) ()
+ (:documentation "A MONOLITHIC operation operates on a system *and all of its
+dependencies*. So, for example, a monolithic concatenate operation will
+concatenate together a system's components and all of its dependencies, but a
+simple concatenate operation will concatenate only the components of the system
+itself.")) ;; operation on a system and its dependencies
+
+ (defclass monolithic-bundle-op (monolithic-op bundle-op)
+ ;; Old style way of specifying prologue and epilogue on ECL: in the monolithic operation
+ ((prologue-code :initform nil :accessor prologue-code)
+ (epilogue-code :initform nil :accessor epilogue-code)))
+
+ (defclass program-system (system)
+ ;; New style (ASDF3.1) way of specifying prologue and epilogue on ECL: in the system
+ ((prologue-code :initform nil :initarg :prologue-code :reader prologue-code)
+ (epilogue-code :initform nil :initarg :epilogue-code :reader epilogue-code)
+ (no-uiop :initform nil :initarg :no-uiop :reader no-uiop)
+ (prefix-lisp-object-files :initarg :prefix-lisp-object-files
+ :initform nil :accessor prefix-lisp-object-files)
+ (postfix-lisp-object-files :initarg :postfix-lisp-object-files
+ :initform nil :accessor postfix-lisp-object-files)
+ (extra-object-files :initarg :extra-object-files
+ :initform nil :accessor extra-object-files)
+ (extra-build-args :initarg :extra-build-args
+ :initform nil :accessor extra-build-args)))
+
+ (defmethod prologue-code ((x t)) nil)
+ (defmethod epilogue-code ((x t)) nil)
+ (defmethod no-uiop ((x t)) nil)
+ (defmethod prefix-lisp-object-files ((x t)) nil)
+ (defmethod postfix-lisp-object-files ((x t)) nil)
+ (defmethod extra-object-files ((x t)) nil)
+ (defmethod extra-build-args ((x t)) nil)
+
+ (defclass link-op (bundle-op) ()
+ (:documentation "Abstract operation for linking files together"))
+
+ (defclass gather-op (bundle-op)
+ ((gather-op :initform nil :allocation :class :reader gather-op))
+ (:documentation "Abstract operation for gathering many input files from a system"))
+
+ (defun operation-monolithic-p (op)
+ (typep op 'monolithic-op))
+
+ (defmethod component-depends-on ((o gather-op) (s system))
+ (let* ((mono (operation-monolithic-p o))
+ (deps
+ (required-components
+ s :other-systems mono :component-type (if mono 'system '(not system))
+ :goal-operation (find-operation o 'load-op)
+ :keep-operation 'compile-op)))
+ ;; NB: the explicit make-operation on ECL and MKCL
+ ;; ensures that we drop the original-initargs and its magic flags when recursing.
+ `((,(make-operation (or (gather-op o) (if mono 'lib-op 'compile-op))) , at deps)
+ ,@(call-next-method))))
;; create a single fasl for the entire library
- (defclass basic-fasl-op (bundle-compile-op)
+ (defclass basic-compile-bundle-op (bundle-op)
((bundle-type :initform :fasl)))
- (defclass prepare-fasl-op (sideway-operation)
- ((sideway-operation :initform 'load-fasl-op)))
- (defclass fasl-op (basic-fasl-op selfward-operation)
- ((selfward-operation :initform '(prepare-fasl-op #+ecl lib-op))))
- (defclass load-fasl-op (basic-load-op selfward-operation)
- ((selfward-operation :initform '(prepare-op fasl-op))))
- ;; NB: since the monolithic-op's can't be sideway-operation's,
- ;; if we wanted lib-op, dll-op, binary-op to be sideway-operation's,
- ;; we'd have to have the monolithic-op not inherit from the main op,
- ;; but instead inherit from a basic-FOO-op as with basic-fasl-op above.
+ (defclass prepare-bundle-op (sideway-operation)
+ ((sideway-operation :initform #+(or ecl mkcl) 'load-bundle-op #-(or ecl mkcl) 'load-op
+ :allocation :class)))
- (defclass no-ld-flags-op (operation) ())
+ (defclass lib-op (link-op gather-op non-propagating-operation)
+ ((bundle-type :initform :lib))
+ (:documentation "compile the system and produce linkable (.a) library for it."))
- (defclass lib-op (bundle-compile-op no-ld-flags-op)
- ((bundle-type :initform #+(or ecl mkcl) :lib #-(or ecl mkcl) :no-output-file))
- (:documentation #+(or ecl mkcl) "compile the system and produce linkable (.a) library for it."
- #-(or ecl mkcl) "just compile the system"))
+ (defclass compile-bundle-op (basic-compile-bundle-op selfward-operation
+ #+(or ecl mkcl) link-op #-ecl gather-op)
+ ((selfward-operation :initform '(prepare-bundle-op #+ecl lib-op) :allocation :class)))
- (defclass dll-op (bundle-compile-op selfward-operation no-ld-flags-op)
- ((bundle-type :initform :dll))
- (:documentation "compile the system and produce dynamic (.so/.dll) library for it."))
+ (defclass load-bundle-op (basic-load-op selfward-operation)
+ ((selfward-operation :initform '(prepare-bundle-op compile-bundle-op) :allocation :class)))
- (defclass binary-op (basic-compile-op selfward-operation)
- ((selfward-operation :initform '(fasl-op lib-op)))
- (:documentation "produce fasl and asd files for the system"))
+ ;; NB: since the monolithic-op's can't be sideway-operation's,
+ ;; if we wanted lib-op, dll-op, deliver-asd-op to be sideway-operation's,
+ ;; we'd have to have the monolithic-op not inherit from the main op,
+ ;; but instead inherit from a basic-FOO-op as with basic-compile-bundle-op above.
- (defclass monolithic-op (operation) ()) ;; operation on a system and its dependencies
+ (defclass dll-op (link-op gather-op non-propagating-operation)
+ ((bundle-type :initform :dll))
+ (:documentation "compile the system and produce dynamic (.so/.dll) library for it."))
- (defclass monolithic-bundle-op (monolithic-op bundle-op)
- ((prologue-code :accessor monolithic-op-prologue-code)
- (epilogue-code :accessor monolithic-op-epilogue-code)))
+ (defclass deliver-asd-op (basic-compile-op selfward-operation)
+ ((selfward-operation :initform '(compile-bundle-op #+(or ecl mkcl) lib-op) :allocation :class))
+ (:documentation "produce an asd file for delivering the system as a single fasl"))
- (defclass monolithic-bundle-compile-op (monolithic-bundle-op bundle-compile-op)
- ()
- (:documentation "Abstract operation for ways to bundle the outputs of compiling *Lisp* files over all systems"))
- (defclass monolithic-binary-op (monolithic-op binary-op)
- ((selfward-operation :initform '(monolithic-fasl-op monolithic-lib-op)))
+ (defclass monolithic-deliver-asd-op (monolithic-bundle-op deliver-asd-op)
+ ((selfward-operation :initform '(monolithic-compile-bundle-op #+(or ecl mkcl) monolithic-lib-op)
+ :allocation :class))
(:documentation "produce fasl and asd files for combined system and dependencies."))
- (defclass monolithic-fasl-op (monolithic-bundle-compile-op basic-fasl-op) ()
+ (defclass monolithic-compile-bundle-op (monolithic-bundle-op basic-compile-bundle-op
+ #+(or ecl mkcl) link-op gather-op non-propagating-operation)
+ ((gather-op :initform #+(or ecl mkcl) 'lib-op #-(or ecl mkcl) 'compile-bundle-op :allocation :class))
(:documentation "Create a single fasl for the system and its dependencies."))
- (defclass monolithic-lib-op (monolithic-bundle-compile-op basic-compile-op no-ld-flags-op)
- ((bundle-type :initform #+(or ecl mkcl) :lib #-(or ecl mkcl) :no-output-file))
- (:documentation #+(or ecl mkcl) "Create a single linkable library for the system and its dependencies."
- #-(or ecl mkcl) "Compile a system and its dependencies."))
+ (defclass monolithic-load-bundle-op (monolithic-bundle-op load-bundle-op)
+ ((selfward-operation :initform 'monolithic-compile-bundle-op :allocation :class))
+ (:documentation "Load a single fasl for the system and its dependencies."))
- (defclass monolithic-dll-op (monolithic-bundle-compile-op sideway-operation selfward-operation no-ld-flags-op)
+ (defclass monolithic-lib-op (monolithic-bundle-op lib-op non-propagating-operation) ()
+ (:documentation "Create a single linkable library for the system and its dependencies."))
+
+ (defclass monolithic-dll-op (monolithic-bundle-op dll-op non-propagating-operation)
((bundle-type :initform :dll))
(:documentation "Create a single dynamic (.so/.dll) library for the system and its dependencies."))
- (defclass program-op #+(or mkcl ecl) (monolithic-bundle-compile-op)
- #-(or mkcl ecl) (monolithic-bundle-op selfward-operation)
- ((bundle-type :initform :program)
- #-(or mkcl ecl) (selfward-operation :initform #-(or mkcl ecl) 'load-op))
+ (defclass image-op (monolithic-bundle-op selfward-operation
+ #+(or ecl mkcl) link-op #+(or ecl mkcl) gather-op)
+ ((bundle-type :initform :image)
+ (selfward-operation :initform '(#-(or ecl mkcl) load-op) :allocation :class))
+ (:documentation "create an image file from the system and its dependencies"))
+
+ (defclass program-op (image-op)
+ ((bundle-type :initform :program))
(:documentation "create an executable file from the system and its dependencies"))
(defun bundle-pathname-type (bundle-type)
@@ -9223,31 +10309,33 @@ for how to load or compile stuff")
((or null string) bundle-type)
((eql :fasl) #-(or ecl mkcl) (compile-file-type) #+(or ecl mkcl) "fasb")
#+ecl
- ((member :binary :dll :lib :shared-library :static-library :program :object :program)
+ ((member :dll :lib :shared-library :static-library :program :object :program)
(compile-file-type :type bundle-type))
- ((eql :binary) "image")
- ((eql :dll) (cond ((os-macosx-p) "dylib") ((os-unix-p) "so") ((os-windows-p) "dll")))
- ((member :lib :static-library) (cond ((os-unix-p) "a") ((os-windows-p) "lib")))
+ ((member :image) #-allegro "image" #+allegro "dxl")
+ ((member :dll :shared-library) (cond ((os-macosx-p) "dylib") ((os-unix-p) "so") ((os-windows-p) "dll")))
+ ((member :lib :static-library) (cond ((os-unix-p) "a")
+ ((os-windows-p) (if (featurep '(:or :mingw32 :mingw64)) "a" "lib"))))
((eql :program) (cond ((os-unix-p) nil) ((os-windows-p) "exe")))))
(defun bundle-output-files (o c)
- (when (input-files o c)
- (let ((bundle-type (bundle-type o)))
- (unless (eq bundle-type :no-output-file) ;; NIL already means something regarding type.
- (let ((name (or (component-build-pathname c)
- (format nil "~A~@[~A~]" (component-name c) (slot-value o 'name-suffix))))
- (type (bundle-pathname-type bundle-type)))
- (values (list (subpathname (component-pathname c) name :type type))
- (eq (type-of o) (component-build-operation c))))))))
+ (let ((bundle-type (bundle-type o)))
+ (unless (or (eq bundle-type :no-output-file) ;; NIL already means something regarding type.
+ (and (null (input-files o c)) (not (member bundle-type '(:image :program)))))
+ (let ((name (or (component-build-pathname c)
+ (format nil "~A~@[~A~]" (component-name c) (slot-value o 'name-suffix))))
+ (type (bundle-pathname-type bundle-type)))
+ (values (list (subpathname (component-pathname c) name :type type))
+ (eq (type-of o) (component-build-operation c)))))))
(defmethod output-files ((o bundle-op) (c system))
(bundle-output-files o c))
#-(or ecl mkcl)
- (defmethod perform ((o program-op) (c system))
- (let ((output-file (output-file o c)))
- (setf *image-entry-point* (ensure-function (component-entry-point c)))
- (dump-image output-file :executable t)))
+ (progn
+ (defmethod perform ((o image-op) (c system))
+ (dump-image (output-file o c) :executable (typep o 'program-op)))
+ (defmethod perform :before ((o program-op) (c system))
+ (setf *image-entry-point* (ensure-function (component-entry-point c)))))
(defclass compiled-file (file-component)
((type :initform #-(or ecl mkcl) (compile-file-type) #+(or ecl mkcl) "fasb")))
@@ -9268,45 +10356,37 @@ for how to load or compile stuff")
;;; a FASL, a statically linked library, a shared library, etc.
;;; The different targets are defined by specialization.
;;;
-(with-upgradability ()
- (defun operation-monolithic-p (op)
- (typep op 'monolithic-op))
-
+(with-upgradability ()
(defmethod initialize-instance :after ((instance bundle-op) &rest initargs
&key (name-suffix nil name-suffix-p)
&allow-other-keys)
- (declare (ignorable initargs name-suffix))
+ (declare (ignore initargs name-suffix))
(unless name-suffix-p
(setf (slot-value instance 'name-suffix)
(unless (typep instance 'program-op)
- (if (operation-monolithic-p instance) "--all-systems" #-ecl "--system")))) ; . no good for Logical Pathnames
+ (if (operation-monolithic-p instance) "--all-systems" #-(or ecl mkcl) "--system")))) ; . no good for Logical Pathnames
(when (typep instance 'monolithic-bundle-op)
- (destructuring-bind (&rest original-initargs
- &key lisp-files prologue-code epilogue-code
+ (destructuring-bind (&key lisp-files prologue-code epilogue-code
&allow-other-keys)
(operation-original-initargs instance)
- (setf (operation-original-initargs instance)
- (remove-plist-keys '(:lisp-files :epilogue-code :prologue-code) original-initargs)
- (monolithic-op-prologue-code instance) prologue-code
- (monolithic-op-epilogue-code instance) epilogue-code)
- #-ecl (assert (null (or lisp-files epilogue-code prologue-code)))
- #+ecl (setf (bundle-op-lisp-files instance) lisp-files)))
- (setf (bundle-op-build-args instance)
- (remove-plist-keys '(:type :monolithic :name-suffix)
- (operation-original-initargs instance))))
-
- (defmethod bundle-op-build-args :around ((o no-ld-flags-op))
- (declare (ignorable o))
- (let ((args (call-next-method)))
- (remf args :ld-flags)
- args))
+ (setf (prologue-code instance) prologue-code
+ (epilogue-code instance) epilogue-code)
+ #-ecl (assert (null (or lisp-files #-mkcl epilogue-code #-mkcl prologue-code)))
+ #+ecl (setf (extra-object-files instance) lisp-files)))
+ (setf (extra-build-args instance)
+ (remove-plist-keys
+ '(:type :monolithic :name-suffix :epilogue-code :prologue-code :lisp-files
+ :force :force-not :plan-class) ;; TODO: refactor so we don't mix plan and operation arguments
+ (operation-original-initargs instance))))
(defun bundlable-file-p (pathname)
(let ((type (pathname-type pathname)))
(declare (ignorable type))
(or #+ecl (or (equalp type (compile-file-type :type :object))
(equalp type (compile-file-type :type :static-library)))
- #+mkcl (equalp type (compile-file-type :fasl-p nil))
+ #+mkcl (or (equalp type (compile-file-type :fasl-p nil))
+ #+(or unix mingw32 mingw64) (equalp type "a") ;; valid on Unix and MinGW
+ #+(and windows (not (or mingw32 mingw64))) (equalp type "lib"))
#+(or abcl allegro clisp clozure cmu lispworks sbcl scl xcl) (equalp type (compile-file-type)))))
(defgeneric* (trivial-system-p) (component))
@@ -9328,57 +10408,40 @@ for how to load or compile stuff")
;;; MONOLITHIC SHARED LIBRARIES, PROGRAMS, FASL
;;;
(with-upgradability ()
- (defmethod component-depends-on ((o bundle-compile-op) (c system))
- `(,(if (operation-monolithic-p o)
- `(#-(or ecl mkcl) fasl-op #+(or ecl mkcl) lib-op
- ,@(required-components c :other-systems t :component-type 'system
- :goal-operation (find-operation o 'load-op)
- :keep-operation 'compile-op))
- `(compile-op
- ,@(required-components c :other-systems nil :component-type '(not system)
- :goal-operation (find-operation o 'load-op)
- :keep-operation 'compile-op)))
- ,@(call-next-method)))
-
- (defmethod component-depends-on :around ((o bundle-op) (c component))
- (declare (ignorable o c))
- (if-let (op (and (eq (type-of o) 'bundle-op) (component-build-operation c)))
- `((,op ,c))
- (call-next-method)))
-
(defun direct-dependency-files (o c &key (test 'identity) (key 'output-files) &allow-other-keys)
;; This file selects output files from direct dependencies;
;; your component-depends-on method better gathered the correct dependencies in the correct order.
(while-collecting (collect)
(map-direct-dependencies
- o c #'(lambda (sub-o sub-c)
- (loop :for f :in (funcall key sub-o sub-c)
- :when (funcall test f) :do (collect f))))))
+ t o c #'(lambda (sub-o sub-c)
+ (loop :for f :in (funcall key sub-o sub-c)
+ :when (funcall test f) :do (collect f))))))
- (defmethod input-files ((o bundle-compile-op) (c system))
+ (defmethod input-files ((o gather-op) (c system))
(unless (eq (bundle-type o) :no-output-file)
(direct-dependency-files o c :test 'bundlable-file-p :key 'output-files)))
(defun select-bundle-operation (type &optional monolithic)
(ecase type
- ((:binary)
- (if monolithic 'monolithic-binary-op 'binary-op))
((:dll :shared-library)
(if monolithic 'monolithic-dll-op 'dll-op))
((:lib :static-library)
(if monolithic 'monolithic-lib-op 'lib-op))
((:fasl)
- (if monolithic 'monolithic-fasl-op 'fasl-op))
+ (if monolithic 'monolithic-compile-bundle-op 'compile-bundle-op))
+ ((:image)
+ 'image-op)
((:program)
'program-op)))
+ ;; DEPRECATED. This is originally from asdf-ecl.lisp. Does anyone use it?
(defun make-build (system &rest args &key (monolithic nil) (type :fasl)
(move-here nil move-here-p)
&allow-other-keys)
(let* ((operation-name (select-bundle-operation type monolithic))
(move-here-path (if (and move-here
(typep move-here '(or pathname string)))
- (pathname move-here)
+ (ensure-pathname move-here :namestring :lisp :ensure-directory t)
(system-relative-pathname system "asdf-output/")))
(operation (apply #'operate operation-name
system
@@ -9386,7 +10449,7 @@ for how to load or compile stuff")
(system (find-system system))
(files (and system (output-files operation system))))
(if (or move-here (and (null move-here-p)
- (member operation-name '(:program :binary))))
+ (member operation-name '(:program :image))))
(loop :with dest-path = (resolve-symlinks* (ensure-directories-exist move-here-path))
:for f :in files
:for new-f = (make-pathname :name (pathname-name f)
@@ -9394,34 +10457,33 @@ for how to load or compile stuff")
:defaults dest-path)
:do (rename-file-overwriting-target f new-f)
:collect new-f)
- files))))
+ files)))
+
+ ;; DEPRECATED. Does anyone use this?
+ (defun bundle-system (system &rest args &key force (verbose t) version &allow-other-keys)
+ (declare (ignore force verbose version))
+ (apply #'operate 'deliver-asd-op system args)))
;;;
-;;; LOAD-FASL-OP
+;;; LOAD-BUNDLE-OP
;;;
-;;; This is like ASDF's LOAD-OP, but using monolithic fasl files.
+;;; This is like ASDF's LOAD-OP, but using bundle fasl files.
;;;
(with-upgradability ()
- (defmethod component-depends-on ((o load-fasl-op) (c system))
- (declare (ignorable o))
- `((,o ,@(loop :for dep :in (component-sideway-dependencies c)
- :collect (resolve-dependency-spec c dep)))
- (,(if (user-system-p c) 'fasl-op 'load-op) ,c)
+ (defmethod component-depends-on ((o load-bundle-op) (c system))
+ `((,o ,@(component-sideway-dependencies c))
+ (,(if (user-system-p c) 'compile-bundle-op 'load-op) ,c)
,@(call-next-method)))
- (defmethod input-files ((o load-fasl-op) (c system))
+ (defmethod input-files ((o load-bundle-op) (c system))
(when (user-system-p c)
- (output-files (find-operation o 'fasl-op) c)))
+ (output-files (find-operation o 'compile-bundle-op) c)))
- (defmethod perform ((o load-fasl-op) c)
- (declare (ignorable o c))
- nil)
-
- (defmethod perform ((o load-fasl-op) (c system))
+ (defmethod perform ((o load-bundle-op) (c system))
(when (input-files o c)
(perform-lisp-load-fasl o c)))
- (defmethod mark-operation-done :after ((o load-fasl-op) (c system))
+ (defmethod mark-operation-done :after ((o load-bundle-op) (c system))
(mark-operation-done (find-operation o 'load-op) c)))
;;;
@@ -9434,20 +10496,13 @@ for how to load or compile stuff")
(defmethod trivial-system-p ((s system))
(every #'(lambda (c) (typep c 'compiled-file)) (component-children s)))
- (defmethod output-files (o (c compiled-file))
- (declare (ignorable o c))
- nil)
- (defmethod input-files (o (c compiled-file))
- (declare (ignorable o))
- (component-pathname c))
+ (defmethod input-files ((o operation) (c compiled-file))
+ (list (component-pathname c)))
(defmethod perform ((o load-op) (c compiled-file))
(perform-lisp-load-fasl o c))
(defmethod perform ((o load-source-op) (c compiled-file))
(perform (find-operation o 'load-op) c))
- (defmethod perform ((o load-fasl-op) (c compiled-file))
- (perform (find-operation o 'load-op) c))
(defmethod perform ((o operation) (c compiled-file))
- (declare (ignorable o c))
nil))
;;;
@@ -9455,570 +10510,287 @@ for how to load or compile stuff")
;;;
(with-upgradability ()
(defmethod trivial-system-p ((s prebuilt-system))
- (declare (ignorable s))
t)
- (defmethod perform ((o lib-op) (c prebuilt-system))
- (declare (ignorable o c))
- nil)
-
- (defmethod component-depends-on ((o lib-op) (c prebuilt-system))
- (declare (ignorable o c))
+ (defmethod perform ((o link-op) (c prebuilt-system))
nil)
- (defmethod component-depends-on ((o monolithic-lib-op) (c prebuilt-system))
- (declare (ignorable o))
- nil))
-
-
-;;;
-;;; PREBUILT SYSTEM CREATOR
-;;;
-(with-upgradability ()
- (defmethod output-files ((o binary-op) (s system))
- (list (make-pathname :name (component-name s) :type "asd"
- :defaults (component-pathname s))))
-
- (defmethod perform ((o binary-op) (s system))
- (let* ((inputs (input-files o s))
- (fasl (first inputs))
- (library (second inputs))
- (asd (first (output-files o s)))
- (name (if (and fasl asd) (pathname-name asd) (return-from perform)))
- (dependencies
- (if (operation-monolithic-p o)
- (remove-if-not 'builtin-system-p
- (required-components s :component-type 'system
- :keep-operation 'load-op))
- (while-collecting (x) ;; resolve the sideway-dependencies of s
- (map-direct-dependencies
- 'load-op s
- #'(lambda (o c)
- (when (and (typep o 'load-op) (typep c 'system))
- (x c)))))))
- (depends-on (mapcar 'coerce-name dependencies)))
- (when (pathname-equal asd (system-source-file s))
- (cerror "overwrite the asd file"
- "~/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."
- (cons o s) asd))
- (with-open-file (s asd :direction :output :if-exists :supersede
- :if-does-not-exist :create)
- (format s ";;; Prebuilt~:[~; monolithic~] ASDF definition for system ~A~%"
- (operation-monolithic-p o) name)
- (format s ";;; Built for ~A ~A on a ~A/~A ~A~%"
- (lisp-implementation-type)
- (lisp-implementation-version)
- (software-type)
- (machine-type)
- (software-version))
- (let ((*package* (find-package :asdf-user)))
- (pprint `(defsystem ,name
- :class prebuilt-system
- :depends-on ,depends-on
- :components ((:compiled-file ,(pathname-name fasl)))
- ,@(when library `(:lib ,(file-namestring library))))
- s)
- (terpri s)))))
-
- #-(or ecl mkcl)
- (defmethod perform ((o bundle-compile-op) (c system))
- (let* ((input-files (input-files o c))
- (fasl-files (remove (compile-file-type) input-files :key #'pathname-type :test-not #'equalp))
- (non-fasl-files (remove (compile-file-type) input-files :key #'pathname-type :test #'equalp))
- (output-files (output-files o c))
- (output-file (first output-files)))
- (assert (eq (not input-files) (not output-files)))
- (when input-files
- (when non-fasl-files
- (error "On ~A, asdf-bundle can only bundle FASL files, but these were also produced: ~S"
- (implementation-type) non-fasl-files))
- (when (and (typep o 'monolithic-bundle-op)
- (or (monolithic-op-prologue-code o) (monolithic-op-epilogue-code o)))
- (error "prologue-code and epilogue-code are not supported on ~A"
- (implementation-type)))
- (with-staging-pathname (output-file)
- (combine-fasls fasl-files output-file)))))
-
- (defmethod input-files ((o load-op) (s precompiled-system))
- (declare (ignorable o))
- (bundle-output-files (find-operation o 'fasl-op) s))
-
- (defmethod perform ((o load-op) (s precompiled-system))
- (perform-lisp-load-fasl o s))
-
- (defmethod component-depends-on ((o load-fasl-op) (s precompiled-system))
- (declare (ignorable o))
- `((load-op ,s) ,@(call-next-method))))
-
- #| ;; Example use:
-(asdf:defsystem :precompiled-asdf-utils :class asdf::precompiled-system :fasl (asdf:apply-output-translations (asdf:system-relative-pathname :asdf-utils "asdf-utils.system.fasl")))
-(asdf:load-system :precompiled-asdf-utils)
-|#
-
-#+(or ecl mkcl)
-(with-upgradability ()
- (defun uiop-library-file ()
- (or (and (find-system :uiop nil)
- (system-source-directory :uiop)
- (progn
- (operate 'lib-op :uiop)
- (output-file 'lib-op :uiop)))
- (resolve-symlinks* (c::compile-file-pathname "sys:asdf" :type :lib))))
- (defmethod input-files :around ((o program-op) (c system))
- (let ((files (call-next-method))
- (plan (traverse-sub-actions o c :plan-class 'sequential-plan)))
- (unless (or (and (find-system :uiop nil)
- (system-source-directory :uiop)
- (plan-operates-on-p plan '("uiop")))
- (and (system-source-directory :asdf)
- (plan-operates-on-p plan '("asdf"))))
- (pushnew (uiop-library-file) files :test 'pathname-equal))
- files))
-
- (defun register-pre-built-system (name)
- (register-system (make-instance 'system :name (coerce-name name) :source-file nil))))
-
-#+ecl
-(with-upgradability ()
- (defmethod perform ((o bundle-compile-op) (c system))
- (let* ((object-files (input-files o c))
- (output (output-files o c))
- (bundle (first output))
- (kind (bundle-type o)))
- (when output
- (create-image
- bundle (append object-files (bundle-op-lisp-files o))
- :kind kind
- :entry-point (component-entry-point c)
- :prologue-code
- (when (typep o 'monolithic-bundle-op)
- (monolithic-op-prologue-code o))
- :epilogue-code
- (when (typep o 'monolithic-bundle-op)
- (monolithic-op-epilogue-code o))
- :build-args (bundle-op-build-args o))))))
-
-#+mkcl
-(with-upgradability ()
- (defmethod perform ((o lib-op) (s system))
- (apply #'compiler::build-static-library (output-file o c)
- :lisp-object-files (input-files o s) (bundle-op-build-args o)))
-
- (defmethod perform ((o basic-fasl-op) (s system))
- (apply #'compiler::build-bundle (output-file o c) ;; second???
- :lisp-object-files (input-files o s) (bundle-op-build-args o)))
-
- (defun bundle-system (system &rest args &key force (verbose t) version &allow-other-keys)
- (declare (ignore force verbose version))
- (apply #'operate 'binary-op system args)))
-;;;; -------------------------------------------------------------------------
-;;;; Concatenate-source
-
-(asdf/package:define-package :asdf/concatenate-source
- (:recycle :asdf/concatenate-source :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade
- :asdf/component :asdf/operation
- :asdf/system :asdf/find-system :asdf/defsystem
- :asdf/action :asdf/lisp-action :asdf/bundle)
- (:export
- #:concatenate-source-op
- #:load-concatenated-source-op
- #:compile-concatenated-source-op
- #:load-compiled-concatenated-source-op
- #:monolithic-concatenate-source-op
- #:monolithic-load-concatenated-source-op
- #:monolithic-compile-concatenated-source-op
- #:monolithic-load-compiled-concatenated-source-op))
-(in-package :asdf/concatenate-source)
-
-;;;
-;;; Concatenate sources
-;;;
-(with-upgradability ()
- (defclass basic-concatenate-source-op (bundle-op)
- ((bundle-type :initform "lisp")))
- (defclass basic-load-concatenated-source-op (basic-load-op selfward-operation) ())
- (defclass basic-compile-concatenated-source-op (basic-compile-op selfward-operation) ())
- (defclass basic-load-compiled-concatenated-source-op (basic-load-op selfward-operation) ())
-
- (defclass concatenate-source-op (basic-concatenate-source-op) ())
- (defclass load-concatenated-source-op (basic-load-concatenated-source-op)
- ((selfward-operation :initform '(prepare-op concatenate-source-op))))
- (defclass compile-concatenated-source-op (basic-compile-concatenated-source-op)
- ((selfward-operation :initform '(prepare-op concatenate-source-op))))
- (defclass load-compiled-concatenated-source-op (basic-load-compiled-concatenated-source-op)
- ((selfward-operation :initform '(prepare-op compile-concatenated-source-op))))
-
- (defclass monolithic-concatenate-source-op (basic-concatenate-source-op monolithic-bundle-op) ())
- (defclass monolithic-load-concatenated-source-op (basic-load-concatenated-source-op)
- ((selfward-operation :initform 'monolithic-concatenate-source-op)))
- (defclass monolithic-compile-concatenated-source-op (basic-compile-concatenated-source-op)
- ((selfward-operation :initform 'monolithic-concatenate-source-op)))
- (defclass monolithic-load-compiled-concatenated-source-op (basic-load-compiled-concatenated-source-op)
- ((selfward-operation :initform 'monolithic-compile-concatenated-source-op)))
-
- (defmethod input-files ((operation basic-concatenate-source-op) (s system))
- (loop :with encoding = (or (component-encoding s) *default-encoding*)
- :with other-encodings = '()
- :with around-compile = (around-compile-hook s)
- :with other-around-compile = '()
- :for c :in (required-components
- s :goal-operation 'compile-op
- :keep-operation 'compile-op
- :other-systems (operation-monolithic-p operation))
- :append
- (when (typep c 'cl-source-file)
- (let ((e (component-encoding c)))
- (unless (equal e encoding)
- (let ((a (assoc e other-encodings)))
- (if a (push (component-find-path c) (cdr a))
- (push (list a (component-find-path c)) other-encodings)))))
- (unless (equal around-compile (around-compile-hook c))
- (push (component-find-path c) other-around-compile))
- (input-files (make-operation 'compile-op) c)) :into inputs
- :finally
- (when other-encodings
- (warn "~S uses encoding ~A but has sources that use these encodings:~{ ~A~}"
- operation encoding
- (mapcar #'(lambda (x) (cons (car x) (list (reverse (cdr x)))))
- other-encodings)))
- (when other-around-compile
- (warn "~S uses around-compile hook ~A but has sources that use these hooks: ~A"
- operation around-compile other-around-compile))
- (return inputs)))
- (defmethod output-files ((o basic-compile-concatenated-source-op) (s system))
- (lisp-compilation-output-files o s))
-
- (defmethod perform ((o basic-concatenate-source-op) (s system))
- (let ((inputs (input-files o s))
- (output (output-file o s)))
- (concatenate-files inputs output)))
- (defmethod perform ((o basic-load-concatenated-source-op) (s system))
- (perform-lisp-load-source o s))
- (defmethod perform ((o basic-compile-concatenated-source-op) (s system))
- (perform-lisp-compilation o s))
- (defmethod perform ((o basic-load-compiled-concatenated-source-op) (s system))
- (perform-lisp-load-fasl o s)))
-
-;;;; ---------------------------------------------------------------------------
-;;;; asdf-output-translations
-
-(asdf/package:define-package :asdf/output-translations
- (:recycle :asdf/output-translations :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade)
- (:export
- #:*output-translations* #:*output-translations-parameter*
- #:invalid-output-translation
- #:output-translations #:output-translations-initialized-p
- #:initialize-output-translations #:clear-output-translations
- #:disable-output-translations #:ensure-output-translations
- #:apply-output-translations
- #:validate-output-translations-directive #:validate-output-translations-form
- #:validate-output-translations-file #:validate-output-translations-directory
- #:parse-output-translations-string #:wrapping-output-translations
- #:user-output-translations-pathname #:system-output-translations-pathname
- #:user-output-translations-directory-pathname #:system-output-translations-directory-pathname
- #:environment-output-translations #:process-output-translations
- #:compute-output-translations
- #+abcl #:translate-jar-pathname
- ))
-(in-package :asdf/output-translations)
-
-(when-upgrading () (undefine-function '(setf output-translations)))
-
-(with-upgradability ()
- (define-condition invalid-output-translation (invalid-configuration warning)
- ((format :initform (compatfmt "~@<Invalid asdf output-translation ~S~@[ in ~S~]~@{ ~@?~}~@:>"))))
-
- (defvar *output-translations* ()
- "Either NIL (for uninitialized), or a list of one element,
-said element itself being a sorted list of mappings.
-Each mapping is a pair of a source pathname and destination pathname,
-and the order is by decreasing length of namestring of the source pathname.")
-
- (defun output-translations ()
- (car *output-translations*))
-
- (defun set-output-translations (new-value)
- (setf *output-translations*
- (list
- (stable-sort (copy-list new-value) #'>
- :key #'(lambda (x)
- (etypecase (car x)
- ((eql t) -1)
- (pathname
- (let ((directory (pathname-directory (car x))))
- (if (listp directory) (length directory) 0))))))))
- new-value)
- #-gcl2.6
- (defun* ((setf output-translations)) (new-value) (set-output-translations new-value))
- #+gcl2.6
- (defsetf output-translations set-output-translations)
-
- (defun output-translations-initialized-p ()
- (and *output-translations* t))
-
- (defun clear-output-translations ()
- "Undoes any initialization of the output translations."
- (setf *output-translations* '())
- (values))
- (register-clear-configuration-hook 'clear-output-translations)
-
- (defun validate-output-translations-directive (directive)
- (or (member directive '(:enable-user-cache :disable-cache nil))
- (and (consp directive)
- (or (and (length=n-p directive 2)
- (or (and (eq (first directive) :include)
- (typep (second directive) '(or string pathname null)))
- (and (location-designator-p (first directive))
- (or (location-designator-p (second directive))
- (location-function-p (second directive))))))
- (and (length=n-p directive 1)
- (location-designator-p (first directive)))))))
-
- (defun validate-output-translations-form (form &key location)
- (validate-configuration-form
- form
- :output-translations
- 'validate-output-translations-directive
- :location location :invalid-form-reporter 'invalid-output-translation))
+ (defmethod perform ((o basic-compile-bundle-op) (c prebuilt-system))
+ nil)
- (defun validate-output-translations-file (file)
- (validate-configuration-file
- file 'validate-output-translations-form :description "output translations"))
+ (defmethod perform ((o lib-op) (c prebuilt-system))
+ nil)
- (defun validate-output-translations-directory (directory)
- (validate-configuration-directory
- directory :output-translations 'validate-output-translations-directive
- :invalid-form-reporter 'invalid-output-translation))
+ (defmethod perform ((o dll-op) (c prebuilt-system))
+ nil)
- (defun parse-output-translations-string (string &key location)
- (cond
- ((or (null string) (equal string ""))
- '(:output-translations :inherit-configuration))
- ((not (stringp string))
- (error (compatfmt "~@<Environment string isn't: ~3i~_~S~@:>") string))
- ((eql (char string 0) #\")
- (parse-output-translations-string (read-from-string string) :location location))
- ((eql (char string 0) #\()
- (validate-output-translations-form (read-from-string string) :location location))
- (t
- (loop
- :with inherit = nil
- :with directives = ()
- :with start = 0
- :with end = (length string)
- :with source = nil
- :with separator = (inter-directory-separator)
- :for i = (or (position separator string :start start) end) :do
- (let ((s (subseq string start i)))
- (cond
- (source
- (push (list source (if (equal "" s) nil s)) directives)
- (setf source nil))
- ((equal "" s)
- (when inherit
- (error (compatfmt "~@<Only one inherited configuration allowed: ~3i~_~S~@:>")
- string))
- (setf inherit t)
- (push :inherit-configuration directives))
- (t
- (setf source s)))
- (setf start (1+ i))
- (when (> start end)
- (when source
- (error (compatfmt "~@<Uneven number of components in source to destination mapping: ~3i~_~S~@:>")
- string))
- (unless inherit
- (push :ignore-inherited-configuration directives))
- (return `(:output-translations ,@(nreverse directives)))))))))
+ (defmethod component-depends-on ((o gather-op) (c prebuilt-system))
+ nil)
- (defparameter *default-output-translations*
- '(environment-output-translations
- user-output-translations-pathname
- user-output-translations-directory-pathname
- system-output-translations-pathname
- system-output-translations-directory-pathname))
+ (defmethod output-files ((o lib-op) (c prebuilt-system))
+ (values (list (prebuilt-system-static-library c)) t)))
- (defun wrapping-output-translations ()
- `(:output-translations
- ;; Some implementations have precompiled ASDF systems,
- ;; so we must disable translations for implementation paths.
- #+(or #|clozure|# ecl mkcl sbcl)
- ,@(let ((h (resolve-symlinks* (lisp-implementation-directory))))
- (when h `(((,h ,*wild-path*) ()))))
- #+mkcl (,(translate-logical-pathname "CONTRIB:") ())
- ;; All-import, here is where we want user stuff to be:
- :inherit-configuration
- ;; These are for convenience, and can be overridden by the user:
- #+abcl (#p"/___jar___file___root___/**/*.*" (:user-cache #p"**/*.*"))
- #+abcl (#p"jar:file:/**/*.jar!/**/*.*" (:function translate-jar-pathname))
- ;; We enable the user cache by default, and here is the place we do:
- :enable-user-cache))
- (defparameter *output-translations-file* (parse-unix-namestring "asdf-output-translations.conf"))
- (defparameter *output-translations-directory* (parse-unix-namestring "asdf-output-translations.conf.d/"))
+;;;
+;;; PREBUILT SYSTEM CREATOR
+;;;
+(with-upgradability ()
+ (defmethod output-files ((o deliver-asd-op) (s system))
+ (list (make-pathname :name (component-name s) :type "asd"
+ :defaults (component-pathname s))))
- (defun user-output-translations-pathname (&key (direction :input))
- (in-user-configuration-directory *output-translations-file* :direction direction))
- (defun system-output-translations-pathname (&key (direction :input))
- (in-system-configuration-directory *output-translations-file* :direction direction))
- (defun user-output-translations-directory-pathname (&key (direction :input))
- (in-user-configuration-directory *output-translations-directory* :direction direction))
- (defun system-output-translations-directory-pathname (&key (direction :input))
- (in-system-configuration-directory *output-translations-directory* :direction direction))
- (defun environment-output-translations ()
- (getenv "ASDF_OUTPUT_TRANSLATIONS"))
+ (defmethod perform ((o deliver-asd-op) (s system))
+ (let* ((inputs (input-files o s))
+ (fasl (first inputs))
+ (library (second inputs))
+ (asd (first (output-files o s)))
+ (name (if (and fasl asd) (pathname-name asd) (return-from perform)))
+ (version (component-version s))
+ (dependencies
+ (if (operation-monolithic-p o)
+ (remove-if-not 'builtin-system-p
+ (required-components s :component-type 'system
+ :keep-operation 'load-op))
+ (while-collecting (x) ;; resolve the sideway-dependencies of s
+ (map-direct-dependencies
+ t 'load-op s
+ #'(lambda (o c)
+ (when (and (typep o 'load-op) (typep c 'system))
+ (x c)))))))
+ (depends-on (mapcar 'coerce-name dependencies)))
+ (when (pathname-equal asd (system-source-file s))
+ (cerror "overwrite the asd file"
+ "~/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."
+ (cons o s) asd))
+ (with-open-file (s asd :direction :output :if-exists :supersede
+ :if-does-not-exist :create)
+ (format s ";;; Prebuilt~:[~; monolithic~] ASDF definition for system ~A~%"
+ (operation-monolithic-p o) name)
+ (format s ";;; Built for ~A ~A on a ~A/~A ~A~%"
+ (lisp-implementation-type)
+ (lisp-implementation-version)
+ (software-type)
+ (machine-type)
+ (software-version))
+ (let ((*package* (find-package :asdf-user)))
+ (pprint `(defsystem ,name
+ :class prebuilt-system
+ :version ,version
+ :depends-on ,depends-on
+ :components ((:compiled-file ,(pathname-name fasl)))
+ ,@(when library `(:lib ,(file-namestring library))))
+ s)
+ (terpri s)))))
- (defgeneric process-output-translations (spec &key inherit collect))
+ #-(or ecl mkcl)
+ (defmethod perform ((o basic-compile-bundle-op) (c system))
+ (let* ((input-files (input-files o c))
+ (fasl-files (remove (compile-file-type) input-files :key #'pathname-type :test-not #'equalp))
+ (non-fasl-files (remove (compile-file-type) input-files :key #'pathname-type :test #'equalp))
+ (output-files (output-files o c))
+ (output-file (first output-files)))
+ (assert (eq (not input-files) (not output-files)))
+ (when input-files
+ (when non-fasl-files
+ (error "On ~A, asdf/bundle can only bundle FASL files, but these were also produced: ~S"
+ (implementation-type) non-fasl-files))
+ (when (or (prologue-code o) (epilogue-code o)
+ (prologue-code c) (epilogue-code c))
+ (error "prologue-code and epilogue-code are not supported on ~A"
+ (implementation-type)))
+ (with-staging-pathname (output-file)
+ (combine-fasls fasl-files output-file)))))
- (defun inherit-output-translations (inherit &key collect)
- (when inherit
- (process-output-translations (first inherit) :collect collect :inherit (rest inherit))))
+ (defmethod input-files ((o load-op) (s precompiled-system))
+ (bundle-output-files (find-operation o 'compile-bundle-op) s))
- (defun* (process-output-translations-directive) (directive &key inherit collect)
- (if (atom directive)
- (ecase directive
- ((:enable-user-cache)
- (process-output-translations-directive '(t :user-cache) :collect collect))
- ((:disable-cache)
- (process-output-translations-directive '(t t) :collect collect))
- ((:inherit-configuration)
- (inherit-output-translations inherit :collect collect))
- ((:ignore-inherited-configuration :ignore-invalid-entries nil)
- nil))
- (let ((src (first directive))
- (dst (second directive)))
- (if (eq src :include)
- (when dst
- (process-output-translations (pathname dst) :inherit nil :collect collect))
- (when src
- (let ((trusrc (or (eql src t)
- (let ((loc (resolve-location src :ensure-directory t :wilden t)))
- (if (absolute-pathname-p loc) (resolve-symlinks* loc) loc)))))
- (cond
- ((location-function-p dst)
- (funcall collect
- (list trusrc (ensure-function (second dst)))))
- ((eq dst t)
- (funcall collect (list trusrc t)))
- (t
- (let* ((trudst (if dst
- (resolve-location dst :ensure-directory t :wilden t)
- trusrc)))
- (funcall collect (list trudst t))
- (funcall collect (list trusrc trudst)))))))))))
+ (defmethod perform ((o load-op) (s precompiled-system))
+ (perform-lisp-load-fasl o s))
- (defmethod process-output-translations ((x symbol) &key
- (inherit *default-output-translations*)
- collect)
- (process-output-translations (funcall x) :inherit inherit :collect collect))
- (defmethod process-output-translations ((pathname #-gcl2.6 pathname #+gcl2.6 t) &key inherit collect)
- (cond
- ((directory-pathname-p pathname)
- (process-output-translations (validate-output-translations-directory pathname)
- :inherit inherit :collect collect))
- ((probe-file* pathname :truename *resolve-symlinks*)
- (process-output-translations (validate-output-translations-file pathname)
- :inherit inherit :collect collect))
- (t
- (inherit-output-translations inherit :collect collect))))
- (defmethod process-output-translations ((string string) &key inherit collect)
- (process-output-translations (parse-output-translations-string string)
- :inherit inherit :collect collect))
- (defmethod process-output-translations ((x null) &key inherit collect)
- (declare (ignorable x))
- (inherit-output-translations inherit :collect collect))
- (defmethod process-output-translations ((form cons) &key inherit collect)
- (dolist (directive (cdr (validate-output-translations-form form)))
- (process-output-translations-directive directive :inherit inherit :collect collect)))
+ (defmethod component-depends-on ((o load-bundle-op) (s precompiled-system))
+ #+xcl (declare (ignorable o))
+ `((load-op ,s) ,@(call-next-method))))
- (defun compute-output-translations (&optional parameter)
- "read the configuration, return it"
- (remove-duplicates
- (while-collecting (c)
- (inherit-output-translations
- `(wrapping-output-translations ,parameter ,@*default-output-translations*) :collect #'c))
- :test 'equal :from-end t))
+#| ;; Example use:
+(asdf:defsystem :precompiled-asdf-utils :class asdf::precompiled-system :fasl (asdf:apply-output-translations (asdf:system-relative-pathname :asdf-utils "asdf-utils.system.fasl")))
+(asdf:load-system :precompiled-asdf-utils)
+|#
- (defvar *output-translations-parameter* nil)
+#+(or ecl mkcl)
+(with-upgradability ()
+ ;; I think that Juanjo intended for this to be,
+ ;; but beware the weird bug in test-xach-update-bug.script,
+ ;; and also it makes mkcl fail test-logical-pathname.script,
+ ;; and ecl fail test-bundle.script.
+ ;;(unless (or #+ecl (use-ecl-byte-compiler-p))
+ ;; (setf *load-system-operation* 'load-bundle-op))
+
+ (defun asdf-library-pathname ()
+ #+ecl (or (probe-file* (compile-file-pathname "sys:asdf" :type :lib)) ;; new style
+ (probe-file* (compile-file-pathname "sys:asdf" :type :object))) ;; old style
+ #+mkcl (make-pathname :type (bundle-pathname-type :lib) :defaults #p"sys:contrib;asdf"))
+
+ (defun compiler-library-pathname ()
+ #+ecl (compile-file-pathname "sys:cmp" :type :lib)
+ #+mkcl (make-pathname :type (bundle-pathname-type :lib) :defaults #p"sys:cmp"))
+
+ (defun make-library-system (name pathname)
+ (make-instance 'prebuilt-system
+ :name (coerce-name name) :static-library (resolve-symlinks* pathname)))
+
+ (defmethod component-depends-on :around ((o image-op) (c system))
+ (destructuring-bind ((lib-op . deps)) (call-next-method)
+ (flet ((has-it-p (x) (find x deps :test 'equal :key 'coerce-name)))
+ `((,lib-op
+ ,@(unless (or (no-uiop c) (has-it-p "cmp"))
+ `(,(make-library-system
+ "cmp" (compiler-library-pathname))))
+ ,@(unless (or (no-uiop c) (has-it-p "uiop") (has-it-p "asdf"))
+ `(,(cond
+ ((system-source-directory :uiop) (find-system :uiop))
+ ((system-source-directory :asdf) (find-system :asdf))
+ (t (make-library-system "asdf" (asdf-library-pathname))))))
+ , at deps)))))
+
+ (defmethod perform ((o link-op) (c system))
+ (let* ((object-files (input-files o c))
+ (output (output-files o c))
+ (bundle (first output))
+ (programp (typep o 'program-op))
+ (kind (bundle-type o)))
+ (when output
+ (apply 'create-image
+ bundle (append
+ (when programp (prefix-lisp-object-files c))
+ object-files
+ (when programp (postfix-lisp-object-files c)))
+ :kind kind
+ :prologue-code (or (prologue-code o) (when programp (prologue-code c)))
+ :epilogue-code (or (epilogue-code o) (when programp (epilogue-code c)))
+ :build-args (or (extra-build-args o) (when programp (extra-build-args c)))
+ :extra-object-files (or (extra-object-files o) (when programp (extra-object-files c)))
+ :no-uiop (no-uiop c)
+ (when programp `(:entry-point ,(component-entry-point c))))))))
+
+#+(and (not asdf-use-unsafe-mac-bundle-op)
+ (or (and ecl darwin)
+ (and abcl darwin (not abcl-bundle-op-supported))))
+(defmethod perform :before ((o basic-compile-bundle-op) (c component))
+ (unless (featurep :asdf-use-unsafe-mac-bundle-op)
+ (cerror "Continue after modifying *FEATURES*."
+ "BASIC-COMPILE-BUNDLE-OP operations are not supported on Mac OS X for this lisp.~%~T~
+To continue, push :asdf-use-unsafe-mac-bundle-op onto *FEATURES*.~%~T~
+Please report to ASDF-DEVEL if this works for you.")))
+
+
+;;; Backward compatibility with pre-3.1.1 names
+(defclass fasl-op (selfward-operation)
+ ((selfward-operation :initform 'compile-bundle-op :allocation :class)))
+(defclass load-fasl-op (selfward-operation)
+ ((selfward-operation :initform 'load-bundle-op :allocation :class)))
+(defclass binary-op (selfward-operation)
+ ((selfward-operation :initform 'deliver-asd-op :allocation :class)))
+(defclass monolithic-fasl-op (selfward-operation)
+ ((selfward-operation :initform 'monolithic-compile-bundle-op :allocation :class)))
+(defclass monolithic-load-fasl-op (selfward-operation)
+ ((selfward-operation :initform 'monolithic-load-bundle-op :allocation :class)))
+(defclass monolithic-binary-op (selfward-operation)
+ ((selfward-operation :initform 'monolithic-deliver-asd-op :allocation :class)))
+;;;; -------------------------------------------------------------------------
+;;;; Concatenate-source
- (defun initialize-output-translations (&optional (parameter *output-translations-parameter*))
- "read the configuration, initialize the internal configuration variable,
-return the configuration"
- (setf *output-translations-parameter* parameter
- (output-translations) (compute-output-translations parameter)))
+(uiop/package:define-package :asdf/concatenate-source
+ (:recycle :asdf/concatenate-source :asdf)
+ (:use :uiop/common-lisp :uiop :asdf/upgrade
+ :asdf/component :asdf/operation
+ :asdf/system :asdf/find-system
+ :asdf/action :asdf/lisp-action :asdf/bundle)
+ (:export
+ #:concatenate-source-op
+ #:load-concatenated-source-op
+ #:compile-concatenated-source-op
+ #:load-compiled-concatenated-source-op
+ #:monolithic-concatenate-source-op
+ #:monolithic-load-concatenated-source-op
+ #:monolithic-compile-concatenated-source-op
+ #:monolithic-load-compiled-concatenated-source-op))
+(in-package :asdf/concatenate-source)
- (defun disable-output-translations ()
- "Initialize output translations in a way that maps every file to itself,
-effectively disabling the output translation facility."
- (initialize-output-translations
- '(:output-translations :disable-cache :ignore-inherited-configuration)))
+;;;
+;;; Concatenate sources
+;;;
+(with-upgradability ()
+ (defclass basic-concatenate-source-op (bundle-op)
+ ((bundle-type :initform "lisp")))
+ (defclass basic-load-concatenated-source-op (basic-load-op selfward-operation) ())
+ (defclass basic-compile-concatenated-source-op (basic-compile-op selfward-operation) ())
+ (defclass basic-load-compiled-concatenated-source-op (basic-load-op selfward-operation) ())
- ;; checks an initial variable to see whether the state is initialized
- ;; or cleared. In the former case, return current configuration; in
- ;; the latter, initialize. ASDF will call this function at the start
- ;; of (asdf:find-system).
- (defun ensure-output-translations ()
- (if (output-translations-initialized-p)
- (output-translations)
- (initialize-output-translations)))
+ (defclass concatenate-source-op (basic-concatenate-source-op non-propagating-operation) ())
+ (defclass load-concatenated-source-op (basic-load-concatenated-source-op)
+ ((selfward-operation :initform '(prepare-op concatenate-source-op) :allocation :class)))
+ (defclass compile-concatenated-source-op (basic-compile-concatenated-source-op)
+ ((selfward-operation :initform '(prepare-op concatenate-source-op) :allocation :class)))
+ (defclass load-compiled-concatenated-source-op (basic-load-compiled-concatenated-source-op)
+ ((selfward-operation :initform '(prepare-op compile-concatenated-source-op) :allocation :class)))
- (defun* (apply-output-translations) (path)
- (etypecase path
- (logical-pathname
- path)
- ((or pathname string)
- (ensure-output-translations)
- (loop* :with p = (resolve-symlinks* path)
- :for (source destination) :in (car *output-translations*)
- :for root = (when (or (eq source t)
- (and (pathnamep source)
- (not (absolute-pathname-p source))))
- (pathname-root p))
- :for absolute-source = (cond
- ((eq source t) (wilden root))
- (root (merge-pathnames* source root))
- (t source))
- :when (or (eq source t) (pathname-match-p p absolute-source))
- :return (translate-pathname* p absolute-source destination root source)
- :finally (return p)))))
+ (defclass monolithic-concatenate-source-op (basic-concatenate-source-op monolithic-bundle-op non-propagating-operation) ())
+ (defclass monolithic-load-concatenated-source-op (basic-load-concatenated-source-op)
+ ((selfward-operation :initform 'monolithic-concatenate-source-op :allocation :class)))
+ (defclass monolithic-compile-concatenated-source-op (basic-compile-concatenated-source-op)
+ ((selfward-operation :initform 'monolithic-concatenate-source-op :allocation :class)))
+ (defclass monolithic-load-compiled-concatenated-source-op (basic-load-compiled-concatenated-source-op)
+ ((selfward-operation :initform 'monolithic-compile-concatenated-source-op :allocation :class)))
- ;; Hook into uiop's output-translation mechanism
- #-cormanlisp
- (setf *output-translation-function* 'apply-output-translations)
+ (defmethod input-files ((operation basic-concatenate-source-op) (s system))
+ (loop :with encoding = (or (component-encoding s) *default-encoding*)
+ :with other-encodings = '()
+ :with around-compile = (around-compile-hook s)
+ :with other-around-compile = '()
+ :for c :in (required-components
+ s :goal-operation 'compile-op
+ :keep-operation 'compile-op
+ :other-systems (operation-monolithic-p operation))
+ :append
+ (when (typep c 'cl-source-file)
+ (let ((e (component-encoding c)))
+ (unless (equal e encoding)
+ (let ((a (assoc e other-encodings)))
+ (if a (push (component-find-path c) (cdr a))
+ (push (list a (component-find-path c)) other-encodings)))))
+ (unless (equal around-compile (around-compile-hook c))
+ (push (component-find-path c) other-around-compile))
+ (input-files (make-operation 'compile-op) c)) :into inputs
+ :finally
+ (when other-encodings
+ (warn "~S uses encoding ~A but has sources that use these encodings:~{ ~A~}"
+ operation encoding
+ (mapcar #'(lambda (x) (cons (car x) (list (reverse (cdr x)))))
+ other-encodings)))
+ (when other-around-compile
+ (warn "~S uses around-compile hook ~A but has sources that use these hooks: ~A"
+ operation around-compile other-around-compile))
+ (return inputs)))
+ (defmethod output-files ((o basic-compile-concatenated-source-op) (s system))
+ (lisp-compilation-output-files o s))
- #+abcl
- (defun translate-jar-pathname (source wildcard)
- (declare (ignore wildcard))
- (flet ((normalize-device (pathname)
- (if (find :windows *features*)
- pathname
- (make-pathname :defaults pathname :device :unspecific))))
- (let* ((jar
- (pathname (first (pathname-device source))))
- (target-root-directory-namestring
- (format nil "/___jar___file___root___/~@[~A/~]"
- (and (find :windows *features*)
- (pathname-device jar))))
- (relative-source
- (relativize-pathname-directory source))
- (relative-jar
- (relativize-pathname-directory (ensure-directory-pathname jar)))
- (target-root-directory
- (normalize-device
- (pathname-directory-pathname
- (parse-namestring target-root-directory-namestring))))
- (target-root
- (merge-pathnames* relative-jar target-root-directory))
- (target
- (merge-pathnames* relative-source target-root)))
- (normalize-device (apply-output-translations target))))))
+ (defmethod perform ((o basic-concatenate-source-op) (s system))
+ (let* ((ins (input-files o s))
+ (out (output-file o s))
+ (tmp (tmpize-pathname out)))
+ (concatenate-files ins tmp)
+ (rename-file-overwriting-target tmp out)))
+ (defmethod perform ((o basic-load-concatenated-source-op) (s system))
+ (perform-lisp-load-source o s))
+ (defmethod perform ((o basic-compile-concatenated-source-op) (s system))
+ (perform-lisp-compilation o s))
+ (defmethod perform ((o basic-load-compiled-concatenated-source-op) (s system))
+ (perform-lisp-load-fasl o s)))
;;;; -------------------------------------------------------------------------
;;; Backward-compatible interfaces
-(asdf/package:define-package :asdf/backward-interface
+(uiop/package:define-package :asdf/backward-interface
(:recycle :asdf/backward-interface :asdf)
(:use :uiop/common-lisp :uiop :asdf/upgrade
:asdf/component :asdf/system :asdf/find-system :asdf/operation :asdf/action
@@ -10057,16 +10829,16 @@ effectively disabling the output translation facility."
(defgeneric operation-on-warnings (operation))
(defgeneric operation-on-failure (operation))
- #-gcl2.6 (defgeneric (setf operation-on-warnings) (x operation))
- #-gcl2.6 (defgeneric (setf operation-on-failure) (x operation))
+ (defgeneric (setf operation-on-warnings) (x operation))
+ (defgeneric (setf operation-on-failure) (x operation))
(defmethod operation-on-warnings ((o operation))
- (declare (ignorable o)) *compile-file-warnings-behaviour*)
+ *compile-file-warnings-behaviour*)
(defmethod operation-on-failure ((o operation))
- (declare (ignorable o)) *compile-file-failure-behaviour*)
+ *compile-file-failure-behaviour*)
(defmethod (setf operation-on-warnings) (x (o operation))
- (declare (ignorable o)) (setf *compile-file-warnings-behaviour* x))
+ (setf *compile-file-warnings-behaviour* x))
(defmethod (setf operation-on-failure) (x (o operation))
- (declare (ignorable o)) (setf *compile-file-failure-behaviour* x))
+ (setf *compile-file-failure-behaviour* x))
(defun system-definition-pathname (x)
;; As of 2.014.8, we mean to make this function obsolete,
@@ -10132,420 +10904,239 @@ processed in order by OPERATE."))
,@(loop :for pattern :in patterns
:collect `((:root ,*wild-inferiors* ,pattern)
(, at destination-directory ,pattern)))
- (t t)
- :ignore-inherited-configuration))))
-
- (defmethod operate :before (operation-class system &rest args &key &allow-other-keys)
- (declare (ignorable operation-class system args))
- (when (find-symbol* '#:output-files-for-system-and-operation :asdf nil)
- (error "ASDF 2 is not compatible with ASDF-BINARY-LOCATIONS, which you are using.
-ASDF 2 now achieves the same purpose with its builtin ASDF-OUTPUT-TRANSLATIONS,
-which should be easier to configure. Please stop using ASDF-BINARY-LOCATIONS,
-and instead use ASDF-OUTPUT-TRANSLATIONS. See the ASDF manual for details.
-In case you insist on preserving your previous A-B-L configuration, but
-do not know how to achieve the same effect with A-O-T, you may use function
-ASDF:ENABLE-ASDF-BINARY-LOCATIONS-COMPATIBILITY as documented in the manual;
-call that function where you would otherwise have loaded and configured A-B-L."))))
-
-
-;;; run-shell-command
-;; WARNING! The function below is not just deprecated but also dysfunctional.
-;; Please use asdf/run-program:run-program instead.
-(with-upgradability ()
- (defun run-shell-command (control-string &rest args)
- "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and
-synchronously execute the result using a Bourne-compatible shell, with
-output to *VERBOSE-OUT*. Returns the shell's exit code.
-
-PLEASE DO NOT USE.
-Deprecated function, for backward-compatibility only.
-Please use UIOP:RUN-PROGRAM instead."
- (let ((command (apply 'format nil control-string args)))
- (asdf-message "; $ ~A~%" command)
- (let ((exit-code
- (ignore-errors
- (nth-value 2 (run-program command :force-shell t :ignore-error-status t
- :output *verbose-out*)))))
- (typecase exit-code
- ((integer 0 255) exit-code)
- (t 255))))))
-
-(with-upgradability ()
- (defvar *asdf-verbose* nil)) ;; backward-compatibility with ASDF2 only. Unused.
-
-;; backward-compatibility methods. Do NOT use in new code. NOT SUPPORTED.
-(with-upgradability ()
- (defgeneric component-property (component property))
- (defgeneric (setf component-property) (new-value component property))
-
- (defmethod component-property ((c component) property)
- (cdr (assoc property (slot-value c 'properties) :test #'equal)))
-
- (defmethod (setf component-property) (new-value (c component) property)
- (let ((a (assoc property (slot-value c 'properties) :test #'equal)))
- (if a
- (setf (cdr a) new-value)
- (setf (slot-value c 'properties)
- (acons property new-value (slot-value c 'properties)))))
- new-value))
-;;;; -----------------------------------------------------------------
-;;;; Source Registry Configuration, by Francois-Rene Rideau
-;;;; See the Manual and https://bugs.launchpad.net/asdf/+bug/485918
-
-(asdf/package:define-package :asdf/source-registry
- (:recycle :asdf/source-registry :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/find-system)
- (:export
- #:*source-registry-parameter* #:*default-source-registries*
- #:invalid-source-registry
- #:source-registry-initialized-p
- #:initialize-source-registry #:clear-source-registry #:*source-registry*
- #:ensure-source-registry #:*source-registry-parameter*
- #:*default-source-registry-exclusions* #:*source-registry-exclusions*
- #:*wild-asd* #:directory-asd-files #:register-asd-directory
- #:collect-asds-in-directory #:collect-sub*directories-asd-files
- #:validate-source-registry-directive #:validate-source-registry-form
- #:validate-source-registry-file #:validate-source-registry-directory
- #:parse-source-registry-string #:wrapping-source-registry #:default-source-registry
- #:user-source-registry #:system-source-registry
- #:user-source-registry-directory #:system-source-registry-directory
- #:environment-source-registry #:process-source-registry
- #:compute-source-registry #:flatten-source-registry
- #:sysdef-source-registry-search))
-(in-package :asdf/source-registry)
-
-(with-upgradability ()
- (define-condition invalid-source-registry (invalid-configuration warning)
- ((format :initform (compatfmt "~@<Invalid source registry ~S~@[ in ~S~]~@{ ~@?~}~@:>"))))
-
- ;; Using ack 1.2 exclusions
- (defvar *default-source-registry-exclusions*
- '(".bzr" ".cdv"
- ;; "~.dep" "~.dot" "~.nib" "~.plst" ; we don't support ack wildcards
- ".git" ".hg" ".pc" ".svn" "CVS" "RCS" "SCCS" "_darcs"
- "_sgbak" "autom4te.cache" "cover_db" "_build"
- "debian")) ;; debian often builds stuff under the debian directory... BAD.
-
- (defvar *source-registry-exclusions* *default-source-registry-exclusions*)
-
- (defvar *source-registry* nil
- "Either NIL (for uninitialized), or an equal hash-table, mapping
-system names to pathnames of .asd files")
-
- (defun source-registry-initialized-p ()
- (typep *source-registry* 'hash-table))
-
- (defun clear-source-registry ()
- "Undoes any initialization of the source registry."
- (setf *source-registry* nil)
- (values))
- (register-clear-configuration-hook 'clear-source-registry)
-
- (defparameter *wild-asd*
- (make-pathname* :directory nil :name *wild* :type "asd" :version :newest))
-
- (defun directory-asd-files (directory)
- (directory-files directory *wild-asd*))
-
- (defun collect-asds-in-directory (directory collect)
- (map () collect (directory-asd-files directory)))
-
- (defun collect-sub*directories-asd-files
- (directory &key (exclude *default-source-registry-exclusions*) collect)
- (collect-sub*directories
- directory
- (constantly t)
- #'(lambda (x &aux (l (car (last (pathname-directory x))))) (not (member l exclude :test #'equal)))
- #'(lambda (dir) (collect-asds-in-directory dir collect))))
-
- (defun validate-source-registry-directive (directive)
- (or (member directive '(:default-registry))
- (and (consp directive)
- (let ((rest (rest directive)))
- (case (first directive)
- ((:include :directory :tree)
- (and (length=n-p rest 1)
- (location-designator-p (first rest))))
- ((:exclude :also-exclude)
- (every #'stringp rest))
- ((:default-registry)
- (null rest)))))))
-
- (defun validate-source-registry-form (form &key location)
- (validate-configuration-form
- form :source-registry 'validate-source-registry-directive
- :location location :invalid-form-reporter 'invalid-source-registry))
-
- (defun validate-source-registry-file (file)
- (validate-configuration-file
- file 'validate-source-registry-form :description "a source registry"))
-
- (defun validate-source-registry-directory (directory)
- (validate-configuration-directory
- directory :source-registry 'validate-source-registry-directive
- :invalid-form-reporter 'invalid-source-registry))
+ (t t)
+ :ignore-inherited-configuration))))
- (defun parse-source-registry-string (string &key location)
- (cond
- ((or (null string) (equal string ""))
- '(:source-registry :inherit-configuration))
- ((not (stringp string))
- (error (compatfmt "~@<Environment string isn't: ~3i~_~S~@:>") string))
- ((find (char string 0) "\"(")
- (validate-source-registry-form (read-from-string string) :location location))
- (t
- (loop
- :with inherit = nil
- :with directives = ()
- :with start = 0
- :with end = (length string)
- :with separator = (inter-directory-separator)
- :for pos = (position separator string :start start) :do
- (let ((s (subseq string start (or pos end))))
- (flet ((check (dir)
- (unless (absolute-pathname-p dir)
- (error (compatfmt "~@<source-registry string must specify absolute pathnames: ~3i~_~S~@:>") string))
- dir))
- (cond
- ((equal "" s) ; empty element: inherit
- (when inherit
- (error (compatfmt "~@<Only one inherited configuration allowed: ~3i~_~S~@:>")
- string))
- (setf inherit t)
- (push ':inherit-configuration directives))
- ((string-suffix-p s "//") ;; TODO: allow for doubling of separator even outside Unix?
- (push `(:tree ,(check (subseq s 0 (- (length s) 2)))) directives))
- (t
- (push `(:directory ,(check s)) directives))))
- (cond
- (pos
- (setf start (1+ pos)))
- (t
- (unless inherit
- (push '(:ignore-inherited-configuration) directives))
- (return `(:source-registry ,@(nreverse directives))))))))))
+ (defmethod operate :before (operation-class system &rest args &key &allow-other-keys)
+ (declare (ignore operation-class system args))
+ (when (find-symbol* '#:output-files-for-system-and-operation :asdf nil)
+ (error "ASDF 2 is not compatible with ASDF-BINARY-LOCATIONS, which you are using.
+ASDF 2 now achieves the same purpose with its builtin ASDF-OUTPUT-TRANSLATIONS,
+which should be easier to configure. Please stop using ASDF-BINARY-LOCATIONS,
+and instead use ASDF-OUTPUT-TRANSLATIONS. See the ASDF manual for details.
+In case you insist on preserving your previous A-B-L configuration, but
+do not know how to achieve the same effect with A-O-T, you may use function
+ASDF:ENABLE-ASDF-BINARY-LOCATIONS-COMPATIBILITY as documented in the manual;
+call that function where you would otherwise have loaded and configured A-B-L."))))
- (defun register-asd-directory (directory &key recurse exclude collect)
- (if (not recurse)
- (collect-asds-in-directory directory collect)
- (collect-sub*directories-asd-files
- directory :exclude exclude :collect collect)))
- (defparameter *default-source-registries*
- '(environment-source-registry
- user-source-registry
- user-source-registry-directory
- system-source-registry
- system-source-registry-directory
- default-source-registry))
+;;; run-shell-command
+;; WARNING! The function below is not just deprecated but also dysfunctional.
+;; Please use asdf/run-program:run-program instead.
+(with-upgradability ()
+ (defun run-shell-command (control-string &rest args)
+ "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and
+synchronously execute the result using a Bourne-compatible shell, with
+output to *VERBOSE-OUT*. Returns the shell's exit code.
- (defparameter *source-registry-file* (parse-unix-namestring "source-registry.conf"))
- (defparameter *source-registry-directory* (parse-unix-namestring "source-registry.conf.d/"))
+PLEASE DO NOT USE.
+Deprecated function, for backward-compatibility only.
+Please use UIOP:RUN-PROGRAM instead."
+ (let ((command (apply 'format nil control-string args)))
+ (asdf-message "; $ ~A~%" command)
+ (let ((exit-code
+ (ignore-errors
+ (nth-value 2 (run-program command :force-shell t :ignore-error-status t
+ :output *verbose-out*)))))
+ (typecase exit-code
+ ((integer 0 255) exit-code)
+ (t 255))))))
- (defun wrapping-source-registry ()
- `(:source-registry
- #+(or ecl sbcl) (:tree ,(resolve-symlinks* (lisp-implementation-directory)))
- #+mkcl (:tree ,(translate-logical-pathname "CONTRIB:"))
- :inherit-configuration
- #+cmu (:tree #p"modules:")
- #+scl (:tree #p"file://modules/")))
- (defun default-source-registry ()
- `(:source-registry
- #+sbcl (:directory ,(subpathname (user-homedir-pathname) ".sbcl/systems/"))
- ,@(loop :for dir :in
- `(,@(when (os-unix-p)
- `(,(or (getenv-absolute-directory "XDG_DATA_HOME")
- (subpathname (user-homedir-pathname) ".local/share/"))
- ,@(or (getenv-absolute-directories "XDG_DATA_DIRS")
- '("/usr/local/share" "/usr/share"))))
- ,@(when (os-windows-p)
- (mapcar 'get-folder-path '(:local-appdata :appdata :common-appdata))))
- :collect `(:directory ,(subpathname* dir "common-lisp/systems/"))
- :collect `(:tree ,(subpathname* dir "common-lisp/source/")))
- :inherit-configuration))
- (defun user-source-registry (&key (direction :input))
- (in-user-configuration-directory *source-registry-file* :direction direction))
- (defun system-source-registry (&key (direction :input))
- (in-system-configuration-directory *source-registry-file* :direction direction))
- (defun user-source-registry-directory (&key (direction :input))
- (in-user-configuration-directory *source-registry-directory* :direction direction))
- (defun system-source-registry-directory (&key (direction :input))
- (in-system-configuration-directory *source-registry-directory* :direction direction))
- (defun environment-source-registry ()
- (getenv "CL_SOURCE_REGISTRY"))
+(with-upgradability ()
+ (defvar *asdf-verbose* nil)) ;; backward-compatibility with ASDF2 only. Unused.
- (defgeneric* (process-source-registry) (spec &key inherit register))
+;; backward-compatibility methods. Do NOT use in new code. NOT SUPPORTED.
+(with-upgradability ()
+ (defgeneric component-property (component property))
+ (defgeneric (setf component-property) (new-value component property))
- (defun* (inherit-source-registry) (inherit &key register)
- (when inherit
- (process-source-registry (first inherit) :register register :inherit (rest inherit))))
+ (defmethod component-property ((c component) property)
+ (cdr (assoc property (slot-value c 'properties) :test #'equal)))
- (defun* (process-source-registry-directive) (directive &key inherit register)
- (destructuring-bind (kw &rest rest) (if (consp directive) directive (list directive))
- (ecase kw
- ((:include)
- (destructuring-bind (pathname) rest
- (process-source-registry (resolve-location pathname) :inherit nil :register register)))
- ((:directory)
- (destructuring-bind (pathname) rest
- (when pathname
- (funcall register (resolve-location pathname :ensure-directory t)))))
- ((:tree)
- (destructuring-bind (pathname) rest
- (when pathname
- (funcall register (resolve-location pathname :ensure-directory t)
- :recurse t :exclude *source-registry-exclusions*))))
- ((:exclude)
- (setf *source-registry-exclusions* rest))
- ((:also-exclude)
- (appendf *source-registry-exclusions* rest))
- ((:default-registry)
- (inherit-source-registry '(default-source-registry) :register register))
- ((:inherit-configuration)
- (inherit-source-registry inherit :register register))
- ((:ignore-inherited-configuration)
- nil)))
- nil)
+ (defmethod (setf component-property) (new-value (c component) property)
+ (let ((a (assoc property (slot-value c 'properties) :test #'equal)))
+ (if a
+ (setf (cdr a) new-value)
+ (setf (slot-value c 'properties)
+ (acons property new-value (slot-value c 'properties)))))
+ new-value))
+;;;; -------------------------------------------------------------------------
+;;;; Package systems in the style of quick-build or faslpath
- (defmethod process-source-registry ((x symbol) &key inherit register)
- (process-source-registry (funcall x) :inherit inherit :register register))
- (defmethod process-source-registry ((pathname #-gcl2.6 pathname #+gcl2.6 t) &key inherit register)
- (cond
- ((directory-pathname-p pathname)
- (let ((*here-directory* (resolve-symlinks* pathname)))
- (process-source-registry (validate-source-registry-directory pathname)
- :inherit inherit :register register)))
- ((probe-file* pathname :truename *resolve-symlinks*)
- (let ((*here-directory* (pathname-directory-pathname pathname)))
- (process-source-registry (validate-source-registry-file pathname)
- :inherit inherit :register register)))
- (t
- (inherit-source-registry inherit :register register))))
- (defmethod process-source-registry ((string string) &key inherit register)
- (process-source-registry (parse-source-registry-string string)
- :inherit inherit :register register))
- (defmethod process-source-registry ((x null) &key inherit register)
- (declare (ignorable x))
- (inherit-source-registry inherit :register register))
- (defmethod process-source-registry ((form cons) &key inherit register)
- (let ((*source-registry-exclusions* *default-source-registry-exclusions*))
- (dolist (directive (cdr (validate-source-registry-form form)))
- (process-source-registry-directive directive :inherit inherit :register register))))
+(uiop:define-package :asdf/package-inferred-system
+ (:recycle :asdf/package-inferred-system :asdf/package-system :asdf)
+ (:use :uiop/common-lisp :uiop
+ :asdf/defsystem ;; Using the old name of :asdf/parse-defsystem for compatibility
+ :asdf/upgrade :asdf/component :asdf/system :asdf/find-system :asdf/lisp-action)
+ (:export
+ #:package-inferred-system #:sysdef-package-inferred-system-search
+ #:package-system ;; backward compatibility only. To be removed.
+ #:register-system-packages
+ #:*defpackage-forms* #:*package-inferred-systems* #:package-inferred-system-missing-package-error))
+(in-package :asdf/package-inferred-system)
- (defun flatten-source-registry (&optional parameter)
- (remove-duplicates
- (while-collecting (collect)
- (with-pathname-defaults () ;; be location-independent
- (inherit-source-registry
- `(wrapping-source-registry
- ,parameter
- ,@*default-source-registries*)
- :register #'(lambda (directory &key recurse exclude)
- (collect (list directory :recurse recurse :exclude exclude))))))
- :test 'equal :from-end t))
+(with-upgradability ()
+ (defparameter *defpackage-forms* '(cl:defpackage uiop:define-package))
- ;; Will read the configuration and initialize all internal variables.
- (defun compute-source-registry (&optional parameter (registry *source-registry*))
- (dolist (entry (flatten-source-registry parameter))
- (destructuring-bind (directory &key recurse exclude) entry
- (let* ((h (make-hash-table :test 'equal))) ; table to detect duplicates
- (register-asd-directory
- directory :recurse recurse :exclude exclude :collect
- #'(lambda (asd)
- (let* ((name (pathname-name asd))
- (name (if (typep asd 'logical-pathname)
- ;; logical pathnames are upper-case,
- ;; at least in the CLHS and on SBCL,
- ;; yet (coerce-name :foo) is lower-case.
- ;; won't work well with (load-system "Foo")
- ;; instead of (load-system 'foo)
- (string-downcase name)
- name)))
- (cond
- ((gethash name registry) ; already shadowed by something else
- nil)
- ((gethash name h) ; conflict at current level
- (when *verbose-out*
- (warn (compatfmt "~@<In source-registry entry ~A~@[/~*~] ~
- found several entries for ~A - picking ~S over ~S~:>")
- directory recurse name (gethash name h) asd)))
- (t
- (setf (gethash name registry) asd)
- (setf (gethash name h) asd))))))
- h)))
- (values))
+ (defun initial-package-inferred-systems-table ()
+ (let ((h (make-hash-table :test 'equal)))
+ (dolist (p (list-all-packages))
+ (dolist (n (package-names p))
+ (setf (gethash n h) t)))
+ h))
- (defvar *source-registry-parameter* nil)
+ (defvar *package-inferred-systems* (initial-package-inferred-systems-table))
- (defun initialize-source-registry (&optional (parameter *source-registry-parameter*))
- ;; Record the parameter used to configure the registry
- (setf *source-registry-parameter* parameter)
- ;; Clear the previous registry database:
- (setf *source-registry* (make-hash-table :test 'equal))
- ;; Do it!
- (compute-source-registry parameter))
+ (defclass package-inferred-system (system)
+ ())
- ;; Checks an initial variable to see whether the state is initialized
- ;; or cleared. In the former case, return current configuration; in
- ;; the latter, initialize. ASDF will call this function at the start
- ;; of (asdf:find-system) to make sure the source registry is initialized.
- ;; However, it will do so *without* a parameter, at which point it
- ;; will be too late to provide a parameter to this function, though
- ;; you may override the configuration explicitly by calling
- ;; initialize-source-registry directly with your parameter.
- (defun ensure-source-registry (&optional parameter)
- (unless (source-registry-initialized-p)
- (initialize-source-registry parameter))
- (values))
+ ;; For backward compatibility only. To be removed in an upcoming release:
+ (defclass package-system (package-inferred-system) ())
- (defun sysdef-source-registry-search (system)
- (ensure-source-registry)
- (values (gethash (primary-system-name system) *source-registry*))))
+ (defun defpackage-form-p (form)
+ (and (consp form)
+ (member (car form) *defpackage-forms*)))
+ (defun stream-defpackage-form (stream)
+ (loop :for form = (read stream nil nil) :while form
+ :when (defpackage-form-p form) :return form))
+ (defun file-defpackage-form (file)
+ "Return the first DEFPACKAGE form in FILE."
+ (with-input-file (f file)
+ (stream-defpackage-form f)))
+
+ (define-condition package-inferred-system-missing-package-error (system-definition-error)
+ ((system :initarg :system :reader error-system)
+ (pathname :initarg :pathname :reader error-pathname))
+ (:report (lambda (c s)
+ (format s (compatfmt "~@<No package form found while ~
+ trying to define package-inferred-system ~A from file ~A~>")
+ (error-system c) (error-pathname c)))))
+
+ (defun package-dependencies (defpackage-form)
+ "Return a list of packages depended on by the package
+defined in DEFPACKAGE-FORM. A package is depended upon if
+the DEFPACKAGE-FORM uses it or imports a symbol from it."
+ (assert (defpackage-form-p defpackage-form))
+ (remove-duplicates
+ (while-collecting (dep)
+ (loop* :for (option . arguments) :in (cddr defpackage-form) :do
+ (ecase option
+ ((:use :mix :reexport :use-reexport :mix-reexport)
+ (dolist (p arguments) (dep (string p))))
+ ((:import-from :shadowing-import-from)
+ (dep (string (first arguments))))
+ ((:nicknames :documentation :shadow :export :intern :unintern :recycle)))))
+ :from-end t :test 'equal))
+
+ (defun package-designator-name (package)
+ (etypecase package
+ (package (package-name package))
+ (string package)
+ (symbol (string package))))
+
+ (defun register-system-packages (system packages)
+ "Register SYSTEM as providing PACKAGES."
+ (let ((name (or (eq system t) (coerce-name system))))
+ (dolist (p (ensure-list packages))
+ (setf (gethash (package-designator-name p) *package-inferred-systems*) name))))
+
+ (defun package-name-system (package-name)
+ "Return the name of the SYSTEM providing PACKAGE-NAME, if such exists,
+otherwise return a default system name computed from PACKAGE-NAME."
+ (check-type package-name string)
+ (if-let ((system-name (gethash package-name *package-inferred-systems*)))
+ system-name
+ (string-downcase package-name)))
+
+ (defun package-inferred-system-file-dependencies (file &optional system)
+ (if-let (defpackage-form (file-defpackage-form file))
+ (remove t (mapcar 'package-name-system (package-dependencies defpackage-form)))
+ (error 'package-inferred-system-missing-package-error :system system :pathname file)))
+
+ (defun same-package-inferred-system-p (system name directory subpath dependencies)
+ (and (eq (type-of system) 'package-inferred-system)
+ (equal (component-name system) name)
+ (pathname-equal directory (component-pathname system))
+ (equal dependencies (component-sideway-dependencies system))
+ (let ((children (component-children system)))
+ (and (length=n-p children 1)
+ (let ((child (first children)))
+ (and (eq (type-of child) 'cl-source-file)
+ (equal (component-name child) "lisp")
+ (and (slot-boundp child 'relative-pathname)
+ (equal (slot-value child 'relative-pathname) subpath))))))))
+
+ (defun sysdef-package-inferred-system-search (system)
+ (let ((primary (primary-system-name system)))
+ (unless (equal primary system)
+ (let ((top (find-system primary nil)))
+ (when (typep top 'package-inferred-system)
+ (if-let (dir (system-source-directory top))
+ (let* ((sub (subseq system (1+ (length primary))))
+ (f (probe-file* (subpathname dir sub :type "lisp")
+ :truename *resolve-symlinks*)))
+ (when (file-pathname-p f)
+ (let ((dependencies (package-inferred-system-file-dependencies f system))
+ (previous (cdr (system-registered-p system))))
+ (if (same-package-inferred-system-p previous system dir sub dependencies)
+ previous
+ (eval `(defsystem ,system
+ :class package-inferred-system
+ :source-file nil
+ :pathname ,dir
+ :depends-on ,dependencies
+ :components ((cl-source-file "lisp" :pathname ,sub)))))))))))))))
+
+(with-upgradability ()
+ (pushnew 'sysdef-package-inferred-system-search *system-definition-search-functions*)
+ (setf *system-definition-search-functions*
+ (remove (find-symbol* :sysdef-package-system-search :asdf/package-system nil)
+ *system-definition-search-functions*)))
;;;; ---------------------------------------------------------------------------
;;;; Handle ASDF package upgrade, including implementation-dependent magic.
-(asdf/package:define-package :asdf/interface
+(uiop/package:define-package :asdf/interface
(:nicknames :asdf :asdf-utilities)
(:recycle :asdf/interface :asdf)
(:unintern
- #:*asdf-revision* #:around #:asdf-method-combination
- #:do-traverse #:do-dep #:do-one-dep #:visit-action #:component-visited-p
- #:split #:make-collector
#:loaded-systems ; makes for annoying SLIME completion
- #:output-files-for-system-and-operation) ; obsolete ASDF-BINARY-LOCATION function
+ #:output-files-for-system-and-operation) ; ASDF-BINARY-LOCATION function we use to detect ABL
(:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
:asdf/component :asdf/system :asdf/find-system :asdf/find-component
:asdf/operation :asdf/action :asdf/lisp-action
:asdf/output-translations :asdf/source-registry
- :asdf/plan :asdf/operate :asdf/defsystem :asdf/bundle :asdf/concatenate-source
- :asdf/backward-internals :asdf/backward-interface)
- ;; TODO: automatically generate interface with reexport?
+ :asdf/plan :asdf/operate :asdf/parse-defsystem :asdf/bundle :asdf/concatenate-source
+ :asdf/backward-internals :asdf/backward-interface :asdf/package-inferred-system)
+ ;; Note: (1) we are NOT automatically reexporting everything from previous packages.
+ ;; (2) we only reexport UIOP functionality when backward-compatibility requires it.
(:export
- #:defsystem #:find-system #:locate-system #:coerce-name
+ #:defsystem #:find-system #:locate-system #:coerce-name #:primary-system-name
#:oos #:operate #:make-plan #:perform-plan #:sequential-plan
- #:system-definition-pathname #:with-system-definitions
+ #:system-definition-pathname
#:search-for-system-definition #:find-component #:component-find-path
#:compile-system #:load-system #:load-systems #:load-systems*
#:require-system #:test-system #:clear-system
#:operation #:make-operation #:find-operation
#:upward-operation #:downward-operation #:sideway-operation #:selfward-operation
- #:build-system #:build-op
+ #:non-propagating-operation
+ #:build-op #:make
#:load-op #:prepare-op #:compile-op
#:prepare-source-op #:load-source-op #:test-op
#:feature #:version #:version-satisfies #:upgrade-asdf
#:implementation-identifier #:implementation-type #:hostname
- #:input-files #:output-files #:output-file #:perform
+ #:input-files #:output-files #:output-file #:perform #:perform-with-restarts
#:operation-done-p #:explain #:action-description #:component-sideway-dependencies
#:needed-in-image-p
- ;; #:run-program ; we can't export it, because SB-GROVEL :use's both ASDF and SB-EXT.
#:component-load-dependencies #:run-shell-command ; deprecated, do not use
#:bundle-op #:monolithic-bundle-op #:precompiled-system #:compiled-file #:bundle-system
- #+ecl #:make-build
- #:basic-fasl-op #:prepare-fasl-op #:fasl-op #:load-fasl-op #:monolithic-fasl-op
- #:lib-op #:dll-op #:binary-op #:program-op
- #:monolithic-lib-op #:monolithic-dll-op #:monolithic-binary-op
+ #:program-system #:make-build
+ #:fasl-op #:load-fasl-op #:monolithic-fasl-op #:binary-op #:monolithic-binary-op
+ #:basic-compile-bundle-op #:prepare-bundle-op
+ #:compile-bundle-op #:load-bundle-op #:monolithic-compile-bundle-op #:monolithic-load-bundle-op
+ #:lib-op #:dll-op #:deliver-asd-op #:program-op #:image-op
+ #:monolithic-lib-op #:monolithic-dll-op #:monolithic-deliver-asd-op
#:concatenate-source-op
#:load-concatenated-source-op
#:compile-concatenated-source-op
@@ -10562,8 +11153,10 @@ system names to pathnames of .asd files")
#:file-component #:source-file #:c-source-file #:java-source-file
#:cl-source-file #:cl-source-file.cl #:cl-source-file.lsp
#:static-file #:doc-file #:html-file
- #:file-type
- #:source-file-type
+ #:file-type #:source-file-type
+
+ #:package-inferred-system #:register-system-packages
+ #:package-system ;; backward-compatibility during migration, to be removed in a further release.
#:component-children ; component accessors
#:component-children-by-name
@@ -10597,13 +11190,16 @@ system names to pathnames of .asd files")
#:system-long-name
#:system-source-control
#:map-systems
+ #:system-defsystem-depends-on
+ #:system-depends-on
+ #:system-weakly-depends-on
#:*system-definition-search-functions* ; variables
#:*central-registry*
#:*compile-file-warnings-behaviour*
#:*compile-file-failure-behaviour*
#:*resolve-symlinks*
- #:*load-system-operation*
+ #:*load-system-operation* #:*immutable-systems*
#:*asdf-verbose* ;; unused. For backward-compatibility only.
#:*verbose-out*
@@ -10623,6 +11219,8 @@ system names to pathnames of .asd files")
#:missing-dependency-of-version
#:circular-dependency ; errors
#:duplicate-names #:non-toplevel-system #:non-system-system
+ #:package-inferred-system-missing-package-error
+ #:operation-definition-warning #:operation-definition-error
#:try-recompiling
#:retry
@@ -10669,25 +11267,25 @@ system names to pathnames of .asd files")
;;;; ---------------------------------------------------------------------------
;;;; ASDF-USER, where the action happens.
-(asdf/package:define-package :asdf/user
+(uiop/package:define-package :asdf/user
(:nicknames :asdf-user)
- (:use :asdf/common-lisp :asdf/package :asdf/interface))
+ ;; NB: releases before 3.1.1 this :use'd only uiop/package instead of uiop below.
+ ;; They also :use'd uiop/common-lisp, that reexports common-lisp and is not included in uiop.
+ ;; ASDF3 releases from 2.27 to 2.31 called uiop asdf-driver and asdf/foo uiop/foo.
+ ;; ASDF1 and ASDF2 releases (2.26 and earlier) create a temporary package
+ ;; that only :use's :cl and :asdf
+ (:use :uiop/common-lisp :uiop :asdf/interface))
;;;; -----------------------------------------------------------------------
;;;; ASDF Footer: last words and cleanup
-(asdf/package:define-package :asdf/footer
+(uiop/package:define-package :asdf/footer
(:recycle :asdf/footer :asdf)
- (:use :uiop/common-lisp :uiop :asdf/upgrade
- :asdf/find-system :asdf/find-component :asdf/operation :asdf/action :asdf/lisp-action
- :asdf/operate :asdf/bundle :asdf/concatenate-source
- :asdf/output-translations :asdf/source-registry
- :asdf/backward-internals :asdf/defsystem :asdf/backward-interface))
+ (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/operate :asdf/bundle))
(in-package :asdf/footer)
;;;; Hook ASDF into the implementation's REQUIRE and other entry points.
-
+#+(or abcl clisp clozure cmu ecl mkcl sbcl)
(with-upgradability ()
- #+(or abcl clisp clozure cmu ecl mkcl sbcl)
(if-let (x (and #+clisp (find-symbol* '#:*module-provider-functions* :custom nil)))
(eval `(pushnew 'module-provide-asdf
#+abcl sys::*module-provider-functions*
@@ -10699,7 +11297,7 @@ system names to pathnames of .asd files")
#+(or ecl mkcl)
(progn
- (pushnew '("fasb" . si::load-binary) si:*load-hooks* :test 'equal :key 'car)
+ (pushnew '("fasb" . si::load-binary) si::*load-hooks* :test 'equal :key 'car)
#+(or (and ecl win32) (and mkcl windows))
(unless (assoc "asd" #+ecl ext:*load-hooks* #+mkcl si::*load-hooks* :test 'equal)
@@ -10715,7 +11313,7 @@ system names to pathnames of .asd files")
(and (first l) (register-pre-built-system (coerce-name name)))
(values-list l))))))))
-#+cmu
+#+cmu ;; Hook into the CMUCL herald.
(with-upgradability ()
(defun herald-asdf (stream)
(format stream " ASDF ~A" (asdf-version)))
@@ -10728,13 +11326,13 @@ system names to pathnames of .asd files")
(when (boundp 'excl:*warn-on-nested-reader-conditionals*)
(setf excl:*warn-on-nested-reader-conditionals* asdf/common-lisp::*acl-warn-save*))
- (dolist (f '(:asdf :asdf2 :asdf3)) (pushnew f *features*))
+ (dolist (f '(:asdf :asdf2 :asdf3 :asdf3.1 :asdf-package-system)) (pushnew f *features*))
- (provide :asdf)
+ ;; Provide both lowercase and uppercase, to satisfy more people, especially LispWorks users.
+ (provide "asdf") (provide "ASDF")
(cleanup-upgraded-asdf))
(when *load-verbose*
(asdf-message ";; ASDF, version ~a~%" (asdf-version)))
-
diff --git a/src/general-info/release-20f.txt b/src/general-info/release-20f.txt
index f7a012d..900898a 100644
--- a/src/general-info/release-20f.txt
+++ b/src/general-info/release-20f.txt
@@ -32,7 +32,7 @@ New in this release:
ticket:92)
* Changes
- * Update to ASDF 3.0.3.
+ * Update to ASDF 3.1.2.
* When *PRINT-CASE* is :DOWNCASE, integers are printed with
lowercase letters when needed.
* Micro-optimize KERNEL:DOUBLE-FLOAT-BITS for x86/sse2.
-----------------------------------------------------------------------
Summary of changes:
src/contrib/asdf/asdf.lisp | 5078 +++++++++++++++++++++-----------------
src/general-info/release-20f.txt | 2 +-
2 files changed, 2839 insertions(+), 2241 deletions(-)
hooks/post-receive
--
CMU Common Lisp
More information about the cmucl-cvs
mailing list