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

165 lines
8 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>Controlling file compilation (ASDF Manual)</title>
<meta name="description" content="Controlling file compilation (ASDF Manual)">
<meta name="keywords" content="Controlling file compilation (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="Miscellaneous-additional-functionality.html" rel="up" title="Miscellaneous additional functionality">
<link href="Controlling-source-file-character-encoding.html" rel="next" title="Controlling source file character encoding">
<link href="Miscellaneous-additional-functionality.html" rel="prev" title="Miscellaneous additional functionality">
<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="Controlling-file-compilation">
<div class="header">
<p>
Next: <a href="Controlling-source-file-character-encoding.html" accesskey="n" rel="next">Controlling source file character encoding</a>, Previous: <a href="Miscellaneous-additional-functionality.html" accesskey="p" rel="prev">Miscellaneous additional functionality</a>, Up: <a href="Miscellaneous-additional-functionality.html" accesskey="u" rel="up">Miscellaneous additional functionality</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="Controlling-file-compilation-1"></span><h3 class="section">11.1 Controlling file compilation</h3>
<span id="index-_003aaround_002dcompile"></span>
<span id="index-around_002dcompile-keyword"></span>
<span id="index-compile_002dcheck-keyword"></span>
<span id="index-_003acompile_002dcheck"></span>
<span id="index-compile_002dfile_002a"></span>
<p>When declaring a component (system, module, file),
you can specify a keyword argument <code>:around-compile function</code>.
If left unspecified (and therefore unbound),
the value will be inherited from the parent component if any,
or with a default of <code>nil</code>
if no value is specified in any transitive parent.
</p>
<p>The argument must be either <code>nil</code>, an fbound symbol,
a lambda-expression (e.g. <code>(lambda (thunk) ...(funcall thunk ...) ...)</code>)
a function object (e.g. using <code>#.#'</code> but that&rsquo;s discouraged
because it prevents the introspection done by e.g. asdf-dependency-grovel),
or a string that when <code>read</code> yields a symbol or a lambda-expression.
<code>nil</code> means the normal compile-file function will be called.
A non-nil value designates a function of one argument
that will be called with a function that will
invoke <code>compile-file*</code> with various arguments;
the around-compile hook may supply additional keyword arguments
to pass to that call to <code>compile-file*</code>.
</p>
<p>One notable argument that is heeded by <code>compile-file*</code> is
<code>:compile-check</code>,
a function called when the compilation was otherwise a success,
with the same arguments as <code>compile-file</code>;
the function shall return true if the compilation
and its resulting compiled file respected all system-specific invariants,
and false (<code>nil</code>) if it broke any of those invariants;
it may issue warnings or errors before it returns <code>nil</code>.
(NB: The ability to pass such extra flags
is only available starting with ASDF 2.22.3.)
This feature is notably exercised by asdf-finalizers.
</p>
<p>By using a string, you may reference
a function, symbol and/or package
that will only be created later during the build, but
isn&rsquo;t yet present at the time the defsystem form is evaluated.
However, if your entire system is using such a hook, you may have to
explicitly override the hook with <code>nil</code> for all the modules and files
that are compiled before the hook is defined.
</p>
<p>Using this hook, you may achieve such effects as:
locally renaming packages,
binding <var>*readtables*</var> and other syntax-controlling variables,
handling warnings and other conditions,
proclaiming consistent optimization settings,
saving code coverage information,
maintaining meta-data about compilation timings,
setting gensym counters and PRNG seeds and other sources of non-determinism,
overriding the source-location and/or timestamping systems,
checking that some compile-time side-effects were properly balanced,
etc.
</p>
<p>Note that there is no around-load hook. This is on purpose.
Some implementations such as ECL, GCL or MKCL link object files,
which allows for no such hook.
Other implementations allow for concatenating FASL files,
which doesn&rsquo;t allow for such a hook either.
We aim to discourage something that&rsquo;s not portable,
and has some dubious impact on performance and semantics
even when it is possible.
Things you might want to do with an around-load hook
are better done around-compile,
though it may at times require some creativity
(see e.g. the <code>package-renaming</code> system).
</p>
</div>
<hr>
<div class="header">
<p>
Next: <a href="Controlling-source-file-character-encoding.html">Controlling source file character encoding</a>, Previous: <a href="Miscellaneous-additional-functionality.html">Miscellaneous additional functionality</a>, Up: <a href="Miscellaneous-additional-functionality.html">Miscellaneous additional functionality</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>