1
0
Fork 0
cl-sites/asdf.common-lisp.dev/asdf/Components.html
2023-11-12 11:34:18 +01:00

315 lines
15 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual describes ASDF, a system definition facility
for Common Lisp programs and libraries.
You can find the latest version of this manual at
https://common-lisp.net/project/asdf/asdf.html.
ASDF Copyright (C) 2001-2019 Daniel Barlow and contributors.
This manual Copyright (C) 2001-2019 Daniel Barlow and contributors.
This manual revised (C) 2009-2019 Robert P. Goldman and Francois-Rene Rideau.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<title>Components (ASDF Manual)</title>
<meta name="description" content="Components (ASDF Manual)">
<meta name="keywords" content="Components (ASDF Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="The-object-model-of-ASDF.html" rel="up" title="The object model of ASDF">
<link href="Dependencies.html" rel="next" title="Dependencies">
<link href="Operations.html" rel="prev" title="Operations">
<style type="text/css">
<!--
a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
span:hover a.copiable-anchor {visibility: visible}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<div class="section" id="Components">
<div class="header">
<p>
Next: <a href="Dependencies.html" accesskey="n" rel="next">Dependencies</a>, Previous: <a href="Operations.html" accesskey="p" rel="prev">Operations</a>, Up: <a href="The-object-model-of-ASDF.html" accesskey="u" rel="up">The Object model of ASDF</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Components-1"></span><h3 class="section">7.2 Components</h3>
<span id="index-component"></span>
<span id="index-system"></span>
<span id="index-system-designator"></span>
<span id="index-component-designator"></span>
<span id="index-_002asystem_002ddefinition_002dsearch_002dfunctions_002a"></span>
<p>A <code>component</code> represents an individual source file or a group of source files,
and the things that get transformed into.
A <code>system</code> is a component at the top level of the component hierarchy,
that can be found via <code>find-system</code>.
A <code>source-file</code> is a component representing a single source-file
and the successive output files into which it is transformed.
A <code>module</code> is an intermediate component itself grouping several other components,
themselves source-files or further modules.
</p>
<p>A <em>system designator</em> is a system itself,
or a string or symbol that behaves just like any other component name
(including with regard to the case conversion rules for component names).
</p>
<p>A <em>component designator</em>, relative to a base component,
is either a component itself,
or a string or symbol,
or a list of designators.
</p>
<dl class="def">
<dt id="index-find_002dsystem"><span class="category">Function: </span><span><strong>find-system</strong> <em>system-designator &amp;optional (error-p t)</em><a href='Components.html#index-find_002dsystem' class='copiable-anchor'> &para;</a></span></dt>
<dd>
<p>Given a system designator, <code>find-system</code> finds and returns a system.
If no system is found, an error of type
<code>missing-component</code> is thrown,
or <code>nil</code> is returned if <code>error-p</code> is false.
</p>
<p>To find and update systems, <code>find-system</code> funcalls each element
in the <code>*system-definition-search-functions*</code> list,
expecting a pathname to be returned, or a system object,
from which a pathname may be extracted, and that will be registered.
The resulting pathname (if any) is loaded
if one of the following conditions is true:
</p>
<ul>
<li> there is no system of that name in memory
</li><li> the pathname is different from that which was previously loaded
</li><li> the file&rsquo;s <code>last-modified</code> time exceeds the <code>last-modified</code> time
of the system in memory
</li></ul>
<span id="index-ASDF_002dUSER-package"></span>
<p>When system definitions are loaded from <samp>.asd</samp> files,
they are implicitly loaded into the <code>ASDF-USER</code> package,
which uses <code>ASDF</code>, <code>UIOP</code> and <code>UIOP/COMMON-LISP</code><a id="DOCF12" href="Components.html#FOOT12"><sup>12</sup></a>
Programmers who do anything non-trivial in a <samp>.asd</samp> file,
such as defining new variables, functions or classes,
should include <code>defpackage</code> and <code>in-package</code> forms in this file,
so they will not overwrite each others&rsquo; extensions.
Such forms might also help the files behave identically
if loaded manually with <code>cl:load</code> for development or debugging,
though we recommend you use the function <code>asdf::load-asd</code> instead,
which the <code>slime-asdf</code> contrib knows about.
</p>
<p>The default value of <code>*system-definition-search-functions*</code>
is a list of three functions.
The first function looks in each of the directories given
by evaluating members of <code>*central-registry*</code>
for a file whose name is the name of the system and whose type is <samp>asd</samp>;
the first such file is returned,
whether or not it turns out to actually define the appropriate system.
The second function does something similar,
for the directories specified in the <code>source-registry</code>,
but searches the filesystem only once and caches its results.
The third function makes the <code>package-inferred-system</code> extension work,
see <a href="The-package_002dinferred_002dsystem-extension.html">The package-inferred-system extension</a>.
</p>
<p>Because of the way these search functions are defined,
you should put the definition for a system
<var>foo</var> in a file named <samp>foo.asd</samp>,
in a directory that is
in the central registry or
which can be found using the
source registry configuration.
</p>
<span id="System-names"></span><span id="index-System-names"></span>
<span id="index-Primary-system-name"></span>
<span id="index-primary_002dsystem_002dname"></span>
<p>It is often useful to define multiple systems in a same file,
but ASDF can only locate a system&rsquo;s definition file based on the system
name.
For this reason,
ASDF 3&rsquo;s system search algorithm has been extended to
allow a file <samp>foo.asd</samp> to contain
secondary systems named <var>foo/bar</var>, <var>foo/baz</var>, <var>foo/quux</var>, etc.,
in addition to the primary system named <var>foo</var>.
The first component of a system name,
separated by the slash character, <code>/</code>,
is called the primary name of a system.
The primary name may be
extracted by function <code>asdf::primary-system-name</code>;
when ASDF 3 is told to find a system whose name has a slash,
it will first attempt to load the corresponding primary system,
and will thus see any such definitions, and/or any
definition of a <code>package-inferred-system</code>.<a id="DOCF13" href="Components.html#FOOT13"><sup>13</sup></a>
If your file <samp>foo.asd</samp> also defines systems
that do not follow this convention, e.g., a system named <var>foo-test</var>,
ASDF will not be able to automatically locate a definition for these systems,
and will only see their definition
if you explicitly find or load the primary system
using e.g. <code>(asdf:find-system &quot;foo&quot;)</code> before you try to use them.
We strongly recommend against this practice,
though it is currently supported for backward compatibility.
</p>
</dd></dl>
<dl class="def">
<dt id="index-primary_002dsystem_002dname-1"><span class="category">Function: </span><span><strong>primary-system-name</strong> <em>name</em><a href='Components.html#index-primary_002dsystem_002dname-1' class='copiable-anchor'> &para;</a></span></dt>
<dd>
<p>Internal (not exported) function, <code>asdf::primary-system-name</code>.
Returns the primary system name (the portion before
the slash, <code>/</code>, in a secondary system name) from <var>name</var>.
</p>
</dd></dl>
<dl class="def">
<dt id="index-locate_002dsystem"><span class="category">Function: </span><span><strong>locate-system</strong> <em>name</em><a href='Components.html#index-locate_002dsystem' class='copiable-anchor'> &para;</a></span></dt>
<dd>
<p>This function should typically <em>not</em> be invoked directly. It is
exported as part of the API only for programmers who wish to provide
their own <code>*system-definition-search-functions*</code>.
</p>
<p>Given a system <var>name</var> designator,
try to locate where to load the system definition from.
Returns five values: <var>foundp</var>, <var>found-system</var>, <var>pathname</var>,
<var>previous</var>, and <var>previous-time</var>.
<var>foundp</var> is true when a system was found,
either a new as yet unregistered one, or a previously registered one.
The <var>found-system</var> return value
will be a <code>system</code> object, if a system definition is found in your
source registry.
The system definition will <em>not</em> be
loaded if it hasn&rsquo;t been loaded already.
<var>pathname</var> when not null is a path from which to load the system,
either associated with <var>found-system</var>, or with the <var>previous</var> system.
If <var>previous</var> is not null, it will be a <em>previously loaded</em>
<code>system</code> object of the same name (note that the system
<em>definition</em> is previously-loaded: the system itself may or may not be).
<var>previous-time</var> when not null is
the timestamp of the previous system definition file, at the
time when the <var>previous</var> system definition was loaded.
</p>
<p>For example, if your current registry has <samp>foo.asd</samp> in
<samp>/current/path/to/foo.asd</samp>,
but system <code>foo</code> was previously loaded from <samp>/previous/path/to/foo.asd</samp>
then <var>locate-system</var> will return the following values:
</p><ol>
<li> <var>foundp</var> will be <code>t</code>,
</li><li> <var>found-system</var> will be <code>nil</code>,
</li><li> <var>pathname</var> will be <code>#p&quot;/current/path/to/foo.asd&quot;</code>,
</li><li> <var>previous</var> will be an object of type <code>SYSTEM</code> with
<code>system-source-file</code> slot value of
<code>#p&quot;/previous/path/to/foo.asd&quot;</code>
</li><li> <var>previous-time</var> will be the timestamp of
<code>#p&quot;/previous/path/to/foo.asd&quot;</code> at the time it was loaded.
</li></ol>
</dd></dl>
<dl class="def">
<dt id="index-find_002dcomponent-1"><span class="category">Function: </span><span><strong>find-component</strong> <em>base path</em><a href='Components.html#index-find_002dcomponent-1' class='copiable-anchor'> &para;</a></span></dt>
<dd>
<p>Given a <var>base</var> component (or designator for such),
and a <var>path</var>, find the component designated by the <var>path</var>
starting from the <var>base</var>.
</p>
<p>If <var>path</var> is a component object, it designates itself,
independently from the base.
</p>
<span id="index-coerce_002dname-1"></span>
<p>If <var>path</var> is a string, or symbol denoting a string via <code>coerce-name</code>,
then <var>base</var> is resolved to a component object,
which must be a system or module,
and the designated component is the child named by the <var>path</var>.
</p>
<p>If <var>path</var> is a <code>cons</code> cell,
<code>find-component</code> with the base and the <code>car</code> of the <var>path</var>,
and the resulting object is used as the base for a tail call
to <code>find-component</code> with the <code>car</code> of the <var>path</var>.
</p>
<p>If <var>base</var> is a component object, it designates itself.
</p>
<p>If <var>base</var> is null, then <var>path</var> is used as the base, with <code>nil</code> as the path.
</p>
<p>If <var>base</var> is a string, or symbol denoting a string via <code>coerce-name</code>,
it designates a system as per <code>find-system</code>.
</p>
<p>If <var>base</var> is a <code>cons</code> cell, it designates the component found by
<code>find-component</code> with its <code>car</code> as base and <code>cdr</code> as path.
</p></dd></dl>
<ul class="section-toc">
<li><a href="Common-attributes-of-components.html" accesskey="1">Common attributes of components</a></li>
<li><a href="Pre_002ddefined-subclasses-of-component.html" accesskey="2">Pre-defined subclasses of component</a></li>
<li><a href="Creating-new-component-types.html" accesskey="3">Creating new component types</a></li>
</ul>
</div>
<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>
<h5><a id="FOOT12" href="Components.html#DOCF12">(12)</a></h5>
<p>Note that between releases 2.27 and 3.0.3, only <code>UIOP/PACKAGE</code>,
not all of <code>UIOP</code>, was used; if you want your code to work
with releases earlier than 3.1.2, you may have to explicitly define a package
that uses <code>UIOP</code>, or use proper package prefix to your symbols, as in
<code>uiop:version&lt;</code>.</p>
<h5><a id="FOOT13" href="Components.html#DOCF13">(13)</a></h5>
<p>ASDF 2.26 and earlier versions
do not support this primary system name convention.
With these versions of ASDF
you must explicitly load <samp>foo.asd</samp>
before you can use system <var>foo/bar</var> defined therein,
e.g. using <code>(asdf:find-system &quot;foo&quot;)</code>.
We do not support ASDF 2, and recommend that you should upgrade to ASDF 3.
</p>
</div>
<hr>
<div class="header">
<p>
Next: <a href="Dependencies.html">Dependencies</a>, Previous: <a href="Operations.html">Operations</a>, Up: <a href="The-object-model-of-ASDF.html">The Object model of ASDF</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>