Skip to content
Snippets Groups Projects
Commit d8b99de5 authored by Robert P. Goldman's avatar Robert P. Goldman
Browse files

Merge branch 'master' into docs

Non-trivial merge necessary because there were updates to the ASDF
manual on master corresponding to the (renamed) package-inferred-system
facility.
parents d5f314c9 1cec1baf
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 77 deletions
......@@ -54,7 +54,7 @@ XCL ?= xcl
header_lisp := header.lisp
driver_lisp := uiop/package.lisp uiop/common-lisp.lisp uiop/utility.lisp uiop/os.lisp uiop/pathname.lisp uiop/filesystem.lisp uiop/stream.lisp uiop/image.lisp uiop/run-program.lisp uiop/lisp-build.lisp uiop/configuration.lisp uiop/backward-driver.lisp uiop/driver.lisp
defsystem_lisp := upgrade.lisp component.lisp system.lisp cache.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp output-translations.lisp source-registry.lisp backward-internals.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp backward-interface.lisp package-system.lisp interface.lisp user.lisp footer.lisp
defsystem_lisp := upgrade.lisp component.lisp system.lisp cache.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp output-translations.lisp source-registry.lisp backward-internals.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp backward-interface.lisp package-inferred-system.lisp interface.lisp user.lisp footer.lisp
all_lisp := $(header_lisp) $(driver_lisp) $(defsystem_lisp)
# Making ASDF itself should be our first, default, target:
......
......@@ -3,7 +3,7 @@
;;; ;;;
;;; Free Software available under an MIT-style license. ;;;
;;; ;;;
;;; Copyright (c) 2001-2013 Daniel Barlow and contributors ;;;
;;; Copyright (c) 2001-2014 Daniel Barlow and contributors ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
......@@ -61,11 +61,11 @@
(:file "bundle" :depends-on ("lisp-action" "operate" "parse-defsystem"))
(:file "concatenate-source" :depends-on ("plan" "parse-defsystem" "bundle"))
(:file "backward-interface" :depends-on ("operate" "output-translations"))
(:file "package-system" :depends-on ("system" "find-system" "parse-defsystem"))
(:file "package-inferred-system" :depends-on ("system" "find-system" "parse-defsystem"))
(:file "interface" :depends-on
("parse-defsystem" "concatenate-source"
"backward-interface" "backward-internals"
"output-translations" "source-registry" "package-system"))
"output-translations" "source-registry" "package-inferred-system"))
(:file "user" :depends-on ("interface"))
(:file "footer" :depends-on ("user"))))
......@@ -75,13 +75,13 @@
:licence "MIT"
:description "Another System Definition Facility"
:long-description "ASDF builds Common Lisp software organized into defined systems."
:version "3.1.0.113" ;; to be automatically updated by make bump-version
:version "3.1.0.116" ;; to be automatically updated by make bump-version
:depends-on ()
#+asdf3 :encoding #+asdf3 :utf-8
:class #.(if (find-class 'package-system nil) 'package-system 'system)
:class #.(if (find-class 'package-inferred-system nil) 'package-inferred-system 'system)
;; For most purposes, asdf itself specially counts as a builtin system.
;; If you want to link it or do something forbidden to builtin systems,
;; specify separate dependencies on UIOP (aka asdf-driver) and asdf/defsystem.
;; specify separate dependencies on uiop (aka asdf-driver) and asdf/defsystem.
#+asdf3 :builtin-system-p #+asdf3 t
:components ((:module "build" :components ((:file "asdf"))))
:in-order-to (#+asdf3 (prepare-op (monolithic-concatenate-source-op :asdf/defsystem))))
......
......@@ -273,9 +273,8 @@ children.")))
;;;; version-satisfies
(with-upgradability ()
;; short-circuit testing of null version specifications.
;; this is an all-pass
;; this is an all-pass, without warning
(defmethod version-satisfies :around ((c t) (version null))
(declare (ignorable c version))
t)
(defmethod version-satisfies ((c component) version)
(unless (and version (slot-boundp c 'version) (component-version c))
......
......@@ -140,7 +140,7 @@ Defining systems with defsystem
* A more involved example::
* The defsystem grammar::
* Other code in .asd files::
* The package-system extension::
* The package-inferred-system extension::
The Object model of ASDF
......@@ -1040,7 +1040,7 @@ software.
* A more involved example::
* The defsystem grammar::
* Other code in .asd files::
* The package-system extension::
* The package-inferred-system extension::
@end menu
@node The defsystem form, A more involved example, Defining systems with defsystem, Defining systems with defsystem
......@@ -1682,7 +1682,7 @@ this provided
a roundabout way to express conditional compilation.
@node Other code in .asd files, The package-system extension, The defsystem grammar, Defining systems with defsystem
@node Other code in .asd files, The package-inferred-system extension, The defsystem grammar, Defining systems with defsystem
@section Other code in .asd files
Files containing @code{defsystem} forms
......@@ -1710,8 +1710,8 @@ of output from ASDF operations.
@end itemize
@node The package-system extension, , Other code in .asd files, Defining systems with defsystem
@section The package-system extension
@node The package-inferred-system extension, , Other code in .asd files, Defining systems with defsystem
@section The package-inferred-system extension
Starting with release 3.1.1,
ASDF supports a one-package-per-file style of programming,
......@@ -1719,40 +1719,29 @@ whereby each file is its own system,
and dependencies are deduced from the @code{defpackage} form
(or its variant @code{uiop:define-package}).
In this style, packages refer to a same-named system (downcased),
unless specially registered.
If a system is defined with @code{:class :package-system},
In this style, packages refer to a system with the same name (downcased);
and if a system is defined with @code{:class package-inferred-system},
then system names that start with that name
(using the slash @code{/} separator)
refer to files under the filesystem hierarchy where the system is defined.
For instance, if system @code{lil} is defined in
@file{/home/tunes/cl/lisp-interface-library/lil.asd}, then package @code{lil/interface/order}
will be found in file @file{/home/tunes/cl/lisp-interface-library/interface/order.lisp}.
This style was made popular
by @code{faslpath} and @code{quick-build} before (@pxref{Bibliography}).
It seems to make for more maintainable code,
at the cost of a stricter package discipline:
by imposing upon programmers a discipline of smaller namespaces,
with explicit dependencies and especially explicit forward dependencies,
the style encourages good factoring of the code into coherent units;
by contrast, the traditional style of "everything in one package"
has low overhead but doesn't scale very well.
It is used by ASDF itself (starting with ASDF 3, aka 2.27)
and by @code{lisp-interface-library},
to the great satisfaction of the author (FRR).
Others who have tried it before also expressed similar results.
Thus, for instance, in @code{lisp-interface-library},
the file @file{lil.asd} contains the following incantations (elided):
For instance, if system @code{my-lib} is defined in
@file{/foo/bar/my-lib/my-lib.asd}, then system @code{my-lib/src/utility}
will be found in file @file{/foo/bar/my-lib/src/utility.lisp}.
This style was made popular by @code{faslpath} and @code{quick-build} before,
and at the cost of a stricter package discipline,
seems to make for more maintainable code.
It is used by ASDF itself (starting with ASDF 3) and by @code{lisp-interface-library}.
To use this style, choose a toplevel system name, e.g. @code{my-lib},
and create a file @file{my-lib.asd}
with the @code{:class :package-inferred-system} option in its @code{defsystem}.
For instance:
@example
#-asdf3 (error "LIL requires ASDF 3 or later. Please upgrade your ASDF.")
(defsystem lil
:description "LIL: Lisp Interface Library" ...
:class :package-system
#-asdf (error "my-lib requires ASDF 3")
(defsystem my-lib
:class :package-inferred-system
:defsystem-depends-on (:asdf-package-system)
:depends-on (:lil/interface/all
:lil/pure/all
......
;;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp ; buffer-read-only: t; -*-
;;; This is ASDF 3.1.0.113: Another System Definition Facility.
;;; This is ASDF 3.1.0.116: Another System Definition Facility.
;;;
;;; Feedback, bug reports, and patches are all welcome:
;;; please mail to <asdf-devel@common-lisp.net>.
......
......@@ -12,7 +12,7 @@
:asdf/operation :asdf/action :asdf/lisp-action
:asdf/output-translations :asdf/source-registry
:asdf/plan :asdf/operate :asdf/parse-defsystem :asdf/bundle :asdf/concatenate-source
:asdf/backward-internals :asdf/backward-interface :asdf/package-system)
: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
......@@ -59,7 +59,8 @@
#:static-file #:doc-file #:html-file
#:file-type #:source-file-type
#:package-system #:register-system-packages
#: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
......@@ -122,7 +123,7 @@
#:missing-dependency-of-version
#:circular-dependency ; errors
#:duplicate-names #:non-toplevel-system #:non-system-system
#:package-system-missing-package-error
#:package-inferred-system-missing-package-error
#:operation-definition-warning #:operation-definition-error
#:try-recompiling
......
;;;; -------------------------------------------------------------------------
;;;; Package systems in the style of quick-build or faslpath
(uiop:define-package :asdf/package-system
(:recycle :asdf/package-system :asdf)
(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-system #:register-system-packages #:sysdef-package-system-search
#:*defpackage-forms* #:*package-systems* #:package-system-missing-package-error))
(in-package :asdf/package-system)
#: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)
(with-upgradability ()
(defparameter *defpackage-forms* '(cl:defpackage uiop:define-package))
(defun initial-package-systems-table ()
(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 *package-systems* (initial-package-systems-table))
(defvar *package-inferred-systems* (initial-package-inferred-systems-table))
(defclass package-system (system)
(defclass package-inferred-system (system)
())
;; For backward compatibility only. To be removed in an upcoming release:
(defclass package-system (package-inferred-system) ())
(defun defpackage-form-p (form)
(and (consp form)
(member (car form) *defpackage-forms*)))
......@@ -39,12 +44,12 @@
(with-input-file (f file)
(stream-defpackage-form f)))
(define-condition package-system-missing-package-error (system-definition-error)
(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-system ~A from file ~A~>")
trying to define package-inferred-system ~A from file ~A~>")
(error-system c) (error-pathname c)))))
(defun package-dependencies (defpackage-form)
......@@ -73,23 +78,23 @@ the DEFPACKAGE-FORM uses it or imports a symbol from it."
"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-systems*) name))))
(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-systems*)))
(if-let ((system-name (gethash package-name *package-inferred-systems*)))
system-name
(string-downcase package-name)))
(defun package-system-file-dependencies (file &optional system)
(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-system-missing-package-error :system system :pathname file)))
(error 'package-inferred-system-missing-package-error :system system :pathname file)))
(defun same-package-system-p (system name directory subpath dependencies)
(and (eq (type-of system) 'package-system)
(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))
......@@ -101,26 +106,29 @@ otherwise return a default system name computed from PACKAGE-NAME."
(and (slot-boundp child 'relative-pathname)
(equal (slot-value child 'relative-pathname) subpath))))))))
(defun sysdef-package-system-search (system)
(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-system)
(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-system-file-dependencies f system))
(let ((dependencies (package-inferred-system-file-dependencies f system))
(previous (cdr (system-registered-p system))))
(if (same-package-system-p previous system dir sub dependencies)
(if (same-package-inferred-system-p previous system dir sub dependencies)
previous
(eval `(defsystem ,system
:class package-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-system-search *system-definition-search-functions*))
(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*)))
(defpackage :test-asdf/dll-test (:use)) ;; dummy, for package-system dependencies.
(defpackage :test-asdf/dll-test (:use)) ;; dummy, for package-inferred-system dependencies.
#+ecl
(ffi:clines "
......
(defpackage :test-asdf/dll-user (:use)) ;; dummy, for package-system dependencies.
(defpackage :test-asdf/dll-user (:use)) ;; dummy, for package-inferred-system dependencies.
(in-package :test-package)
......
(defpackage :l-file
(:use :asdf :uiop :cl) ;; asdf/package-system dependencies
(:use :asdf :uiop :cl) ;; asdf/package-inferred-system dependencies
(:export #:cl-source-file.l))
(in-package :l-file)
......
(cl:defpackage :l-operation
(:use :asdf :uiop :cl) ;; asdf/package-system dependencies
(:use :asdf :uiop :cl) ;; asdf/package-inferred-system dependencies
(:export #:op #:*x*))
(cl:in-package :l-operation)
......
(defpackage :test-asdf/monodll-1 (:use)) ;; dummy, for package-system dependencies.
(defpackage :test-asdf/monodll-1 (:use)) ;; dummy, for package-inferred-system dependencies.
#+ecl
(ffi:clines "
......
(defpackage :test-asdf/monodll-user (:use)) ;; dummy, for package-system dependencies.
(defpackage :test-asdf/monodll-user (:use)) ;; dummy, for package-inferred-system dependencies.
(in-package :test-package)
(ffi:def-function "always_42" () :returning :int)
(defpackage :test-asdf/monodll (:use :test-asdf/monodll-1)) ;; dummy, for package-system dependencies.
(defpackage :test-asdf/monodll (:use :test-asdf/monodll-1)) ;; dummy, for package-inferred-system dependencies.
#+ecl
(ffi:clines "
......
(register-directory (subpathname *test-directory* "package-inferred-system-test/"))
(load-system :package-inferred-system-test/a/x)
(load-system :package-inferred-system-test/d)
(signals package-inferred-system-missing-package-error (load-system :package-inferred-system-test/e))
;; No such file.
(signals missing-component (load-system :package-inferred-system-test/f))
(defpackage package-inferred-system-test/a (:use cl))
(defpackage package-inferred-system-test/a/x (:use common-lisp package-inferred-system-test/c))
(defpackage package-inferred-system-test/b (:use cl package-inferred-system-test/a))
(defpackage package-inferred-system-test/c (:use cl package-inferred-system-test/a))
(defpackage package-inferred-system-test/d (:use cl package-inferred-system-test/b package-inferred-system-test/c))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment