Commit d9c775e3 authored by Francois-Rene Rideau's avatar Francois-Rene Rideau

Update comments and docstrings in package-inferred-system.lisp

parent 4b357e64
......@@ -14,27 +14,36 @@
(in-package :asdf/package-inferred-system)
(with-upgradability ()
;; The names of the recognized defpackage forms.
(defparameter *defpackage-forms* '(defpackage define-package))
(defun initial-package-inferred-systems-table ()
;; Mark all existing packages are preloaded.
(let ((h (make-hash-table :test 'equal)))
(dolist (p (list-all-packages))
(dolist (n (package-names p))
(setf (gethash n h) t)))
h))
;; Mapping from package names to systems that provide them.
(defvar *package-inferred-systems* (initial-package-inferred-systems-table))
(defclass package-inferred-system (system)
())
()
(:documentation "Class for primary systems for which secondary systems are automatically
in the one-file, one-file, one-system style: system names are mapped to files under the primary
system's system-source-directory, dependencies are inferred from the first defpackage form in
every such file"))
;; For backward compatibility only. To be removed in an upcoming release:
;; DEPRECATED. For backward compatibility only. To be removed in an upcoming release:
(defclass package-system (package-inferred-system) ())
;; Is a given form recognizable as a defpackage form?
(defun defpackage-form-p (form)
(and (consp form)
(member (car form) *defpackage-forms*)))
;; Find the first defpackage form in a stream, if any
(defun stream-defpackage-form (stream)
(loop :for form = (read stream nil nil) :while form
:when (defpackage-form-p form) :return form))
......@@ -69,6 +78,7 @@ the DEFPACKAGE-FORM uses it or imports a symbol from it."
:from-end t :test 'equal))
(defun package-designator-name (package)
"Normalize a package designator to a string"
(etypecase package
(package (package-name package))
(string package)
......@@ -88,11 +98,14 @@ otherwise return a default system name computed from PACKAGE-NAME."
system-name
(string-downcase package-name)))
;; Given a file in package-inferred-system style, find its dependencies
(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)))
;; Given package-inferred-system object, check whether its specification matches
;; the provided parameters
(defun same-package-inferred-system-p (system name directory subpath around-compile dependencies)
(and (eq (type-of system) 'package-inferred-system)
(equal (component-name system) name)
......@@ -107,6 +120,7 @@ otherwise return a default system name computed from PACKAGE-NAME."
(and (slot-boundp child 'relative-pathname)
(equal (slot-value child 'relative-pathname) subpath))))))))
;; sysdef search function to push into *system-definition-search-functions*
(defun sysdef-package-inferred-system-search (system)
(let ((primary (primary-system-name system)))
(unless (equal primary system)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment