Address lp# 1545148
[sbcl.git] / contrib / asdf / asdf.texinfo
blob6dcdfb763f4fb5679d96f58a0e3ec7783a694197
1 \input texinfo          @c -*- texinfo -*-
2 @c %**start of header
3 @setfilename asdf.info
4 @settitle ASDF Manual
5 @syncodeindex tp fn
6 @c %**end of header
8 @c We use @&key, etc to escape & from TeX in lambda lists --
9 @c so we need to define them for info as well.
10 @macro AallowOtherKeys
11 &allow-other-keys
12 @end macro
13 @macro Aoptional
14 &optional
15 @end macro
16 @macro Arest
17 &rest
18 @end macro
19 @macro Akey
20 &key
21 @end macro
22 @macro Abody
23 &body
24 @end macro
26 @c for install-info
27 @dircategory Software development
28 @direntry
29 * asdf: (asdf).           Another System Definition Facility (for Common Lisp)
30 @end direntry
32 @copying
33 This manual describes ASDF, a system definition facility
34 for Common Lisp programs and libraries.
36 You can find the latest version of this manual at
37 @url{https://common-lisp.net/project/asdf/asdf.html}.
39 ASDF Copyright @copyright{} 2001-2015 Daniel Barlow and contributors.
41 This manual Copyright @copyright{} 2001-2015 Daniel Barlow and contributors.
43 This manual revised @copyright{} 2009-2015 Robert P. Goldman and Francois-Rene Rideau.
45 Permission is hereby granted, free of charge, to any person obtaining
46 a copy of this software and associated documentation files (the
47 ``Software''), to deal in the Software without restriction, including
48 without limitation the rights to use, copy, modify, merge, publish,
49 distribute, sublicense, and/or sell copies of the Software, and to
50 permit persons to whom the Software is furnished to do so, subject to
51 the following conditions:
53 The above copyright notice and this permission notice shall be
54 included in all copies or substantial portions of the Software.
56 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
57 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
59 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
60 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
61 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
62 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64 @end copying
66 @include version.texinfo
68 @titlepage
69 @title ASDF: Another System Definition Facility
70 @subtitle Manual for Version @value{VERSION}
71 @c The following two commands start the copyright page.
72 @page
73 @vskip 0pt plus 1filll
74 @insertcopying
75 @end titlepage
77 @c Output the table of contents at the beginning.
78 @contents
80 @c -------------------
82 @ifnottex
84 @node Top, Introduction, (dir), (dir)
85 @top ASDF: Another System Definition Facility
86 @ifnottex
87 Manual for Version @value{VERSION}
88 @end ifnottex
91 @insertcopying
93 @menu
94 * Introduction::
95 * Quick start summary::
96 * Loading ASDF::
97 * Configuring ASDF::
98 * Using ASDF::
99 * Defining systems with defsystem::
100 * The object model of ASDF::
101 * Controlling where ASDF searches for systems::
102 * Controlling where ASDF saves compiled files::
103 * Error handling::
104 * Miscellaneous additional functionality::
105 * Getting the latest version::
106 * FAQ::
107 * Ongoing Work::
108 * Bibliography::
109 * Concept Index::
110 * Function and Class Index::
111 * Variable Index::              @c @detailmenu
114 @detailmenu
115  --- The Detailed Node Listing ---
117 Loading ASDF
119 * Loading a pre-installed ASDF::
120 * Checking whether ASDF is loaded::
121 * Upgrading ASDF::
122 * Replacing your implementation's ASDF::
123 * Loading ASDF from source::
125 Configuring ASDF
127 * Configuring ASDF to find your systems::
128 * Configuring ASDF to find your systems --- old style::
129 * Configuring where ASDF stores object files::
130 * Resetting the ASDF configuration::
132 Using ASDF
134 * Loading a system::
135 * Convenience Functions::
136 * Moving on::
138 Defining systems with defsystem
140 * The defsystem form::
141 * A more involved example::
142 * The defsystem grammar::
143 * Other code in .asd files::
144 * The package-inferred-system extension::
146 The Object model of ASDF
148 * Operations::
149 * Components::
150 * Dependencies::
151 * Functions::
153 Operations
155 * Predefined operations of ASDF::
156 * Creating new operations::
158 Components
160 * Common attributes of components::
161 * Pre-defined subclasses of component::
162 * Creating new component types::
164 properties
166 * Pre-defined subclasses of component::
167 * Creating new component types::
169 Controlling where ASDF searches for systems
171 * Configurations::
172 * Truenames and other dangers::
173 * XDG base directory::
174 * Backward Compatibility::
175 * Configuration DSL::
176 * Configuration Directories::
177 * Shell-friendly syntax for configuration::
178 * Search Algorithm::
179 * Caching Results::
180 * Configuration API::
181 * Introspection::
182 * Status::
183 * Rejected ideas::
184 * TODO::
185 * Credits for the source-registry::
187 Configuration Directories
189 * The here directive::
191 Introspection
193 * *source-registry-parameter* variable::
194 * Information about system dependencies::
196 Controlling where ASDF saves compiled files
198 * Output Configurations::
199 * Output Backward Compatibility::
200 * Output Configuration DSL::
201 * Output Configuration Directories::
202 * Output Shell-friendly syntax for configuration::
203 * Semantics of Output Translations::
204 * Output Caching Results::
205 * Output location API::
206 * Credits for output translations::
208 Miscellaneous additional functionality
210 * Controlling file compilation::
211 * Controlling source file character encoding::
212 * Miscellaneous Functions::
213 * Some Utility Functions::
217 * Where do I report a bug?::
218 * Mailing list::
219 * What has changed between ASDF 1 ASDF 2 and ASDF 3?::
220 * Issues with installing the proper version of ASDF::
221 * Issues with configuring ASDF::
222 * Issues with using and extending ASDF to define systems::
223 * ASDF development FAQs::
225 ``What has changed between ASDF 1, ASDF 2, and ASDF 3?''
227 * What are ASDF 1 2 3?::
228 * How do I detect the ASDF version?::
229 * ASDF can portably name files in subdirectories::
230 * Output translations::
231 * Source Registry Configuration::
232 * Usual operations are made easier to the user::
233 * Many bugs have been fixed::
234 * ASDF itself is versioned::
235 * ASDF can be upgraded::
236 * Decoupled release cycle::
237 * Pitfalls of the transition to ASDF 2::
238 * Pitfalls of the upgrade to ASDF 3::
239 * What happened to the bundle operations::
241 Issues with installing the proper version of ASDF
243 * My Common Lisp implementation comes with an outdated version of ASDF. What to do?::
244 * I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?::
246 Issues with configuring ASDF
248 * How can I customize where fasl files are stored?::
249 * How can I wholly disable the compiler output cache?::
251 Issues with using and extending ASDF to define systems
253 * How can I cater for unit-testing in my system?::
254 * How can I cater for documentation generation in my system?::
255 * How can I maintain non-Lisp (e.g. C) source files?::
256 * I want to put my module's files at the top level.  How do I do this?::
257 * How do I create a system definition where all the source files have a .cl extension?::
258 * How do I mark a source file to be loaded only and not compiled?::
259 * How do I work with readtables?::
261 ASDF development FAQs
263 * How do run the tests interactively in a REPL?::
265 @end detailmenu
266 @end menu
268 @end ifnottex
270 @c -------------------
272 @node Introduction, Quick start summary, Top, Top
273 @comment  node-name,  next,  previous,  up
274 @chapter Introduction
275 @cindex ASDF-related features
276 @vindex *features*
277 @cindex Testing for ASDF
278 @cindex ASDF versions
279 @cindex :asdf
280 @cindex :asdf2
281 @cindex :asdf3
283 ASDF is Another System Definition Facility:
284 a tool for specifying how systems of Common Lisp software
285 are made up of components (sub-systems and files),
286 and how to operate on these components in the right order
287 so that they can be compiled, loaded, tested, etc.
288 If you are new to ASDF, @pxref{Quick start summary,,the quick start
289 guide}.
291 ASDF presents three faces:
292 one for users of Common Lisp software who want to reuse other people's code,
293 one for writers of Common Lisp software who want to specify how to build their systems,
294 and one for implementers of Common Lisp extensions who want to extend
295 the build system.
296 For more specifics,
297 @pxref{Using ASDF},
298 to learn how to use ASDF to load a system.
299 @xref{Defining systems with defsystem},
300 to learn how to define a system of your own.
301 @xref{The object model of ASDF}, for a description of
302 the ASDF internals and how to extend ASDF.
304 Note that
305 ASDF is @emph{not} a tool for library and system @emph{installation};
306 it plays a role like @code{make} or @code{ant}, not like a package manager.
307 In particular, ASDF should not to be confused with Quicklisp or ASDF-Install,
308 that attempt to find and download ASDF systems for you.
309 Despite what the name might suggest, ASDF-Install is not part of ASDF, but a separate piece of software.
310 ASDF-Install is also unmaintained and obsolete.
311 We recommend you use Quicklisp
312 (@uref{http://www.quicklisp.org/}) instead,
313 a Common Lisp package manager which works well and is being actively maintained.
314 If you want to download software from version control instead of tarballs,
315 so you may more easily modify it, we recommend clbuild (@uref{http://common-lisp.net/project/clbuild/}).
316 We recommend @file{~/common-lisp/}
317 as a place into which to install Common Lisp software;
318 starting with ASDF 3.1.2, it is included in the default source-registry configuration.
320 Finally, note that this manual is incomplete.
321 All the bases are covered,
322 but many advanced topics are only barely alluded to,
323 and there is not much in terms of examples.
324 The source code remains the ultimate source of information,
325 free software systems in Quicklisp remain the best source of examples,
326 and the mailing-list the best place to ask for help.
329 @node  Quick start summary, Loading ASDF, Introduction, Top
330 @chapter Quick start summary
332 @itemize
334 @item To load an ASDF system:
336 @itemize
337 @item
338 Load ASDF itself into your Lisp image, using
339 @code{(require "asdf")}.
340 Check that you have a recent version using @code{(asdf:asdf-version)}.
341 For more details, or if any of the above fails, @pxref{Loading ASDF}.
343 @item
344 Make sure software is installed where ASDF can find it.
345 The simplest way is to put all your Lisp code in subdirectories of
346 @file{~/common-lisp/} (starting with ASDF 3.1.2),
347 or @file{~/.local/share/common-lisp/source/}
348 (for ASDF 2 and later, or if you want to keep source in a hidden directory).
349 For more details, @pxref{Configuring ASDF to find your systems}.
351 @item
352 Load your system with @code{(asdf:load-system "@var{my-system}")}.
353 @xref{Using ASDF}.
355 @end itemize
357 @item To make your own ASDF system:
359 @itemize
360 @item
361 As above, load and configure ASDF.
363 @item
364 Make a new directory for your system, @code{@var{my-system}/},
365 again in a location where ASDF can find it.
366 All else being equal, the easiest location is probably
367 @file{~/common-lisp/my-system/}.
368 @xref{Configuring ASDF to find your systems}.
371 @item
372 Create an ASDF system definition listing the dependencies of
373 your system, its components, and their interdependencies,
374 and put it in @file{@var{my-system}.asd}.
375 This file must have the same name as your system, all lowercase.
376 @xref{Defining systems with defsystem}.
378 @item
379 Use @code{(asdf:load-system "@var{my-system}")}
380 to make sure it's all working properly. @xref{Using ASDF}.
382 @end itemize
383 @end itemize
385 @c FIXME: (1) add a sample project that the user can cut and paste to
386 @c get started.  (2) discuss the option of starting with Quicklisp.
392 @node Loading ASDF, Configuring ASDF, Quick start summary, Top
393 @comment  node-name,  next,  previous,  up
394 @chapter Loading ASDF
396 @menu
397 * Loading a pre-installed ASDF::
398 * Checking whether ASDF is loaded::
399 * Upgrading ASDF::
400 * Replacing your implementation's ASDF::
401 * Loading ASDF from source::
402 @end menu
404 @node  Loading a pre-installed ASDF, Checking whether ASDF is loaded, Loading ASDF, Loading ASDF
405 @section Loading a pre-installed ASDF
407 The recommended way to load ASDF is via:
408 @lisp
409 (require "asdf")
410 @end lisp
412 All actively maintained Lisp implementations now include a copy of ASDF 3
413 that you can load this way using Common Lisp's @code{require} function.@footnote{
414 NB: all implementations except GNU CLISP also accept
415 @code{(require "ASDF")}, @code{(require 'asdf)} and @code{(require :asdf)}.
416 For portability's sake, you should use @code{(require "asdf")}.
419 If the implementation you are using doesn't provide a recent ASDF 3,
420 we recommend you upgrade it.
421 If for some reason you would rather not upgrade it,
422 we recommend you replace your implementation's ASDF.
423 @xref{Replacing your implementation's ASDF}.
424 If all else fails, see @pxref{Loading ASDF from source} below.
426 If you use an actively maintained implementation that fails to provide
427 an up-to-date enough stable release of ASDF,
428 you may also send a bug report to your Lisp vendor and complain about it
429 --- or you may fix the issue yourself if it's free software.
431 As of the writing of this manual,
432 the following implementations provide ASDF 3 this way:
433 ABCL, Allegro CL, CLASP, Clozure CL, CMUCL, ECL, GNU CLISP, LispWorks, MKCL, SBCL.
434 The following implementations only provide ASDF 2:
435 MOCL, XCL.
436 The following implementations don't provide ASDF:
437 Corman CL, GCL, Genera, MCL, SCL.
438 The latter implementations are not actively maintained (except maybe GCL);
439 if some of them are ever released again, they probably will include ASDF 3.
441 For maximum convenience you might want to have ASDF loaded
442 whenever you start your Lisp implementation,
443 for example by loading it from the startup script or dumping a custom core
444 --- check your Lisp implementation's manual for details.
445 SLIME notably sports a @code{slime-asdf} contrib that makes life easier with ASDF.
448 @node Checking whether ASDF is loaded, Upgrading ASDF, Loading a pre-installed ASDF, Loading ASDF
449 @section Checking whether ASDF is loaded
451 To check that ASDF is properly loaded, you can run this form:
453 @lisp
454 (asdf:asdf-version)
455 @end lisp
457 If it returns a string,
458 that is the version of ASDF that is currently installed.
459 If that version is suitably recent (say, 3.1.2 or later),
460 then you can skip directly to next chapter: @xref{Configuring ASDF}.
462 If it raises an error,
463 then either ASDF is not loaded, or
464 you are using a very old version of ASDF,
465 and need to install ASDF 3.
467 For more precision in detecting versions old and new,
468 @pxref{How do I detect the ASDF version?}.
470 If you are experiencing problems with ASDF,
471 please try upgrading to the latest released version,
472 using the method below,
473 before you contact us and raise an issue.
475 @node  Upgrading ASDF, Replacing your implementation's ASDF, Checking whether ASDF is loaded, Loading ASDF
476 @section Upgrading ASDF
477 @c FIXME: tighten this up a bit -- there's a lot of stuff here that
478 @c doesn't matter to almost anyone.  Move discussion of updating antique
479 @c versions of ASDF down, or encapsulate it.
481 If your implementation already provides ASDF 3 or later (and it should),
482 but you want a more recent ASDF version than your implementation provides,
483 then you just need to ensure the more recent ASDF is installed in a configured path, like any other system.
484 We recommend you download an official tarball or checkout a release from git into
485 @file{~/common-lisp/asdf/}.
486 (@pxref{Configuring ASDF to find your systems}).
488 Once the source code for ASDF is installed,
489 you don't need any extra step to load it beyond the usual @code{(require "asdf")}:
490 ASDF 3 will automatically look whether an updated version of itself is available
491 amongst the regularly configured systems, before it compiles anything else.
493 If your implementation fails to provide ASDF 3 or later,
494 @pxref{Replacing your implementation's ASDF}.
497 @node Replacing your implementation's ASDF, Loading ASDF from source, Upgrading ASDF, Loading ASDF
498 @section Replacing your implementation's ASDF
500 All maintained implementations now provide ASDF 3 in their latest release.
501 If your doesn't, we recommend you upgrade it.
503 Now, if you insist on using an old implementation that didn't provide ASDF or provided an old version,
504 we recommend installing a recent ASDF, as explained below,
505 into your implementation's installation directory.
506 Thus your modified implementation will now provide ASDF 3.
507 This requires proper write permissions and may necessitate execution as a system administrator.
509 The ASDF source repository contains a tool to help you upgrade your implementation's ASDF.
510 You can invoke it from the shell command-line as
511 @code{tools/asdf-tools install-asdf lispworks}
512 (where you can replace @code{lispworks} by the name of the relevant implementation),
513 or you can @code{(load "tools/install-asdf.lisp")} from your Lisp REPL.
515 This script works on
516 Allegro CL, Clozure CL, CMU CL, ECL, GCL, GNU CLISP, LispWorks, MKCL, SBCL, SCL, XCL.
517 It doesn't work on ABCL, Corman CL, Genera, MCL, MOCL.
518 Happily, ABCL is usually pretty up to date and shouldn't need that script.
519 GCL requires a very recent version, and hasn't been tested much.
520 Corman CL, Genera, MCL are obsolete anyway.
521 MOCL is incomplete.
524 @node Loading ASDF from source,  , Replacing your implementation's ASDF, Loading ASDF
525 @section Loading ASDF from source
527 If you write build scripts that must remain portable to old machines with old implementations
528 that you cannot ensure have been upgraded or modified to provide a recent ASDF,
529 you may have to install the file @file{asdf.lisp}
530 somewhere and load it with:
532 @lisp
533 (load "/path/to/your/installed/asdf.lisp")
534 @end lisp
536 The single file @file{asdf.lisp} is all you normally need to use ASDF.
538 You can extract this file from latest release tarball on the
539 @url{https://common-lisp.net/project/asdf/,ASDF website}.
540 If you are daring and willing to report bugs, you can get
541 the latest and greatest version of ASDF from its git repository.
542 @xref{Getting the latest version}.
544 For scripts that try to use ASDF simply via @code{require} at first, and
545 make heroic attempts to load it the hard way if at first they don't succeed,
546 see @file{tools/load-asdf.lisp} distributed with the ASDF source repository,
547 or the code of @url{https://cliki.net/cl-launch,@code{cl-launch}}.
550 @node Configuring ASDF, Using ASDF, Loading ASDF, Top
551 @comment  node-name,  next,  previous,  up
552 @chapter Configuring ASDF
554 For standard use cases, ASDF should work pretty much out of the box.
555 We recommend you skim the sections on configuring ASDF to find your systems
556 and choose the method of installing Lisp software that works best for you.
557 Then skip directly to @xref{Using ASDF}. That will probably be enough.
558 You are unlikely to have to worry about the way ASDF stores object files,
559 and resetting the ASDF configuration is usually only needed in corner cases.
562 @menu
563 * Configuring ASDF to find your systems::
564 * Configuring ASDF to find your systems --- old style::
565 * Configuring where ASDF stores object files::
566 * Resetting the ASDF configuration::
567 @end menu
569 @node Configuring ASDF to find your systems, Configuring ASDF to find your systems --- old style, Configuring ASDF, Configuring ASDF
570 @section Configuring ASDF to find your systems
572 In order to compile and load your systems, ASDF must be configured to find
573 the @file{.asd} files that contain system definitions.
575 There are a number of different techniques for setting yourself up with
576 ASDF, starting from easiest to the most complex:
578 @itemize @bullet
580 @item
581 Put all of your systems in one of the standard locations,
582 subdirectories of
583 @itemize
584 @item
585 @file{~/common-lisp/} or
586 @item
587 @file{~/.local/share/common-lisp/source/}.
588 @end itemize
589 If you install software there, you don't need further
590 configuration.@footnote{
591   @file{~/common-lisp/} is only included in
592   the default configuration
593   starting with ASDF 3.1.2 or later.
594   If your implementation provides an earlier variant of ASDF,
595   you may need to explicitly configure it to use this path,
596   as further explained.
598 You can then skip to the next section. @xref{Loading a system}.
600 @item
601 If you're using some tool to install software (e.g. Quicklisp),
602 the authors of that tool should already have configured ASDF.
604 @item
605 If you have more specific desires about how to lay out your software on
606 disk, the preferred way to configure where ASDF finds your systems is
607 the @code{source-registry} facility,
608 fully described in its own chapter of this manual.
609 @xref{Controlling where ASDF searches for systems}.
610 Here is a quick recipe for getting started.
612 First create the directory
613 @file{~/.config/common-lisp/source-registry.conf.d/}@footnote{
614   For Windows users, and starting with ASDF 3.1.5, start from your
615   @file{%LOCALAPPDATA%}, which is usually @file{~/AppData/Local/}
616   (but you can ask in a @code{CMD.EXE} terminal
617   @code{echo %LOCALAPPDATA%} to make sure)
618   and underneath create a subpath
619   @file{config/common-lisp/source-registry.conf.d/}.
621 there create a file with any name of your choice
622 but with the type @file{conf}@footnote{
623   By requiring the @file{.conf}
624   extension, and ignoring other files, ASDF allows you to have disabled files,
625   editor backups, etc. in the same directory with your active
626   configuration files.
628   ASDF will also ignore files whose names start with a @file{.} character.
630   It is customary to start the filename with two digits, to control the
631   sorting of the @code{conf} files in the source registry directory, and
632   thus the order in which the directories will be scanned.
634 for instance @file{50-luser-lisp.conf};
635 in this file, add the following line
636 to tell ASDF to recursively scan all the subdirectories under @file{/home/luser/lisp/}
637 for @file{.asd} files:
638 @kbd{(:tree "/home/luser/lisp/")}
640 That's enough. You may replace @file{/home/luser/lisp/} by wherever you want to install your source code.
641 You don't actually need to specify anything if you use the default @file{~/common-lisp/} as above
642 and your implementation provides ASDF 3.1.2 or later.
643 If your implementation provides an earlier variant of ASDF 3,
644 you might want to specify @kbd{(:tree (:home "common-lisp/"))} for bootstrap purposes,
645 then install a recent source tree of ASDF under @file{~/common-lisp/asdf/}.
647 If you prefer to use a ``link farm'', which is faster to use but costlier to manage than a recursive traversal,
648 say at @file{/home/luser/.asd-link-farm/}, then
649 you may instead (or additionally) create a file @file{42-asd-link-farm.conf}, containing the line:
650 @kbd{(:directory "/home/luser/.asd-link-farm/")}
652 ASDF will automatically read your configuration
653 the first time you try to find a system.
654 If necessary, you can reset the source-registry configuration with:
656 @lisp
657 (asdf:clear-source-registry)
658 @end lisp
660 @item
661 In earlier versions of ASDF, the system source registry was configured
662 using a global variable, @code{asdf:*central-registry*}.
663 For more details about this, see the following section,
664 @ref{Configuring ASDF to find your systems --- old style}.
665 Unless you need to understand this,
666 skip directly to @ref{Configuring where ASDF stores object files}.
668 @end itemize
670 Note that your Operating System distribution or your system administrator
671 may already have configured system-managed libraries for you.
675 @node Configuring ASDF to find your systems --- old style, Configuring where ASDF stores object files, Configuring ASDF to find your systems, Configuring ASDF
676 @section Configuring ASDF to find your systems --- old style
679 @c FIXME: this section should be moved elsewhere.  The novice user
680 @c should not be burdened with it. [2014/02/27:rpg]
683 The old way to configure ASDF to find your systems is by
684 @code{push}ing directory pathnames onto the variable
685 @code{asdf:*central-registry*}.
687 You must configure this variable between the time you load ASDF
688 and the time you first try to use it.
689 Loading and configuring ASDF presumably happen
690 as part of some initialization script that builds or starts
691 your Common Lisp software system.
692 (For instance, some SBCL users used to put it in their @file{~/.sbclrc}.)
694 The @code{asdf:*central-registry*} is empty by default in ASDF 2 or ASDF 3,
695 but is still supported for compatibility with ASDF 1.
696 When used, it takes precedence over the above source-registry.@footnote{
697 It is possible to further customize
698 the system definition file search.
699 That's considered advanced use, and covered later:
700 search forward for
701 @code{*system-definition-search-functions*}.
702 @xref{Defining systems with defsystem}.}
704 For example, let's say you want ASDF to find the @file{.asd} file
705 @file{/home/me/src/foo/foo.asd}.
706 In your lisp initialization file, you could have the following:
708 @lisp
709 (require "asdf")
710 (push "/home/me/src/foo/" asdf:*central-registry*)
711 @end lisp
713 Note the trailing slash: when searching for a system,
714 ASDF will evaluate each entry of the central registry
715 and coerce the result to a pathname.@footnote{
716 ASDF will indeed call @code{eval} on each entry.
717 It will skip entries that evaluate to @code{nil}.
719 Strings and pathname objects are self-evaluating,
720 in which case the @code{eval} step does nothing;
721 but you may push arbitrary s-expressions onto the central registry.
722 These s-expressions may be evaluated to compute context-dependent
723 entries, e.g. things that depend
724 on the value of shell variables or the identity of the user.
726 The variable @code{asdf:*central-registry*} is thus a list of
727 ``system directory designators''.
728 A @dfn{system directory designator} is a form
729 which will be evaluated whenever a system is to be found,
730 and must evaluate to a directory to look in (or @code{NIL}).
731 By ``directory'', we mean
732 ``designator for a pathname with a non-empty DIRECTORY component''.
734 The trailing directory name separator
735 is necessary to tell Lisp that you're discussing a directory
736 rather than a file.  If you leave it out, ASDF is likely to look in
737 @code{/home/me/src/} instead of @code{/home/me/src/foo/} as you
738 intended, and fail to find your system definition.
740 Typically there are a lot of @file{.asd} files, and
741 a common idiom was to put
742 @emph{symbolic links} to all of one's @file{.asd} files
743 in a common directory
744 and push @emph{that} directory (the ``link farm'')
745 onto
746 @code{asdf:*central-registry*},
747 instead of pushing each individual system directory.
749 ASDF knows to follow @emph{symlinks}
750 to the actual location of the systems.@footnote{
751   On Windows, you can use Windows shortcuts instead of POSIX symlinks.
752   if you try aliases under MacOS, we are curious to hear about your experience.
755 For example, if @code{#p"/home/me/cl/systems/"}
756 is an element of @code{*central-registry*}, you could set up the
757 system @var{foo} as follows:
759 @example
760 $ cd /home/me/cl/systems/
761 $ ln -s ~/src/foo/foo.asd .
762 @end example
764 This old style for configuring ASDF is not recommended for new users,
765 but it is supported for old users, and for users who want a simple way to
766 programmatically control what directories are added to the ASDF search path.
769 @node Configuring where ASDF stores object files, Resetting the ASDF configuration, Configuring ASDF to find your systems --- old style, Configuring ASDF
770 @section Configuring where ASDF stores object files
771 @findex clear-output-translations
773 ASDF lets you configure where object files will be stored.
774 Sensible defaults are provided and
775 you shouldn't normally have to worry about it.
777 This allows the same source code repository to be shared
778 between several versions of several Common Lisp implementations,
779 between several users using different compilation options,
780 with users who lack write privileges on shared source directories, etc.
781 This also keeps source directories from being cluttered
782 with object/fasl files.
784 Starting with ASDF 2, the @code{asdf-output-translations} facility
785 was added to ASDF itself.  This facility controls where object files will be stored.
786 This facility is fully described in a chapter of this manual,
787 @ref{Controlling where ASDF saves compiled files}.
789 @c FIXME: possibly this should be moved elsewhere.  It's redundant here,
790 @c and makes this section of the manual too long and daunting for the
791 @c new user. [2014/02/27:rpg]
792 @c The simplest way to add a translation to your search path,
793 @c say from @file{/foo/bar/baz/quux/}
794 @c to @file{/where/i/want/my/fasls/}
795 @c is to create the directory
796 @c @file{~/.config/common-lisp/asdf-output-translations.conf.d/}
797 @c and there create a file with any name of your choice and the type @file{conf},
798 @c for instance @file{42-bazquux.conf}
799 @c containing the line:
801 @c @kbd{("/foo/bar/baz/quux/" "/where/i/want/my/fasls/")}
803 @c To disable output translations for source under a given directory,
804 @c say @file{/toto/tata/}
805 @c you can create a file @file{40-disable-toto.conf}
806 @c with the line:
808 @c @kbd{("/toto/tata/")}
810 @c To wholly disable output translations for all directories,
811 @c you can create a file @file{00-disable.conf}
812 @c with the line:
814 @c @kbd{(t t)}
816 @c Note that your Operating System distribution or your system administrator
817 @c may already have configured translations for you.
818 @c In absence of any configuration, the default is to redirect everything
819 @c under an implementation-dependent subdirectory of @file{~/.cache/common-lisp/}.
820 @c @xref{Controlling where ASDF searches for systems}, for full details.
822 @c The required @file{.conf} extension allows you to have disabled files
823 @c or editor backups (ending in @file{~}), and works portably
824 @c (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
825 @c Excluded are files the name of which start with a @file{.} character.
826 @c It is customary to start the filename with two digits
827 @c that specify the order in which the directories will be scanned.
829 @c ASDF will automatically read your configuration
830 @c the first time you try to find a system.
831 @c You can reset the source-registry configuration with:
833 @c @lisp
834 @c (asdf:clear-output-translations)
835 @c @end lisp
837 @c And you probably should do so before you dump your Lisp image,
838 @c if the configuration may change
839 @c between the machine where you save it at the time you save it
840 @c and the machine you resume it at the time you resume it.
841 @c (Once again, you should use @code{(asdf:clear-configuration)}
842 @c before you dump your Lisp image, which includes the above.)
844 Note that before ASDF 2,
845 other ASDF add-ons offered the same functionality,
846 each in subtly different and incompatible ways:
847 ASDF-Binary-Locations, cl-launch, common-lisp-controller.
848 ASDF-Binary-Locations is now not needed anymore and should not be used.
849 cl-launch 3.000 and common-lisp-controller 7.2 have been updated
850 to delegate object file placement to ASDF.
852 @node Resetting the ASDF configuration,  , Configuring where ASDF stores object files, Configuring ASDF
853 @section Resetting the ASDF configuration
855 @c FIXME: this should probably be moved out of the "quickstart" part of
856 @c the manual. [2014/02/27:rpg]
859 When you dump and restore an image, or when you tweak your configuration,
860 you may want to reset the ASDF configuration.
861 For that you may use the following function:
863 @defun clear-configuration
864    Undoes any ASDF configuration
865    regarding source-registry or output-translations.
866 @end defun
868 @vindex *image-dump-hook*
869 This function is pushed onto the @code{uiop:*image-dump-hook*} by default,
870 which means that if you save an image using @code{uiop:dump-image},
871 or via @code{asdf:image-op} and @code{asdf:program-op},
872 it will be automatically called to clear your configuration.
873 If for some reason you prefer to call your implementation's underlying functionality,
874 be sure to call @code{clear-configuration} manually,
875 or push it into your implementation's equivalent of @code{uiop:*image-dump-hook*},
876 e.g. @code{sb-ext:*save-hooks*} on SBCL, or @code{ext:*before-save-initializations*}
877 on CMUCL and SCL, etc.
879 @node  Using ASDF, Defining systems with defsystem, Configuring ASDF, Top
880 @chapter Using ASDF
882 @menu
883 * Loading a system::
884 * Convenience Functions::
885 * Moving on::
886 @end menu
888 @node Loading a system, Convenience Functions, Using ASDF, Using ASDF
889 @section Loading a system
891 The system @var{foo} is loaded (and compiled, if necessary)
892 by evaluating the following Lisp form:
894 @example
895 (asdf:load-system :@var{foo})
896 @end example
898 On some implementations (@pxref{Convenience Functions}),
899 ASDF hooks into the @code{cl:require} facility and you can just use:
901 @example
902 (require :@var{foo})
903 @end example
905 Note that the canonical name of a system is a string, conventionally lowercase.
906 A system name can also be specified as a symbol (including a keyword),
907 in which case its @code{symbol-name} is taken and lowercased.
908 The name must be a suitable value for the @code{:name} initarg
909 to @code{make-pathname} in whatever filesystem the system is to be found.
911 The lower-casing-symbols behaviour is unconventional,
912 but was selected after some consideration.
913 The type of systems we want to support
914 either have lowercase as customary case (Unix, Mac, Windows)
915 or silently convert lowercase to uppercase (lpns).
916 @c so this makes more sense than attempting to use @code{:case :common},
917 @c which is reported not to work on some implementations
920 @node Convenience Functions, Moving on, Loading a system, Using ASDF
921 @section Convenience Functions
923 @findex load-system
924 @findex compile-system
925 @findex test-system
926 @findex require-system
927 @findex make
929 ASDF provides three commands for the most common system operations:
930 @code{load-system}, @code{compile-system}, and @code{test-system}.
931 It also provides @code{require-system}, a version of @code{load-system}
932 that skips trying to update systems that are already loaded.
933 And it provides @code{make}, a function that uses whichever operation
934 was specified by the author of the target system,
935 which by default behaves like @code{load-system}.
937 @c FIXME: We seem to export @findex bundle-system also, that some ECL users seem to rely on.
938 @c But it's probably better that bundle operations have their own manual chapter at some point.
940 @findex operate
941 @findex oos
943 Because ASDF is an extensible system
944 for defining @emph{operations} on @emph{components},
945 it also provides a generic function @code{operate},
946 so you may arbitrarily operate on your systems beyond the default operations.
947 (At the interactive REPL, users often use its shorter alias @code{oos},
948 which stands for operate-on-system, a name inherited from @code{mk-defsystem}.)
949 You'll use @code{operate} whenever you want to do something beyond
950 compiling, loading and testing.
952 Note that output from ASDF and ASDF extensions are sent
953 to the CL stream @code{*standard-output*},
954 so rebinding that stream around calls to @code{asdf:operate}
955 should redirect all output from ASDF operations.
957 @c Reminder: before ASDF can operate on a system, however,
958 @c it must be able to find and load that system's definition.
959 @c @xref{Configuring ASDF to find your systems}.
961 @c FIXME: the following is too complicated for here, especially since
962 @c :force hasn't been defined yet.  Move it. [2014/02/27:rpg]
964 @findex load-system
965 @vindex *load-system-operation*
966 @findex already-loaded-systems
967 @findex require-system
968 @code{load-system} applies @code{operate} with the operation from
969 @code{*load-system-operation*}
970 the system, and any provided keyword arguments.
971 @code{*load-system-operation*} by default is @code{load-op};
972 it would be @code{load-bundle-op} by default on ECL, if only an implementation bug were fixed.
974 @code{require-system} skips any update to systems that have already been loaded,
975 in the spirit of @code{cl:require}.
976 It does it by calling @code{load-system} with a keyword option excluding already loaded systems.@footnote{
977   For the curious, the option is @code{:force-not (already-loaded-systems)}.
979 On actively maintained free software implementations
980 (namely recent versions of ABCL, Clozure CL, CMUCL, ECL, GNU CLISP, MKCL and SBCL),
981 once ASDF itself is loaded, @code{cl:require} too can load ASDF systems,
982 by falling back on @code{require-system}
983 for module names not recognized by the implementation.
985 Note that @code{cl:require} and @code{require-system} are appropriate to load code
986 that is not being modified during the current programming session.
987 This notably includes the implementation-provided extension modules that @code{cl:require} can load.
988 This also includes any number of ASDF systems that the user isn't either developing or debugging,
989 for which a previously installed version is deemed to be satisfactory.
990 @code{require-system} and through it @code{cl:require} can load these systems without any problem.
991 But for code that you are actively developing, debugging, or otherwise modifying,
992 you should use @code{load-system}, so ASDF will pick on your modifications
993 and transitively re-build the modified files and everything that depends on them.
995 Finally, starting with ASDF 3.1, a function @code{make} is also available,
996 that does ``The Right Thing'' with your system.
997 The default behaviour is to load the system as if by @code{load-system};
998 but instead of this default, system authors can specify
999 the intended use of their system by specifying their desired operation
1000 with a @code{:build-operation} argument in the system definition.
1001 @c Document :build-operation in the defsystem section.
1002 @c Document in the extension section that for richer programmatic access, you may instead use an overriding
1003 @c @code{(defmethod component-depends-on ((o build-op) (s system)) ...)}.
1006 @node Moving on,  , Convenience Functions, Using ASDF
1007 @section Moving on
1009 That's all you need to know to use ASDF to load systems written by others.
1010 The rest of this manual deals with writing system definitions
1011 for Common Lisp software you write yourself,
1012 including how to extend ASDF to define new operation and component types.
1015 @node Defining systems with defsystem, The object model of ASDF, Using ASDF, Top
1016 @comment  node-name,  next,  previous,  up
1017 @chapter Defining systems with defsystem
1019 This chapter describes how to use ASDF to define systems and develop
1020 software.
1023 @menu
1024 * The defsystem form::
1025 * A more involved example::
1026 * The defsystem grammar::
1027 * Other code in .asd files::
1028 * The package-inferred-system extension::
1029 @end menu
1031 @node  The defsystem form, A more involved example, Defining systems with defsystem, Defining systems with defsystem
1032 @comment  node-name,  next,  previous,  up
1033 @section The defsystem form
1034 @findex defsystem
1035 @cindex asdf-user
1036 @findex load-asd
1038 This section begins with an example of a system definition,
1039 then gives the full grammar of @code{defsystem}.
1041 Let's look at a simple system.
1042 This is a complete file that should be saved as @file{hello-lisp.asd}
1043 (in order that ASDF can find it
1044 when ordered to operate on the system named @code{"hello-lisp"}).
1046 @lisp
1047 ;; Usual Lisp comments are allowed here
1049 (defsystem "hello-lisp"
1050   :description "hello-lisp: a sample Lisp system."
1051   :version "0.0.1"
1052   :author "Joe User <joe@@example.com>"
1053   :licence "Public Domain"
1054   :depends-on ("optima.ppcre" "command-line-arguments")
1055   :components ((:file "packages")
1056                (:file "macros" :depends-on ("packages"))
1057                (:file "hello" :depends-on ("macros"))))
1058 @end lisp
1060 Some notes about this example:
1062 @itemize
1064 @item
1065 The @code{defsystem} form defines a system named @code{hello-lisp}
1066 that contains three source files:
1067 @file{packages.lisp}, @file{macros.lisp} and @file{hello.lisp}.
1069 @item
1070 The @file{.lisp} suffix is implicit for Lisp source files.
1071 The source files are located in the same directory
1072 as the @code{.asd} file with the system definition.
1073 @c FIXME: the following should live somewhere, but not in the quickstart
1074 @c page. [2014/05/03:rpg]
1075 @c ASDF resolves symbolic links (or Windows shortcuts)
1076 @c before loading the system definition file and
1077 @c stores its location in the resulting system@footnote{
1078 @c It is possible, though almost never necessary, to override this behaviour.}.
1079 @c This is a good thing because the user can move the system sources
1080 @c without having to edit the system definition.
1082 @c FIXME: The first example system should probably use just :serial T.
1083 @item
1084 The file @file{macros} depends on @file{packages}
1085 (presumably because the package it's in is defined in @file{packages}),
1086 and the file @file{hello} depends on @file{macros}
1087 (and hence, transitively on @file{packages}).
1088 This means that ASDF will compile and load @file{packages} then @file{macros}
1089 before starting the compilation of file @file{hello}.
1091 @item
1092 This example system has external dependencies on two other systems,
1093 @code{optima.ppcre} (that provides a friendly interface to matching regular expressions),
1094 and @code{command-line-arguments} (that provides a way to parse arguments passed from the shell command line).
1095 To use this system, ASDF must be configured to find installed copies of these systems;
1096 it will load them before it tries to compile and load @code{hello-lisp}.
1098 @item
1099 This system also defines a bunch of metadata.
1100 While it is optional to define these fields
1101 (and other fields like @code{:bug-tracker}, @code{:mailto}, @code{:long-name},
1102 @code{:long-description}, @code{:source-control}),
1103 it is strongly recommended to define the fields @code{:description}, @code{:version}, @code{:author}, and @code{:licence},
1104 especially if you intend your software to be eventually included in Quicklisp.
1106 @c FIXME: Should have cross-reference to "Version specifiers" in the
1107 @c defsystem grammar, but the cross-referencing is so broken by
1108 @c insufficient node breakdown that I have not put one in.
1109 @c FIXME: this is way too detailed for the first example!
1110 @c move it!
1111 @item
1112 Make sure you know how the @code{:version} numbers will be parsed!
1113 Only period-separated non-negative integers are accepted at present.
1114 See below Version specifiers in @ref{The defsystem grammar}.
1116 @item
1117 This file contains a single @code{defsystem} declaration.
1118 More complex system definition files are possible with arbitrary Lisp code,
1119 but we recommend that you keep it simple if you can.
1120 This will make your system definitions more robust and more future-proof.
1122 @cindex :version
1124 @end itemize
1126 This is all you need to know to define simple systems.
1127 The next example is much more involved, to give you a glimpse of how you can do more complex things.
1128 However, since it's ultimately arbitrary Lisp code, there is no bottom to the rabbit hole.
1129 @c FIXME: divide the next example into many examples, to introduce fewer concepts at once.
1132 @node  A more involved example, The defsystem grammar, The defsystem form, Defining systems with defsystem
1133 @comment  node-name,  next,  previous,  up
1134 @section A more involved example
1135 @findex defsystem
1137 Let's illustrate some more involved uses of @code{defsystem} via a
1138 slightly convoluted example:
1140 @lisp
1141 (in-package :asdf-user)
1143 (defsystem "foo"
1144   :version (:read-file-form "variables" :at (3 2))
1145   :components
1146   ((:file "package")
1147    (:file "variables" :depends-on ("package"))
1148    (:module "mod"
1149      :depends-on ("package")
1150      :serial t
1151      :components ((:file "utils")
1152                   (:file "reader")
1153                   (:file "cooker")
1154                   (:static-file "data.raw"))
1155      :output-files (compile-op (o c) (list "data.cooked"))
1156      :perform (compile-op :after (o c)
1157         (cook-data
1158          :in (component-pathname (find-component c "data.raw"))
1159          :out (first (output-files o c)))))
1160    (:file "foo" :depends-on ("mod"))))
1162 (defmethod action-description
1163     ((o compile-op) (c (eql (find-component "foo" "mod"))))
1164   "cooking data")
1165 @end lisp
1167 Here are some notes about this example:
1169 @itemize
1171 @item
1172 The main thing this file does is define a system @code{foo}.
1173 It also contains other Lisp forms, which we'll examine below.
1175 @item
1176 Besides Lisp source files, this system contains a @code{:module} component
1177 named @code{"mod"}, which is a collection of three Lisp source files
1178 @file{utils.lisp}, @file{reader.lisp}, @file{cooker.lisp} and @file{data.raw}
1180 @item
1181 Note that the @code{:static-file} does not have an implicit file type,
1182 unlike the Lisp source files.
1184 @item
1185 This files will be located in a subdirectory of the main code directory named
1186 @file{mod/} (this location could have been overridden to be
1187 in the same directory, or in a different subdirectory;
1188 see the discussion of the @code{:pathname} option in @ref{The defsystem grammar}).
1190 @item
1191 The @code{:serial t} says that each sub-component of @code{mod} depends on the previous components,
1192 so that @file{cooker.lisp} depends-on @file{utils.lisp}, which depends-on @file{reader.lisp}.
1193 Also @file{data.raw} depends on all of them, but that doesn't matter since it's a static file;
1194 on the other hand, if it appeared first, then all the Lisp files would be recompiled
1195 when the data is modified, which is probably not what is desired in this case.
1197 @item
1198 The method-form tokens provide a shorthand for defining methods on
1199 particular components.  This part
1201 @lisp
1202      :output-files (compile-op (o c) (list "data.cooked"))
1203      :perform (compile-op :after (o c)
1204         (cook-data
1205          :in (component-pathname (find-component c "data.raw"))
1206          :out (first (output-files o c))))
1207 @end lisp
1209 has the effect of
1211 @lisp
1212 (defmethod output-files ((o compile-op) (c (eql ...)))
1213   (list "data.cooked"))
1214 (defmethod perform :after ((o compile-op) (c (eql ...)))
1215   (cook-data
1216    :in (component-pathname (find-component c "data.raw"))
1217    :out (first (output-files o c))))
1218 @end lisp
1220 where @code{...} is the component in question.
1221 In this case @code{...} would expand to something like
1223 @lisp
1224 (find-component "foo" "mod")
1225 @end lisp
1227 For more details on the syntax of such forms,
1228 @pxref{The defsystem grammar}.
1229 For more details on what these methods do, @pxref{Operations} in
1230 @ref{The object model of ASDF}.
1232 @item
1233 There is an additional @code{defmethod} with a similar effect,
1234 because ASDF (as of ASDF 3.1.5)
1235 fails to accept inline-methods as above for @code{action-description},
1236 instead only supporting the deprecated @code{explain} interface.
1238 @c FIXME: The following plunge into detail weeds is not appropriate in this
1239 @c location. [2010/10/03:rpg]
1240 @c note that although this also supports @code{:before} methods,
1241 @c they may not do what you want them to ---
1242 @c a @code{:before} method on perform @code{((op compile-op) (c (eql ...)))}
1243 @c will run after all the dependencies and sub-components have been processed,
1244 @c but before the component in question has been compiled.
1246 @item
1247 In this case, these methods describe how this module defines code
1248 that it then uses to cook some data.
1250 @item
1251 Importantly, ASDF is told about the input and output files
1252 used by the data cooker,
1253 and to make sure everyone agrees,
1254 the cooking function explicitly uses ASDF to access pathnames
1255 to the input and output data.
1257 @c FIXME: move most of this package discussion to its own section,
1258 @c and leave only a reference here.
1260 @item
1261 The file starts with a form @code{(in-package :asdf-user)},
1262 but it is actually redundant, not necessary and not recommended.
1263 But yet more complex cases (also not recommended) may usefully use an @code{in-package} form.
1265 @item
1266 Indeed, ASDF does not load @file{.asd} files simply with @code{cl:load},
1267 and neither should you.
1268 You should let ASDF find and load them when you operate on systems.
1269 If you somehow @emph{must} load a @file{.asd} file,
1270 use the same function @code{asdf:load-asd} that ASDF uses.
1271 Among other things, it already binds the @code{*package*} to @code{asdf-user}.
1272 Recent versions of SLIME (2013-02 and later) know to do that when you @kbd{C-c C-k}
1273 when you use the @code{slime-asdf} contrib.
1275 @item
1276 You shouldn't use an @code{in-package} form
1277 if you're keeping things simple.
1278 You should only use @code{in-package} (and before it, a @code{defpackage})
1279 when you're going to define new classes, functions, variables, macros, etc.,
1280 in the @code{.asd} file, and want to thereby avoid name clashes.
1281 Manuals for old versions of ASDF recommended use of such an idiom in @file{.asd} files,
1282 but as of ASDF 3, we recommend that you don't do that anymore,
1283 and instead define any ASDF extensions in their own system,
1284 on which you can then declare a dependency using @code{:defsystem-depends-on}.
1285 @xref{The defsystem grammar}.
1287 @item
1288 More generally, you can always rely on symbols
1289 from packages @code{asdf}, @code{common-lisp} and @code{uiop}
1290 being available in @code{.asd} files ---
1291 most importantly including @code{defsystem}.
1292 It is therefore redundant and in bad taste to use a package-prefixed @code{asdf:defsystem} symbol
1293 in a @file{.asd} file.
1294 Just use @code{(defsystem ...)}.
1295 Only package-prefix it when somehow dynamically generating system definitions
1296 from a package that doesn't already use the ASDF package.
1298 @item
1299 @code{asdf-user} is actually only available starting since ASDF 3, but then again,
1300 ASDF 1 and 2 did crazy things with packages that ASDF 3 has stopped doing@footnote{
1301   ASDF 1 and 2 (up until 2.26)
1302   used to dynamically create and delete temporary packages @code{asdf@emph{N}},
1303   one for each @file{.asd} file, in a misguided attempt to thereby reduce name clashes;
1304   but it failed at that goal and only made things more complex.
1305   ASDF 3 just uses a shared package @code{asdf-user} instead,
1306   and relies on the usual Common Lisp conventions to avoid clashes.
1307   As far as package oddities go, you may just notice that
1308   the @code{asdf-user} package also uses @code{uiop/common-lisp},
1309   a variant of the @code{common-lisp} package that papers over
1310   deficiencies in more obscure Common Lisp implementations;
1311   but unless you care about Corman Lisp, GCL, Genera or MCL, you shouldn't be concerned.
1313 and since all implementations provide ASDF 3, you shouldn't care about compatibility with ASDF 2.
1314 We do not support ASDF 2 anymore, and we recommend that neither should you.
1316 @item
1317 Starting with ASDF 3.1, @code{asdf-user} uses @code{uiop},
1318 whereas in earlier variants of ASDF 3 it only used @code{uiop/package}.
1319 We recommend you either prefix use of UIOP functions with the package prefix @code{uiop:},
1320 or make sure your system @code{:depends-on ((:version "asdf" "3.1.2"))}
1321 or has a @code{#-asdf3.1 (error "MY-SYSTEM requires ASDF 3.1.2")}.
1323 @item
1324 Finally, we elided most metadata, but showed how you can have ASDF automatically extract
1325 the system's version from a source file. In this case, the 3rd subform of the 4th form
1326 (note that Lisp uses 0-based indexing, English uses 1-based indexing).
1327 Presumably, the 4th form looks like @code{(defparameter *foo-version* "5.6.7")}.
1329 @end itemize
1332 @node  The defsystem grammar, Other code in .asd files, A more involved example, Defining systems with defsystem
1333 @comment  node-name,  next,  previous,  up
1334 @section The defsystem grammar
1335 @findex defsystem
1336 @cindex DEFSYSTEM grammar
1338 @c FIXME: @var typesetting not consistently used here.  We should either expand
1339 @c its use to everywhere, or we should kill it everywhere.
1342 @example
1343 system-definition := ( defsystem system-designator @var{system-option}* )
1345 system-option := :defsystem-depends-on system-list
1346                  | :weakly-depends-on @var{system-list}
1347                  | :class class-name (see discussion below)
1348                  | system-option
1349                  | module-option
1350                  | option
1352 # These are only available since ASDF 3 (actually its alpha release 2.27)
1353 system-option := :homepage string
1354                  | :bug-tracker string
1355                  | :mailto string
1356                  | :long-name string
1357                  | :source-control source-control
1358                  | :version version-specifier
1360 source-control := (keyword string)
1362 module-option := :components component-list
1363                  | :serial [ t | nil ]
1365 option :=
1366         | :pathname pathname-specifier
1367         | :default-component-class class-name
1368         | :perform method-form
1369         | :explain method-form
1370         | :output-files method-form
1371         | :operation-done-p method-form
1372         | :if-feature feature-expression
1373         | :depends-on ( @var{dependency-def}* )
1374         | :in-order-to ( @var{dependency}+ )
1377 system-list := ( @var{simple-component-name}* )
1379 component-list := ( @var{component-def}* )
1381 component-def  := ( component-type simple-component-name @var{option}* )
1383 component-type := :module | :file | :static-file | other-component-type
1385 other-component-type := symbol-by-name
1386                         (@pxref{The defsystem grammar,,Component types})
1388 # This is used in :depends-on, as opposed to ``dependency,''
1389 # which is used in :in-order-to
1390 dependency-def := simple-component-name
1391                | ( :feature @var{feature-expression} dependency-def )
1392                | ( :version simple-component-name version-specifier )
1393                | ( :require module-name )
1395 # ``dependency'' is used in :in-order-to, as opposed to
1396 # ``dependency-def''
1397 dependency := (dependent-op @var{requirement}+)
1398 requirement := (required-op @var{required-component}+)
1399 dependent-op := operation-name
1400 required-op := operation-name
1402 simple-component-name := string
1403                       |  symbol
1405 pathname-specifier := pathname | string | symbol
1407 method-form := (operation-name qual lambda-list @Arest{} body)
1408 qual := method qualifier
1410 component-dep-fail-option := :fail | :try-next | :ignore
1412 feature-expression := keyword
1413                       | (:and @var{feature-expression}*)
1414                       | (:or @var{feature-expression}*)
1415                       | (:not @var{feature-expression})
1416 @end example
1419 @subsection Component names
1421 Component names (@code{simple-component-name})
1422 may be either strings or symbols.
1424 @subsection Component types
1426 Component type names, even if expressed as keywords, will be looked up
1427 by name in the current package and in the asdf package, if not found in
1428 the current package.  So a component type @code{my-component-type}, in
1429 the current package @code{my-system-asd} can be specified as
1430 @code{:my-component-type}, or @code{my-component-type}.
1432 @code{system} and its subclasses are @emph{not}
1433 allowed as component types for such children components.
1435 @subsection System class names
1437 A system class name will be looked up
1438 in the same way as a Component type (see above),
1439 except that only @code{system} and its subclasses are allowed.
1440 Typically, one will not need to specify a system
1441 class name, unless using a non-standard system class defined in some
1442 ASDF extension, typically loaded through @code{DEFSYSTEM-DEPENDS-ON},
1443 see below.  For such class names in the ASDF package, we recommend that
1444 the @code{:class} option be specified using a keyword symbol, such as
1446 @example
1447 :class :MY-NEW-SYSTEM-SUBCLASS
1448 @end example
1450 This practice will ensure that package name conflicts are avoided.
1451 Otherwise, the symbol @code{MY-NEW-SYSTEM-SUBCLASS} will be read into
1452 the current package @emph{before} it has been exported from the ASDF
1453 extension loaded by @code{:defsystem-depends-on}, causing a name
1454 conflict in the current package.
1456 @subsection Defsystem depends on
1457 @cindex :defsystem-depends-on
1459 The @code{:defsystem-depends-on} option to @code{defsystem} allows the
1460 programmer to specify another ASDF-defined system or set of systems that
1461 must be loaded @emph{before} the system definition is processed.
1462 Typically this is used to load an ASDF extension that is used in the
1463 system definition.
1465 @subsection Weakly depends on
1466 @cindex :weakly-depends-on
1468 We do @emph{NOT} recommend you use this feature.
1469 If you are tempted to write a system @var{foo}
1470 that weakly-depends-on a system @var{bar},
1471 we recommend that you should instead
1472 write system @var{foo} in a parametric way,
1473 and offer some special variable and/or some hook to specialize its behaviour;
1474 then you should write a system @var{foo+bar}
1475 that does the hooking of things together.
1477 The (deprecated) @code{:weakly-depends-on} option to @code{defsystem}
1478 allows the programmer to specify another ASDF-defined system or set of systems
1479 that ASDF should @emph{try} to load,
1480 but need not load in order to be successful.
1481 Typically this is used if there are a number of systems
1482 that, if present, could provide additional functionality,
1483 but which are not necessary for basic function.
1485 Currently, although it is specified to be an option only to @code{defsystem},
1486 this option is accepted at any component, but it probably
1487 only makes sense at the @code{defsystem} level.
1488 Programmers are cautioned not
1489 to use this component option except at the @code{defsystem} level, as
1490 this anomalous behaviour may be removed without warning.
1492 @c Finally, you might look into the @code{asdf-system-connections} extension,
1493 @c that will let you define additional code to be loaded
1494 @c when two systems are simultaneously loaded.
1495 @c It may or may not be considered good style, but at least it can be used
1496 @c in a way that has deterministic behaviour independent of load order,
1497 @c unlike @code{weakly-depends-on}.
1500 @subsection Pathname specifiers
1501 @cindex pathname specifiers
1503 A pathname specifier (@code{pathname-specifier})
1504 may be a pathname, a string or a symbol.
1505 When no pathname specifier is given for a component,
1506 which is the usual case, the component name itself is used.
1508 If a string is given, which is the usual case,
1509 the string will be interpreted as a Unix-style pathname
1510 where @code{/} characters will be interpreted as directory separators.
1511 Usually, Unix-style relative pathnames are used
1512 (i.e. not starting with @code{/}, as opposed to absolute pathnames);
1513 they are relative to the path of the parent component.
1514 Finally, depending on the @code{component-type},
1515 the pathname may be interpreted as either a file or a directory,
1516 and if it's a file,
1517 a file type may be added corresponding to the @code{component-type},
1518 or else it will be extracted from the string itself (if applicable).
1520 For instance, the @code{component-type} @code{:module}
1521 wants a directory pathname, and so a string @code{"foo/bar"}
1522 will be interpreted as the pathname @file{#p"foo/bar/"}.
1523 On the other hand, the @code{component-type} @code{:file}
1524 wants a file of type @code{lisp}, and so a string @code{"foo/bar"}
1525 will be interpreted as the pathname @file{#p"foo/bar.lisp"},
1526 and a string @code{"foo/bar.quux"}
1527 will be interpreted as the pathname @file{#p"foo/bar.quux.lisp"}.
1528 Finally, the @code{component-type} @code{:static-file}
1529 wants a file without specifying a type, and so a string @code{"foo/bar"}
1530 will be interpreted as the pathname @file{#p"foo/bar"},
1531 and a string @code{"foo/bar.quux"}
1532 will be interpreted as the pathname @file{#p"foo/bar.quux"}.
1534 ASDF interprets the string @code{".."}
1535 as the pathname directory component word @code{:back},
1536 which when merged, goes back one level in the directory hierarchy.
1538 If a symbol is given, it will be translated into a string,
1539 and downcased in the process.
1540 The downcasing of symbols is unconventional,
1541 but was selected after some consideration.
1542 Observations suggest that the type of systems we want to support
1543 either have lowercase as customary case (Unix, Mac, windows)
1544 or silently convert lowercase to uppercase (lpns),
1545 so this makes more sense than attempting to use @code{:case :common}
1546 as argument to @code{make-pathname},
1547 which is reported not to work on some implementations.
1549 Pathname objects may be given to override the path for a component.
1550 Such objects are typically specified using reader macros such as @code{#p}
1551 or @code{#.(make-pathname ...)}.
1552 Note however, that @code{#p...} is
1553 a shorthand for @code{#.(parse-namestring ...)}
1554 and that the behaviour of @code{parse-namestring} is completely non-portable,
1555 unless you are using Common Lisp @code{logical-pathname}s,
1556 which themselves involve other non-portable behaviour
1557 (@pxref{The defsystem grammar,,Using logical pathnames}, below).
1558 Pathnames made with @code{#.(make-pathname ...)}
1559 can usually be done more easily with the string syntax above.
1560 The only case that you really need a pathname object is to override
1561 the component-type default file type for a given component.
1562 Therefore, pathname objects should only rarely be used.
1563 Unhappily, ASDF 1 used not to properly support
1564 parsing component names as strings specifying paths with directories,
1565 and the cumbersome @code{#.(make-pathname ...)} syntax had to be used.
1566 An alternative to @code{#.} read-time evaluation is to use
1567 @code{(eval `(defsystem ... ,pathname ...))}.
1569 Note that when specifying pathname objects,
1570 ASDF does not do any special interpretation of the pathname
1571 influenced by the component type, unlike the procedure for
1572 pathname-specifying strings.
1573 On the one hand, you have to be careful to provide a pathname that correctly
1574 fulfills whatever constraints are required from that component type
1575 (e.g. naming a directory or a file with appropriate type);
1576 on the other hand, you can circumvent the file type that would otherwise
1577 be forced upon you if you were specifying a string.
1579 @subsection Version specifiers
1580 @cindex version specifiers
1581 @cindex :version
1583 Version specifiers are strings to be parsed as period-separated lists of integers.
1584 I.e., in the example, @code{"0.2.1"} is to be interpreted,
1585 roughly speaking, as @code{(0 2 1)}.
1586 In particular, version @code{"0.2.1"} is interpreted the same as @code{"0.0002.1"},
1587 though the latter is not canonical and may lead to a warning being issued.
1588 Also, @code{"1.3"} and @code{"1.4"} are both strictly @code{uiop:version<} to @code{"1.30"},
1589 quite unlike what would have happened
1590 had the version strings been interpreted as decimal fractions.
1592 Instead of a string representing the version,
1593 the @code{:version} argument can be an expression that is resolved to
1594 such a string using the following trivial domain-specific language:
1595 in addition to being a literal string, it can be an expression of the form
1596 @code{(:read-file-form <pathname-or-string> :at <access-at-specifier>)},
1597 which will be resolved by reading a form in the specified pathname
1598 (read as a subpathname of the current system if relative or a unix-namestring).
1599 You may use a @code{uiop:access-at} specifier
1600 with the (optional) @code{:at} keyword,
1601 by default the specifier is @code{0}, meaning the first form is returned;
1602 subforms can also be specified, with e.g. @code{(1 2 2)} specifying
1603 ``the third subform (index 2) of the third subform (index 2) of the second form (index 1)''
1604 in the file (mind the off-by-one error in the English language).
1606 System definers are encouraged to use version identifiers of the form
1607 @var{x}.@var{y}.@var{z} for
1608 major version, minor version and patch level,
1609 where significant API incompatibilities are signaled by an increased major number.
1611 @xref{Common attributes of components}.
1613 @subsection Require
1614 @cindex :require dependencies
1616 Use the implementation's own @code{require} to load the @var{module-name}.
1618 It is good taste to use @code{:if-feature @emph{:implementation-name}}
1619 rather than @code{#+@emph{implementation-name}}
1620 to only depend on the specified module on the specific implementation that provides it.
1621 @xref{if-feature-option}.
1624 @subsection Using logical pathnames
1625 @cindex logical pathnames
1627 We do not generally recommend the use of logical pathnames,
1628 especially not so to newcomers to Common Lisp.
1629 However, we do support the use of logical pathnames by old timers,
1630 when such is their preference.
1632 To use logical pathnames,
1633 you will have to provide a pathname object as a @code{:pathname} specifier
1634 to components that use it, using such syntax as
1635 @code{#p"LOGICAL-HOST:absolute;path;to;component.lisp"}.
1637 You only have to specify such logical pathname
1638 for your system or some top-level component.
1639 Sub-components' relative pathnames,
1640 specified using the string syntax for names,
1641 will be properly merged with the pathnames of their parents.
1642 The specification of a logical pathname host however is @emph{not}
1643 otherwise directly supported in the ASDF syntax
1644 for pathname specifiers as strings.
1646 The @code{asdf-output-translation} layer will
1647 avoid trying to resolve and translate logical pathnames.
1648 The advantage of this is that
1649 you can define yourself what translations you want to use
1650 with the logical pathname facility.
1651 The disadvantage is that if you do not define such translations,
1652 any system that uses logical pathnames will behave differently under
1653 asdf-output-translations than other systems you use.
1655 If you wish to use logical pathnames you will have to configure the
1656 translations yourself before they may be used.
1657 ASDF currently provides no specific support
1658 for defining logical pathname translations.
1660 Note that the reasons we do not recommend logical pathnames are that
1661 (1) there is no portable way to set up logical pathnames @emph{before} they are used,
1662 (2) logical pathnames are limited to only portably use
1663 a single character case, digits and hyphens.
1664 While you can solve the first issue on your own,
1665 describing how to do it on each of fifteen implementations supported by ASDF
1666 is more than we can document.
1667 As for the second issue, mind that the limitation is notably enforced on SBCL,
1668 and that you therefore can't portably violate the limitations
1669 but must instead define some encoding of your own and add individual mappings
1670 to name physical pathnames that do not fit the restrictions.
1671 This can notably be a problem when your Lisp files are part of a larger project
1672 in which it is common to name files or directories in a way that
1673 includes the version numbers of supported protocols,
1674 or in which files are shared with software written
1675 in different programming languages where conventions include the use of
1676 underscores, dots or CamelCase in pathnames.
1679 @subsection Serial dependencies
1680 @cindex serial dependencies
1682 If the @code{:serial t} option is specified for a module,
1683 ASDF will add dependencies for each child component,
1684 on all the children textually preceding it.
1685 This is done as if by @code{:depends-on}.
1687 @lisp
1688 :serial t
1689 :components ((:file "a") (:file "b") (:file "c"))
1690 @end lisp
1692 is equivalent to
1694 @lisp
1695 :components ((:file "a")
1696              (:file "b" :depends-on ("a"))
1697              (:file "c" :depends-on ("a" "b")))
1698 @end lisp
1701 @subsection Source location (@code{:pathname})
1703 The @code{:pathname} option is optional in all cases for systems
1704 defined via @code{defsystem}, and generally is unnecessary.  In the
1705 simple case, source files will be found in the same directory as the
1706 system or, in the case of modules, in a subdirectory with the same name
1707 as the module.
1709 @c FIXME: This should be moved elsewhere -- it's too much detail for the
1710 @c grammar section.
1712 More specifically, ASDF follows a hairy set of rules that are designed so that
1713 @enumerate
1714 @item
1715 @code{find-system}
1716 will load a system from disk
1717 and have its pathname default to the right place.
1719 @item
1720 This pathname information will not be overwritten with
1721 @code{*default-pathname-defaults*}
1722 (which could be somewhere else altogether)
1723 if the user loads up the @file{.asd} file into his editor
1724 and interactively re-evaluates that form.
1725 @end enumerate
1727 If a system is being loaded for the first time,
1728 its top-level pathname will be set to:
1730 @itemize
1731 @item
1732 The host/device/directory parts of @code{*load-truename*},
1733 if it is bound.
1734 @item
1735 @code{*default-pathname-defaults*}, otherwise.
1736 @end itemize
1738 If a system is being redefined, the top-level pathname will be
1740 @itemize
1741 @item
1742 changed, if explicitly supplied or obtained from @code{*load-truename*}
1743 (so that an updated source location is reflected in the system definition)
1745 @item
1746 changed if it had previously been set from @code{*default-pathname-defaults*}
1748 @item
1749 left as before, if it had previously been set from @code{*load-truename*}
1750 and @code{*load-truename*} is currently unbound
1751 (so that a developer can evaluate a @code{defsystem} form
1752 from within an editor without clobbering its source location)
1753 @end itemize
1755 @subsection if-feature option
1756 @cindex :if-feature component option
1757 @anchor{if-feature-option}      @c redo if this ever becomes a node in
1758 @c its own right...
1760 This option allows you to specify a feature expression to be evaluated
1761 as if by @code{#+} to conditionally include a component in your build.
1762 If the expression is false, the component is dropped
1763 as well as any dependency pointing to it.
1764 As compared to using @code{#+} which is expanded at read-time,
1765 this allows you to have an object in your component hierarchy
1766 that can be used for manipulations beside building your project, and
1767 that is accessible to outside code that wishes to reason about system
1768 structure.
1770 Programmers should be careful to consider @strong{when} the
1771 @code{:if-feature} is evaluated.  Recall that ASDF first computes a
1772 build plan, and then executes that plan.  ASDF will check to see whether
1773 or not a feature is present @strong{at planning time}, not during the
1774 build.  It follows that one cannot use @code{:if-feature} to check
1775 features that are set during the course of the build.  It can only be
1776 used to check the state of features before any build operations have
1777 been performed.
1779 This option was added in ASDF 3.  For more information,
1780 @xref{required-features, Required features}.
1782 @subsection if-component-dep-fails option
1783 @cindex :if-component-dep-fails component option
1784 This option was removed in ASDF 3.
1785 Its semantics was limited in purpose and dubious to explain,
1786 and its implementation was breaking a hole into the ASDF object model.
1787 Please use the @code{if-feature} option instead.
1789 @subsection feature requirement
1790 This requirement was removed in ASDF 3.1.  Please do not use it.  In
1791 most cases, @code{:if-feature} (@pxref{if-feature-option}) will provide
1792 an adequate substitute.
1794 The @code{feature} requirement used to ensure that a chain of component
1795 dependencies would fail when a key feature was absent.
1796 Used in conjunction with @code{:if-component-dep-fails}
1797 this provided
1798 a roundabout way to express conditional compilation.
1801 @node Other code in .asd files, The package-inferred-system extension, The defsystem grammar, Defining systems with defsystem
1802 @section Other code in .asd files
1804 Files containing @code{defsystem} forms
1805 are regular Lisp files that are executed by @code{load}.
1806 Consequently, you can put whatever Lisp code you like into these files.
1807 However, it is recommended to keep such forms to a minimal,
1808 and to instead define @code{defsystem} extensions
1809 that you use with @code{:defsystem-depends-on}.
1811 If however, you might insist on including code in the @file{.asd} file itself,
1812 e.g., to examine and adjust the compile-time environment,
1813 possibly adding appropriate features to @code{*features*}.
1814 If so, here are some conventions we recommend you follow,
1815 so that users can control certain details of execution
1816 of the Lisp in @file{.asd} files:
1818 @itemize
1819 @item
1820 Any informative output
1821 (other than warnings and errors,
1822 which are the condition system's to dispose of)
1823 should be sent to the standard CL stream @code{*standard-output*},
1824 so that users can easily control the disposition
1825 of output from ASDF operations.
1826 @end itemize
1829 @node The package-inferred-system extension,  , Other code in .asd files, Defining systems with defsystem
1830 @section The package-inferred-system extension
1832 Starting with release 3.1.2,
1833 ASDF supports a one-package-per-file style of programming,
1834 whereby each file is its own system,
1835 and dependencies are deduced from the @code{defpackage} form
1836 (or its variant @code{uiop:define-package}).
1838 In this style, packages refer to a system with the same name (downcased);
1839 and if a system is defined with @code{:class package-inferred-system},
1840 then system names that start with that name
1841 (using the slash @code{/} separator)
1842 refer to files under the filesystem hierarchy where the system is defined.
1843 For instance, if system @code{my-lib} is defined in
1844 @file{/foo/bar/my-lib/my-lib.asd}, then system @code{my-lib/src/utility}
1845 will be found in file @file{/foo/bar/my-lib/src/utility.lisp}.
1847 This style was made popular by @code{faslpath} and @code{quick-build} before,
1848 and at the cost of a stricter package discipline,
1849 seems to make for more maintainable code.
1850 It is used by ASDF itself (starting with ASDF 3), by @code{lisp-interface-library},
1851 and a few other libraries.
1853 To use this style, choose a toplevel system name, e.g. @code{my-lib},
1854 and create a file @file{my-lib.asd}
1855 with the @code{:class :package-inferred-system} option in its @code{defsystem}.
1856 For instance:
1857 @example
1858 #-asdf3.1 (error "my-lib requires ASDF 3.1")
1859 (defsystem "my-lib"
1860   :class :package-inferred-system
1861   :depends-on ("my-lib/interface/all"
1862                "my-lib/src/all"
1863                "my-lib/extras/all")
1864   :in-order-to ((test-op (load-op "my-lib/test/all")))
1865   :perform (test-op (o c) (symbol-call :my-lib/test/all :test-suite)))
1867 (defsystem "my-lib/test" :depends-on ("my-lib/test/all"))
1869 (register-system-packages "my-lib/interface/all" '(:my-lib-interface))
1870 (register-system-packages "my-lib/src/all" '(:my-lib-implementation))
1871 (register-system-packages "my-lib/test/all" '(:my-lib-test))
1873 (register-system-packages
1874  "closer-mop"
1875  '(:c2mop :closer-common-lisp :c2cl :closer-common-lisp-user :c2cl-user))
1876 @end example
1878 In the code above, the first line checks that we are using ASDF 3.1,
1879 which provides @code{package-inferred-system}.
1881 The function @code{register-system-packages} has to be called to register
1882 packages used or provided by your system and its components
1883 where the name of the system that provides the package
1884 is not the downcase of the package name.
1886 Then, file @file{interface/order.lisp} under the @code{lil} hierarchy,
1887 that defines abstract interfaces for order comparisons,
1888 starts with the following form,
1889 dependencies being trivially computed from the @code{:use} and @code{:mix} clauses:
1891 @example
1892 (uiop:define-package :lil/interface/order
1893   (:use :closer-common-lisp
1894    :lil/interface/definition
1895    :lil/interface/base
1896    :lil/interface/eq :lil/interface/group)
1897   (:mix :fare-utils :uiop :alexandria)
1898   (:export ...))
1899 @end example
1901 ASDF can tell that this file depends on system @code{closer-mop} (registered above),
1902 @code{lil/interface/definition}, @code{lil/interface/base},
1903 @code{lil/interface/eq}, and @code{lil/interface/group}
1904 (package and system names match, and they will be looked up hierarchically).
1906 ASDF also detects dependencies from @code{:import-from} clauses.
1907 You may thus import a well-defined set of symbols from an existing package
1908 as loaded from suitably named system;
1909 or if you prefer to use any such symbol fully qualified by a package prefix,
1910 you may declare a dependency on such a package and its corresponding system
1911 via an @code{:import-from} clause with an empty list of symbols, as in:
1913 @example
1914 (defpackage :foo/bar
1915   (:use :cl)
1916   (:import-from :foo/baz #:sym1 #:sym2)
1917   (:import-from :foo/quux)
1918   (:export ...))
1919 @end example
1921 The form @code{uiop:define-package} is supported as well as @code{defpackage},
1922 and has many options that prove useful in this context,
1923 such as @code{:use-reexport} and @code{:mix-reexport}
1924 that allow for ``inheritance'' of symbols being exported.
1926 @node The object model of ASDF, Controlling where ASDF searches for systems, Defining systems with defsystem, Top
1927 @comment  node-name,  next,  previous,  up
1928 @chapter The Object model of ASDF
1929 @tindex component
1930 @tindex operation
1932 ASDF is designed in an object-oriented way from the ground up.
1933 Both a system's structure and the operations that can be performed on systems
1934 follow a extensible protocol, allowing programmers to add new behaviours to ASDF.
1935 For example, @code{cffi} adds support for special FFI description files
1936 that interface with C libraries and for wrapper files that embed C code in Lisp.
1937 @code{abcl-jar} supports creating Java JAR archives in ABCL.
1938 @code{poiu} supports compiling code in parallel using background processes.
1940 The key classes in ASDF are @code{component} and @code{operation}.
1941 A @code{component} represents an individual source file or a group of source files,
1942 and the products (e.g., fasl files) produced from it.
1943 An @code{operation} represents a transformation that can be performed on a component,
1944 turning them from source files to intermediate results to final outputs.
1945 Components are related by @emph{dependencies}, specified in system
1946 definitions.
1948 When ordered to @code{operate} with some operation on a component (usually a system),
1949 ASDF will first compute a @emph{plan}
1950 by traversing the dependency graph using function @code{make-plan}.@footnote{
1951   Historically, the function that built a plan was
1952   called @code{traverse}, and returned a list of actions;
1953   it was deprecated in favor of @code{make-plan} (that returns a plan object)
1954   when the @code{plan} objects were introduced;
1955   the old function is kept for backward compatibility and debugging purposes only.
1957 The resulting plan object contains an ordered list of @emph{actions}.
1958 An action is a pair of an @code{operation} and a @code{component},
1959 representing  a particular build step to be @code{perform}ed.
1960 The ordering of the plan ensures that no action is performed before
1961 all its dependencies have been fulfilled.@footnote{
1962   The term @emph{action}
1963   was used by Kent Pitman in his article, ``The Description of Large Systems,''
1964   (@pxref{Bibliography}).
1965   Although the term was only used by ASDF hackers starting with ASDF 2,
1966   the concept was there since the very beginning of ASDF 1,
1967   just not clearly articulated.
1970 In this chapter, we describe ASDF's object-oriented protocol,
1971 the classes that make it up, and the generic functions on those classes.
1972 These generic functions often take
1973 both an operation and a component as arguments:
1974 much of the power and configurability of ASDF is provided by
1975 this use of CLOS's multiple dispatch.
1976 We will describe the built-in component and operation classes, and
1977 explain how to extend the ASDF protocol by defining new classes and
1978 methods for ASDF's generic functions.
1979 We will also describe the many @emph{hooks} that can be configured to
1980 customize the behaviour of existing @emph{functions}.
1982 @c FIXME: Swap operations and components.
1983 @c FIXME: Possibly add a description of the PLAN object.
1984 @c Not critical, since the user isn't expected to interact with it.
1985 @menu
1986 * Operations::
1987 * Components::
1988 * Dependencies::
1989 * Functions::
1990 @end menu
1992 @node  Operations, Components, The object model of ASDF, The object model of ASDF
1993 @comment  node-name,  next,  previous,  up
1994 @section Operations
1995 @cindex operation
1997 An @dfn{operation} object of the appropriate type is instantiated
1998 whenever the user wants to do something with a system like
2000 @itemize
2001 @item compile all its files
2002 @item load the files into a running lisp environment
2003 @item copy its source files somewhere else
2004 @end itemize
2006 Operations can be invoked directly, or examined
2007 to see what their effects would be without performing them.
2008 There are a bunch of methods specialised on operation and component type
2009 that actually do the grunt work.
2010 Operations are invoked on systems via @code{operate} (@pxref{operate}).
2012 ASDF contains a number of pre-defined @t{operation} classes for common,
2013 and even fairly uncommon tasks that you might want to do with it.
2014 In addition, ASDF contains ``abstract'' @t{operation} classes that
2015 programmers can use as building blocks to define ASDF extensions.  We
2016 discuss these in turn below.
2018 @c The operation object contains whatever state is relevant for this purpose
2019 @c (perhaps a list of visited nodes, for example)
2020 @c but primarily is a nice thing to specialise operation methods on
2021 @c and easier than having them all be @code{EQL} methods.
2023 @menu
2024 * Predefined operations of ASDF::
2025 * Creating new operations::
2026 @end menu
2028 Operations are invoked on systems via @code{operate}.
2029 @anchor{operate}
2030 @deffn {Generic function} @code{operate} @var{operation} @var{component} @Arest{} @var{initargs} @Akey{} @code{force} @code{force-not} @code{verbose} @AallowOtherKeys
2031 @deffnx {Generic function} @code{oos} @var{operation} @var{component} @Arest{} @var{initargs} @Akey{} @AallowOtherKeys{}
2032 @code{operate} invokes @var{operation} on @var{system}.
2033 @code{oos} is a synonym for @code{operate} (it stands for operate-on-system).
2035 @var{operation} is a symbol that is passed,
2036 along with the supplied @var{initargs},
2037 to @code{make-operation} (which will call @code{make-instance})
2038 to create the operation object.
2039 @var{component} is a component designator,
2040 usually a string or symbol that designates a system,
2041 sometimes a list of strings or symbols that designate a subcomponent of a system.
2043 The @var{initargs} are passed to the @code{make-instance} call
2044 when creating the operation object.
2045 @c We probably want to deprecate that, because
2046 @c (1) there is a mix of flags for operate, for the operation-class, for the plan-class, etc.
2047 @c (2) flags to operations have never been well-supported, anyway.
2048 @c The future solution probably involves having an explicit :operation-options keyword or some such
2049 @c (if operation options are not wholly eliminated), a separate :plan-options, etc.
2050 Note that dependencies may cause the operation
2051 to invoke other operations on the system or its components:
2052 the new operations will be created
2053 with the same @var{initargs} as the original one.
2055 If @var{force} is @code{:all}, then all systems
2056 are forced to be recompiled even if not modified since last compilation.
2057 If @var{force} is @code{t}, then only the system being loaded
2058 is forced to be recompiled even if not modified since last compilation,
2059 but other systems are not affected.
2060 If @var{force} is a list, then it specifies a list of systems that
2061 are forced to be recompiled even if not modified since last compilation.
2062 If @var{force-not} is @code{:all}, then all systems
2063 are forced not to be recompiled even if modified since last compilation.
2064 If @var{force-not} is @code{t}, then all systems but the system being loaded
2065 are forced not to be recompiled even if modified since last compilation
2066 (note: this was changed in ASDF 3.1.2).
2067 If @var{force-not} is a list, then it specifies a list of systems that
2068 are forced not to be recompiled even if modified since last compilation.
2070 @findex register-immutable-system
2071 @cindex immutable systems
2072 Both @var{force} and @var{force-not} apply to systems that are dependencies and were already compiled.
2073 @var{force-not} takes precedences over @var{force},
2074 as it should, really, but unhappily only since ASDF 3.1.2.
2075 Moreover, systems which have been registered as immutable by @code{register-immutable-system} (since ASDF 3.1.5)
2076 are always considered @var{forced-not}, and even their @file{.asd} are not refreshed from the filesystem.
2077 @xref{Miscellaneous Functions}.
2079 @findex traverse
2080 To see what @code{operate} would do, you can use:
2081 @example
2082 (asdf:traverse operation-class system-name)
2083 @end example
2085 @end deffn
2089 @node Predefined operations of ASDF, Creating new operations, Operations, Operations
2090 @comment  node-name,  next,  previous,  up
2091 @subsection Predefined operations of ASDF
2092 @c FIXME: All these deffn's should be replaced with deftyp.  Also, we
2093 @c should set up an appropriate index.
2095 All the operations described in this section are in the @code{asdf} package.
2096 They are invoked via the @code{operate} generic function.
2098 @lisp
2099 (asdf:operate 'asdf:@var{operation-name} :@var{system-name} @{@var{operation-options ...}@})
2100 @end lisp
2102 @deffn Operation @code{compile-op}
2104 This operation compiles the specified component.
2105 A @code{cl-source-file} will be @code{compile-file}'d.
2106 All the children and dependencies of a system or module
2107 will be recursively compiled by @code{compile-op}.
2109 @code{compile-op} depends on @code{prepare-op} which
2110 itself depends on a @code{load-op} of all of a component's dependencies,
2111 as well as of its parent's dependencies.
2112 When @code{operate} is called on @code{compile-op},
2113 all these dependencies will be loaded as well as compiled;
2114 yet, some parts of the system main remain unloaded,
2115 because nothing depends on them.
2116 Use @code{load-op} to load a system.
2117 @end deffn
2119 @deffn Operation @code{load-op}
2121 This operation loads the compiled code for a specified component.
2122 A @code{cl-source-file} will have its compiled fasl @code{load}ed,
2123 which fasl is the output of @code{compile-op} that @code{load-op} depends on.
2125 @code{load-op} will recursively load all the children of a system or module.
2127 @code{load-op} also depends on @code{prepare-op} which
2128 itself depends on a @code{load-op} of all of a component's dependencies,
2129 as well as of its parent's dependencies.
2130 @end deffn
2132 @deffn Operation @code{prepare-op}
2134 This operation ensures that the dependencies of a component
2135 and its recursive parents are loaded (as per @code{load-op}),
2136 as a prerequisite before @code{compile-op} and @code{load-op} operations
2137 may be performed on a given component.
2138 @end deffn
2140 @deffn Operation @code{load-source-op}, @code{prepare-source-op}
2142 @code{load-source-op} will load the source for the files in a module
2143 rather than the compiled fasl output.
2144 It has a @code{prepare-source-op} analog to @code{prepare-op},
2145 that ensures the dependencies are themselves loaded via @code{load-source-op}.
2147 @end deffn
2149 @anchor{test-op}
2150 @deffn Operation @code{test-op}
2152 This operation will perform some tests on the module.
2153 The default method will do nothing.
2154 The default dependency is to require
2155 @code{load-op} to be performed on the module first.
2156 Its @code{operation-done-p} method returns @code{nil},
2157 which means that the operation is @emph{never} done
2159 we assume that if you invoke the @code{test-op},
2160 you want to test the system, even if you have already done so.
2162 The results of this operation are not defined by ASDF.
2163 It has proven difficult to define how the test operation
2164 should signal its results to the user
2165 in a way that is compatible with all of the various test libraries
2166 and test techniques in use in the community, and
2167 given the fact that ASDF operations do not return a value indicating
2168 success or failure.
2169 For those willing to go to the effort, we suggest defining conditions to
2170 signal when a @code{test-op} fails, and storing in those conditions
2171 information that describes which tests fail.
2173 People typically define a separate test @emph{system} to hold the tests.
2174 Doing this avoids unnecessarily adding a test framework as a dependency
2175 on a library.  For example, one might have
2176 @lisp
2177 (defsystem "foo"
2178   :in-order-to ((test-op (test-op "foo/test")))
2179  ...)
2181 (defsystem "foo/test"
2182   :depends-on ("foo" "fiveam") ; fiveam is a test framework library
2183   ...)
2184 @end lisp
2186 Then one defines @code{perform} methods on
2187 @code{test-op} such as the following:
2188 @lisp
2189 (defsystem "foo/test"
2190   :depends-on ("foo" "fiveam") ; fiveam is a test framework library
2191   :perform (test-op (o s)
2192                     (uiop:symbol-call :fiveam '#:run!
2193                        (uiop:find-symbol* '#:foo-test-suite
2194                                             :foo-tests)))
2195   ...)
2196 @end lisp
2198 @end deffn
2202 @deffn Operation @code{compile-bundle-op}, @code{monolithic-compile-bundle-op}, @code{load-bundle-op}, @code{monolithic-load-bundle-op}, @code{deliver-asd-op}, @code{monolithic-deliver-asd-op}, @code{lib-op}, @code{monolithic-lib-op}, @code{dll-op}, @code{monolithic-dll-op}, @code{image-op}, @code{program-op}
2204 These are ``bundle'' operations, that can create a single-file ``bundle''
2205 for all the contents of each system in an application,
2206 or for the entire application.
2208 @code{compile-bundle-op} will create a single fasl file for each of the systems needed,
2209 grouping all its many fasls in one,
2210 so you can deliver each system as a single fasl
2211 @code{monolithic-compile-bundle-op} will create a single fasl file for the target system
2212 and all its dependencies,
2213 so you can deliver your entire application as a single fasl.
2214 @code{load-bundle-op} will load the output of @code{compile-bundle-op}.
2215 Note that if it the output is not up-to-date,
2216 @code{compile-bundle-op} may load the intermediate fasls as a side-effect.
2217 Bundling fasls together matters a lot on ECL,
2218 where the dynamic linking involved in loading tens of individual fasls
2219 can be noticeably more expensive than loading a single one.
2221 NB: @code{compile-bundle-op}, @code{monolithic-compile-bundle-op}, @code{load-bundle-op}, @code{monolithic-load-bundle-op}, @code{deliver-asd-op}, @code{monolithic-deliver-asd-op} were respectively called
2222 @code{fasl-op}, @code{monolithic-fasl-op}, @code{load-fasl-op}, @code{monolithic-load-fasl-op}, @code{binary-op}, @code{monolithic-binary-op} before ASDF 3.1.
2223 The old names still exist for backward compatibility,
2224 though they poorly label what is going on.
2226 Once you have created a fasl with @code{compile-bundle-op},
2227 you can use @code{precompiled-system} to deliver it in a way
2228 that is compatible with clients having dependencies on your system,
2229 whether it is distributed as source or as a single binary;
2230 the @file{.asd} file to be delivered with the fasl will look like this:
2231 @example
2232 (defsystem :mysystem :class :precompiled-system
2233   :fasl (some expression that will evaluate to a pathname))
2234 @end example
2235 Or you can use @code{deliver-asd-op} to let ASDF create such a system for you
2236 as well as the @code{compile-bundle-op} output,
2237 or @code{monolithic-deliver-asd-op}.
2238 This allows you to deliver code for your systems or applications
2239 as a single file.
2240 Of course, if you want to test the result in the current image,
2241 @emph{before} you try to use any newly created @file{.asd} files,
2242 you should not forget to @code{(asdf:clear-configuration)}
2243 or at least @code{(asdf:clear-source-registry)},
2244 so it re-populates the source-registry from the filesystem.
2246 The @code{program-op} operation will create an executable program
2247 from the specified system and its dependencies.
2248 You can use UIOP for its pre-image-dump hooks, its post-image-restore hooks,
2249 and its access to command-line arguments.
2250 And you can specify an entry point @code{my-app:main}
2251 by specifying in your @code{defsystem}
2252 the option @code{:entry-point "my-app:main"}.
2253 Depending on your implementation,
2254 running @code{(asdf:operate 'asdf:program-op :my-app)}
2255 may quit the current Lisp image upon completion.
2256 See the example in
2257 @file{test/hello-world-example.asd} and @file{test/hello.lisp},
2258 as built and tested by
2259 @file{test/test-program.script} and @file{test/make-hello-world.lisp}.
2260 @code{image-op} will dump an image that may not be standalone
2261 and does not start its own function,
2262 but follows the usual execution convention of the underlying Lisp,
2263 just with more code pre-loaded,
2264 for use as an intermediate build result or with a wrapper invocation script.
2266 There is also @code{lib-op}
2267 for building a linkable @file{.a} file (Windows: @file{.lib})
2268 from all linkable object dependencies (FFI files, and on ECL, Lisp files too),
2269 and its monolithic equivalent @code{monolithic-lib-op}.
2270 And there is also @code{dll-op}
2271 (respectively its monolithic equivalent @code{monolithic-lib-op})
2272 for building a linkable @file{.so} file
2273 (Windows: @file{.dll}, MacOS X: @file{.dynlib})
2274 to create a single dynamic library
2275 for all the extra FFI code to be linked into each of your systems
2276 (respectively your entire application).
2278 All these ``bundle'' operations are available since ASDF 3
2279 on all actively supported Lisp implementations,
2280 but may be unavailable on unmaintained legacy implementations.
2281 This functionality was previously available for select implementations,
2282 as part of a separate system @code{asdf-bundle},
2283 itself descended from the ECL-only @code{asdf-ecl}.
2285 The pathname of the output of bundle operations
2286 is subject to output-translation as usual,
2287 unless the operation is equal to
2288 the @code{:build-operation} argument to @code{defsystem}.
2289 This behaviour is not very satisfactory and may change in the future.
2290 Maybe you have suggestions on how to better configure it?
2291 @end deffn
2293 @deffn Operation @code{concatenate-source-op}, @code{monolithic-concatenate-source-op}, @code{load-concatenated-source-op}, @code{compile-concatenated-source-op}, @code{load-compiled-concatenated-source-op}, @code{monolithic-load-concatenated-source-op}, @code{monolithic-compile-concatenated-source-op}, @code{monolithic-load-compiled-concatenated-source-op}
2295 These operations, as their respective names indicate,
2296 will concatenate all the @code{cl-source-file} source files in a system
2297 (or in a system and all its dependencies, if monolithic),
2298 in the order defined by dependencies,
2299 then load the result, or compile and then load the result.
2301 These operations are useful to deliver a system or application
2302 as a single source file,
2303 and for testing that said file loads properly, or compiles and then loads properly.
2305 ASDF itself is delivered as a single source file this way,
2306 using @code{monolithic-concatenate-source-op},
2307 prepending a prelude and the @code{uiop} library
2308 before the @code{asdf/defsystem} system itself.
2309 @end deffn
2312 @node  Creating new operations,  , Predefined operations of ASDF, Operations
2313 @comment  node-name,  next,  previous,  up
2314 @subsection Creating new operations
2316 ASDF was designed to be extensible in an object-oriented fashion.
2317 To teach ASDF new tricks, a programmer can implement the behaviour he wants
2318 by creating a subclass of @code{operation}.
2320 ASDF's pre-defined operations are in no way ``privileged'',
2321 but it is requested that developers never use the @code{asdf} package
2322 for operations they develop themselves.
2323 The rationale for this rule is that we don't want to establish a
2324 ``global asdf operation name registry'',
2325 but also want to avoid name clashes.
2327 Your operation @emph{must} usually provide methods
2328 for one or more of the following generic functions:
2330 @itemize
2332 @findex perform
2333 @item @code{perform}
2334 Unless your operation, like @code{prepare-op},
2335 is for dependency propagation only,
2336 the most important function for which to define a method
2337 is usually @code{perform},
2338 which will be called to perform the operation on a specified component,
2339 after all dependencies have been performed.
2341 The @code{perform} method must call @code{input-files} and @code{output-files} (see below)
2342 to locate its inputs and outputs,
2343 because the user is allowed to override the method
2344 or tweak the output-translation mechanism.
2345 Perform should only use the primary value returned by @code{output-files}.
2346 If one and only one output file is expected,
2347 it can call @code{output-file} that checks that this is the case
2348 and returns the first and only list element.
2350 @findex output-files
2351 @item @code{output-files}
2352 If your perform method has any output,
2353 you must define a method for this function.
2354 for ASDF to determine where the outputs of performing operation lie.
2356 Your method may return two values, a list of pathnames, and a boolean.
2357 If the boolean is @code{nil} (or you fail to return multiple values),
2358 then enclosing @code{:around} methods may translate these pathnames,
2359 e.g. to ensure object files are somehow stored
2360 in some implementation-dependent cache.
2361 If the boolean is @code{t} then the pathnames are marked
2362 not be translated by the enclosing @code{:around} method.
2364 @findex component-depends-on
2365 @item @code{component-depends-on}
2366 If the action of performing the operation on a component has dependencies,
2367 you must define a method on @code{component-depends-on}.
2369 Your method will take as specialized arguments
2370 an operation and a component which together identify an action,
2371 and return a list of entries describing actions that this action depends on.
2372 The format of entries is described below.
2374 It is @emph{strongly} advised that
2375 you should always append the results of @code{(call-next-method)}
2376 to the results of your method,
2377 or ``interesting'' failures will likely occur,
2378 unless you're a true specialist of ASDF internals.
2379 It is unhappily too late to compatibly use the @code{append} method combination,
2380 but conceptually that's the protocol that is being manually implemented.
2382 Each entry returned by @code{component-depends-on} is itself a list.
2384 The first element of an entry is an operation designator:
2385 either an operation object designating itself, or
2386 a symbol that names an operation class
2387 (that ASDF will instantiate using @code{make-operation}).
2388 For instance, @code{load-op}, @code{compile-op} and @code{prepare-op}
2389 are common such names, denoting the respective operations.
2391 @c FIXME COERCE-NAME is referenced, but not defined.
2392 @findex coerce-name
2393 @findex find-component
2394 The rest of each entry is a list of component designators:
2395 either a component object designating itself,
2396 or an identifier to be used with @code{find-component}.
2397 @code{find-component} will be called with the current component's parent as parent,
2398 and the identifier as second argument.
2399 The identifier is typically a string,
2400 a symbol (to be downcased as per @code{coerce-name}),
2401 or a list of strings or symbols.
2402 In particular, the empty list @code{nil} denotes the parent itself.
2404 @end itemize
2406 An operation @emph{may} provide methods for the following generic functions:
2408 @itemize
2410 @item @code{input-files}
2411 @findex input-files
2412 A method for this function is often not needed,
2413 since ASDF has a pretty clever default @code{input-files} mechanism.
2414 You only need create a method if there are multiple ultimate input
2415 files.
2416 Most operations inherit from @code{selfward-operation}, which
2417 appropriately sets the input-files to include the source file itself.
2419 @c FIXME: Add documentation of built-in operation types.
2421 @defun input-files operation component
2422 Return a list of pathnames that represent the input to @var{operation}
2423 performed on @var{component}.
2424 @end defun
2426 @item @code{operation-done-p}
2427 @findex operation-done-p
2428 You only need to define a method on that function
2429 if you can detect conditions that invalidate previous runs of the operation,
2430 even though no filesystem timestamp has changed,
2431 in which case you return @code{nil} (the default is @code{t}).
2433 For instance, the method for @code{test-op} always returns @code{nil},
2434 so that tests are always run afresh.
2435 Of course, the @code{test-op} for your system could depend
2436 on a deterministically repeatable @code{test-report-op},
2437 and just read the results from the report files,
2438 in which case you could have this method return @code{t}.
2440 @end itemize
2442 Operations that print output should send that output to the standard
2443 CL stream @code{*standard-output*}, as the Lisp compiler and loader do.
2445 @node Components, Dependencies, Operations, The object model of ASDF
2446 @comment  node-name,  next,  previous,  up
2447 @section Components
2448 @cindex component
2449 @cindex system
2450 @cindex system designator
2451 @cindex component designator
2452 @vindex *system-definition-search-functions*
2454 A @code{component} represents an individual source file or a group of source files,
2455 and the things that get transformed into.
2456 A @code{system} is a component at the top level of the component hierarchy,
2457 that can be found via @code{find-system}.
2458 A @code{source-file} is a component representing a single source-file
2459 and the successive output files into which it is transformed.
2460 A @code{module} is an intermediate component itself grouping several other components,
2461 themselves source-files or further modules.
2463 A @dfn{system designator} is a system itself,
2464 or a string or symbol that behaves just like any other component name
2465 (including with regard to the case conversion rules for component names).
2467 A @dfn{component designator}, relative to a base component,
2468 is either a component itself,
2469 or a string or symbol,
2470 or a list of designators.
2472 @defun find-system system-designator @Aoptional{} (error-p t)
2474 Given a system designator, @code{find-system} finds and returns a system.
2475 If no system is found, an error of type
2476 @code{missing-component} is thrown,
2477 or @code{nil} is returned if @code{error-p} is false.
2479 To find and update systems, @code{find-system} funcalls each element
2480 in the @code{*system-definition-search-functions*} list,
2481 expecting a pathname to be returned, or a system object,
2482 from which a pathname may be extracted, and that will be registered.
2483 The resulting pathname (if any) is loaded
2484 if one of the following conditions is true:
2486 @itemize
2487 @item
2488 there is no system of that name in memory
2489 @item
2490 the pathname is different from that which was previously loaded
2491 @item
2492 the file's @code{last-modified} time exceeds the @code{last-modified} time
2493 of the system in memory
2494 @end itemize
2496 @cindex ASDF-USER package
2497 When system definitions are loaded from @file{.asd} files,
2498 they are implicitly loaded into the @code{ASDF-USER} package,
2499 which uses @code{ASDF}, @code{UIOP} and @code{UIOP/COMMON-LISP}@footnote{
2500 Note that between releases 2.27 and 3.0.3, only @code{UIOP/PACKAGE},
2501 not all of @code{UIOP}, was used; if you want your code to work
2502 with releases earlier than 3.1.2, you may have to explicitly define a package
2503 that uses @code{UIOP}, or use proper package prefix to your symbols, as in
2504 @code{uiop:version<}.}
2505 Programmers who do anything non-trivial in a @file{.asd} file,
2506 such as defining new variables, functions or classes,
2507 should include @code{defpackage} and @code{in-package} forms in this file,
2508 so they will not overwrite each others' extensions.
2509 Such forms might also help the files behave identically
2510 if loaded manually with @code{cl:load} for development or debugging,
2511 though we recommend you use the function @code{asdf::load-asd} instead,
2512 which the @code{slime-asdf} contrib knows about.
2514 The default value of @code{*system-definition-search-functions*}
2515 is a list of three functions.
2516 The first function looks in each of the directories given
2517 by evaluating members of @code{*central-registry*}
2518 for a file whose name is the name of the system and whose type is @file{asd};
2519 the first such file is returned,
2520 whether or not it turns out to actually define the appropriate system.
2521 The second function does something similar,
2522 for the directories specified in the @code{source-registry},
2523 but searches the filesystem only once and caches its results.
2524 The third function makes the @code{package-inferred-system} extension work,
2525 @pxref{The package-inferred-system extension}.
2527 Because of the way these search functions are defined,
2528 you should put the definition for a system
2529 @var{foo} in a file named @file{foo.asd},
2530 in a directory that is
2531 in the central registry or
2532 which can be found using the
2533 source registry configuration.
2535 @c FIXME: Move this discussion to the system definition grammar, or somewhere else.
2536 @anchor{System names}
2537 @cindex System names
2538 @cindex Primary system name
2539 @findex primary-system-name
2540 It is often useful to define multiple systems in a same file,
2541 but ASDF can only locate a system's definition file based on the system
2542 name.
2543 For this reason,
2544 ASDF 3's system search algorithm has been extended to
2545 allow a file @file{foo.asd} to contain
2546 secondary systems named @var{foo/bar}, @var{foo/baz}, @var{foo/quux}, etc.,
2547 in addition to the primary system named @var{foo}.
2548 The first component of a system name,
2549 separated by the slash character, @code{/},
2550 is called the primary name of a system.
2551 The primary name may be
2552 extracted by function @code{asdf::primary-system-name};
2553 when ASDF 3 is told to find a system whose name has a slash,
2554 it will first attempt to load the corresponding primary system,
2555 and will thus see any such definitions, and/or any
2556 definition of a @code{package-inferred-system}.@footnote{
2557 ASDF 2.26 and earlier versions
2558 do not support this primary system name convention.
2559 With these versions of ASDF
2560 you must explicitly load @file{foo.asd}
2561 before you can use system @var{foo/bar} defined therein,
2562 e.g. using @code{(asdf:find-system "foo")}.
2563 We do not support ASDF 2, and recommend that you should upgrade to ASDF 3.
2565 If your file @file{foo.asd} also defines systems
2566 that do not follow this convention, e.g., a system named @var{foo-test},
2567 ASDF will not be able to automatically locate a definition for these systems,
2568 and will only see their definition
2569 if you explicitly find or load the primary system
2570 using e.g. @code{(asdf:find-system "foo")} before you try to use them.
2571 We strongly recommend against this practice,
2572 though it is currently supported for backward compatibility.
2574 @end defun
2576 @defun primary-system-name name
2578 Internal (not exported) function, @code{asdf::primary-system-name}.
2579 Returns the primary system name (the portion before
2580 the slash, @code{/}, in a secondary system name) from @var{name}.
2582 @end defun
2584 @defun locate-system name
2586 This function should typically @emph{not} be invoked directly.  It is
2587 exported as part of the API only for programmers who wish to provide
2588 their own @code{*system-definition-search-functions*}.
2590 Given a system @var{name} designator,
2591 try to locate where to load the system definition from.
2592 @c (This does not include the loading of the system definition,
2593 @c which is done by @code{find-system},
2594 @c or the loading of the system itself, which is done by @code{load-system};
2595 @c however, for systems the definition of which has already been loaded,
2596 @c @code{locate-system} may return an object of class @code{system}.)
2597 Returns five values: @var{foundp}, @var{found-system}, @var{pathname},
2598 @var{previous}, and @var{previous-time}.
2599 @var{foundp} is true when a system was found,
2600 either a new as yet unregistered one, or a previously registered one.
2601 The @var{found-system} return value
2602 will be a @code{system} object, if a system definition is found in your
2603 source registry.
2604 @c This system may be registered (by @code{register-system}) or may not, if
2605 @c it's preloaded code.  Fare writes:
2606 @c In the case of preloaded code, as for "asdf", "uiop", etc.,
2607 @c themselves, the system objects are not registered until after they are
2608 @c initially located by sysdef-preloaded-system-search as a fallback when
2609 @c no source code was found.
2610 The system definition will @emph{not} be
2611 loaded if it hasn't been loaded already.
2612 @var{pathname} when not null is a path from which to load the system,
2613 either associated with @var{found-system}, or with the @var{previous} system.
2614 If @var{previous} is not null, it will be a @emph{previously loaded}
2615 @code{system} object of the same name (note that the system
2616 @emph{definition} is previously-loaded: the system itself may or may not be).
2617 @var{previous-time} when not null is
2618 the timestamp of the previous system definition file, at the
2619 time when the @var{previous} system definition was loaded.
2621 For example, if your current registry has @file{foo.asd} in
2622 @file{/current/path/to/foo.asd},
2623 but system @code{foo} was previously loaded from @file{/previous/path/to/foo.asd}
2624 then @var{locate-system} will return the following values:
2625 @enumerate
2626 @item
2627 @var{foundp} will be @code{T},
2628 @item
2629 @var{found-system} will be @code{NIL},
2630 @item
2631 @var{pathname} will be @code{#p"/current/path/to/foo.asd"},
2632 @item
2633 @var{previous} will be an object of type @code{SYSTEM} with
2634 @code{system-source-file} slot value of
2635 @code{#p"/previous/path/to/foo.asd"}
2636 @item
2637 @var{previous-time} will be the timestamp of
2638 @code{#p"/previous/path/to/foo.asd"} at the time it was loaded.
2639 @end enumerate
2640 @end defun
2642 @defun find-component base path
2644 Given a @var{base} component (or designator for such),
2645 and a @var{path}, find the component designated by the @var{path}
2646 starting from the @var{base}.
2648 If @var{path} is a component object, it designates itself,
2649 independently from the base.
2651 @findex coerce-name
2652 If @var{path} is a string, or symbol denoting a string via @code{coerce-name},
2653 then @var{base} is resolved to a component object,
2654 which must be a system or module,
2655 and the designated component is the child named by the @var{path}.
2657 If @var{path} is a @code{cons} cell,
2658 @code{find-component} with the base and the @code{car} of the @var{path},
2659 and the resulting object is used as the base for a tail call
2660 to @code{find-component} with the @code{car} of the @var{path}.
2662 If @var{base} is a component object, it designates itself.
2664 If @var{base} is null, then @var{path} is used as the base, with @code{nil} as the path.
2666 If @var{base} is a string, or symbol denoting a string via @code{coerce-name},
2667 it designates a system as per @code{find-system}.
2669 If @var{base} is a @code{cons} cell, it designates the component found by
2670 @code{find-component} with its @code{car} as base and @code{cdr} as path.
2671 @end defun
2674 @menu
2675 * Common attributes of components::
2676 * Pre-defined subclasses of component::
2677 * Creating new component types::
2678 @end menu
2680 @node  Common attributes of components, Pre-defined subclasses of component, Components, Components
2681 @comment  node-name,  next,  previous,  up
2682 @subsection Common attributes of components
2684 All components, regardless of type, have the following attributes.
2685 All attributes except @code{name} are optional.
2687 @subsubsection Name
2688 @findex coerce-name
2689 A component name is a string or a symbol.
2690 If a symbol, its name is taken and lowercased.  This translation is
2691 performed by the exported function @code{coerce-name}.
2693 Unless overridden by a @code{:pathname} attribute,
2694 the name will be interpreted as a pathname specifier according
2695 to a Unix-style syntax.
2696 @xref{The defsystem grammar,,Pathname specifiers}.
2698 @subsubsection Version identifier
2699 @findex version-satisfies
2700 @cindex :version
2702 This optional attribute specifies a version for the current component.
2703 The version should typically be a string of integers separated by dots,
2704 for example @samp{1.0.11}.
2705 For more information on version specifiers, see @ref{The defsystem grammar}.
2707 A version may then be queried by the generic function @code{version-satisfies},
2708 to see if @code{:version} dependencies are satisfied,
2709 and when specifying dependencies, a constraint of minimal version to satisfy
2710 can be specified using e.g. @code{(:version "mydepname" "1.0.11")}.
2712 Note that in the wild, we typically see version numbering
2713 only on components of type @code{system}.
2714 Presumably it is much less useful within a given system,
2715 wherein the library author is responsible to keep the various files in synch.
2717 @subsubsection Required features
2718 @anchor{required-features}
2720 Traditionally defsystem users have used @code{#+} reader conditionals
2721 to include or exclude specific per-implementation files.
2722 For example, CFFI, the portable C foreign function interface contained
2723 lines like:
2724 @lisp
2725      #+sbcl       (:file "cffi-sbcl")
2726 @end lisp
2727 An unfortunate side effect of this approach is that no single
2728 implementation can read the entire system.
2729 This causes problems if, for example, one wished to design an @code{archive-op}
2730 that would create an archive file containing all the sources, since
2731 for example the file @code{cffi-sbcl.lisp} above would be invisible when
2732 running the @code{archive-op} on any implementation other than SBCL.
2734 Starting with ASDF 3,
2735 components may therefore have an @code{:if-feature} option.
2736 The value of this option should be
2737 a feature expression using the same syntax as @code{#+} does.
2738 If that feature expression evaluates to false, any reference to the component will be ignored
2739 during compilation, loading and/or linking.
2740 Since the expression is read by the normal reader,
2741 you must explicitly prefix your symbols with @code{:} so they be read as keywords;
2742 this is as contrasted with the @code{#+} syntax
2743 that implicitly reads symbols in the keyword package by default.
2745 For instance, @code{:if-feature (:and :x86 (:or :sbcl :cmu :scl))} specifies that
2746 the given component is only to be compiled and loaded
2747 when the implementation is SBCL, CMUCL or Scieneer CL on an x86 machine.
2748 You cannot write it as @code{:if-feature (and x86 (or sbcl cmu scl))}
2749 since the symbols would not be read as keywords.
2751 @xref{if-feature-option}.
2753 @subsubsection Dependencies
2755 This attribute specifies dependencies of the component on its siblings.
2756 It is optional but often necessary.
2758 There is an excitingly complicated relationship between the initarg
2759 and the method that you use to ask about dependencies
2761 Dependencies are between (operation component) pairs.
2762 In your initargs for the component, you can say
2764 @lisp
2765 :in-order-to ((compile-op (load-op "a" "b") (compile-op "c"))
2766               (load-op (load-op "foo")))
2767 @end lisp
2769 This means the following things:
2770 @itemize
2771 @item
2772 before performing compile-op on this component, we must perform
2773 load-op on @var{a} and @var{b}, and compile-op on @var{c},
2774 @item
2775 before performing @code{load-op}, we have to load @var{foo}
2776 @end itemize
2778 The syntax is approximately
2780 @verbatim
2781 (this-op @{(other-op required-components)@}+)
2783 simple-component-name := string
2784                       |  symbol
2786 required-components := simple-component-name
2787                      | (required-components required-components)
2789 component-name := simple-component-name
2790                 | (:version simple-component-name minimum-version-object)
2791 @end verbatim
2793 Side note:
2795 This is on a par with what ACL defsystem does.
2796 mk-defsystem is less general: it has an implied dependency
2798 @verbatim
2799   for all source file x, (load x) depends on (compile x)
2800 @end verbatim
2802 and using a @code{:depends-on} argument to say that @var{b} depends on
2803 @var{a} @emph{actually} means that
2805 @verbatim
2806   (compile b) depends on (load a)
2807 @end verbatim
2809 This is insufficient for e.g. the McCLIM system, which requires that
2810 all the files are loaded before any of them can be compiled ]
2812 End side note
2814 In ASDF, the dependency information for a given component and operation
2815 can be queried using @code{(component-depends-on operation component)},
2816 which returns a list
2818 @lisp
2819 ((load-op "a") (load-op "b") (compile-op "c") ...)
2820 @end lisp
2822 @code{component-depends-on} can be subclassed for more specific
2823 component/operation types: these need to @code{(call-next-method)}
2824 and append the answer to their dependency, unless
2825 they have a good reason for completely overriding the default dependencies.
2827 If it weren't for CLISP, we'd be using @code{LIST} method
2828 combination to do this transparently.
2829 But, we need to support CLISP.
2830 If you have the time for some CLISP hacking,
2831 I'm sure they'd welcome your fixes.
2832 @c Doesn't CLISP now support LIST method combination?
2834 A minimal version can be specified for a component you depend on
2835 (typically another system), by specifying @code{(:version "other-system" "1.2.3")}
2836 instead of simply @code{"other-system"} as the dependency.
2837 See the discussion of the semantics of @code{:version}
2838 in the defsystem grammar.
2840 @c FIXME: Should have cross-reference to "Version specifiers" in the
2841 @c defsystem grammar, but the cross-referencing is so broken by
2842 @c insufficient node breakdown that I have not put one in.
2845 @subsubsection pathname
2847 This attribute is optional and if absent (which is the usual case),
2848 the component name will be used.
2850 @xref{The defsystem grammar,,Pathname specifiers},
2851 for an explanation of how this attribute is interpreted.
2853 Note that the @code{defsystem} macro (used to create a ``top-level'' system)
2854 does additional processing to set the filesystem location of
2855 the top component in that system.
2856 This is detailed elsewhere. @xref{Defining systems with defsystem}.
2858 To find the CL pathname corresponding to a component, use
2860 @defun component-pathname component
2861 Returns the pathname corresponding to @var{component}.  For components
2862 such as source files, this will be a filename pathname.  For example:
2864 @lisp
2865 CL-USER> (asdf:component-pathname (asdf:find-system "xmls"))
2866 #P"/Users/rpg/lisp/xmls/"
2867 @end lisp
2871 @lisp
2872 CL-USER> (asdf:component-pathname
2873            (asdf:find-component
2874               (asdf:find-system "xmls") "xmls"))
2875 #P"/Users/rpg/lisp/xmls/xmls.lisp"
2876 @end lisp
2877 @end defun
2882 @subsubsection properties
2884 This attribute is optional.
2886 Packaging systems often require information about files or systems
2887 in addition to that specified by ASDF's pre-defined component attributes.
2888 Programs that create vendor packages out of ASDF systems therefore
2889 have to create ``placeholder'' information to satisfy these systems.
2890 Sometimes the creator of an ASDF system may know the additional
2891 information and wish to provide it directly.
2893 @code{(component-property component property-name)} and
2894 associated @code{setf} method will allow
2895 the programmatic update of this information.
2896 Property names are compared as if by @code{EQL},
2897 so use symbols or keywords or something.
2899 @menu
2900 * Pre-defined subclasses of component::
2901 * Creating new component types::
2902 @end menu
2904 @node Pre-defined subclasses of component, Creating new component types, Common attributes of components, Components
2905 @comment  node-name,  next,  previous,  up
2906 @subsection Pre-defined subclasses of component
2908 @deffn Component source-file
2910 A source file is any file that the system does not know how to
2911 generate from other components of the system.
2913 Note that this is not necessarily the same thing as
2914 ``a file containing data that is typically fed to a compiler''.
2915 If a file is generated by some pre-processor stage
2916 (e.g. a @file{.h} file from @file{.h.in} by autoconf)
2917 then it is not, by this definition, a source file.
2918 Conversely, we might have a graphic file
2919 that cannot be automatically regenerated,
2920 or a proprietary shared library that we received as a binary:
2921 these do count as source files for our purposes.
2923 Subclasses of source-file exist for various languages.
2924 @emph{FIXME: describe these.}
2925 @end deffn
2927 @deffn Component module
2929 A module is a collection of sub-components.
2931 A module component has the following extra initargs:
2933 @itemize
2934 @item
2935 @code{:components} the components contained in this module
2937 @item
2938 @code{:default-component-class}
2939 All children components which don't specify their class explicitly
2940 are inferred to be of this type.
2942 @item
2943 @code{:if-component-dep-fails}
2944 This attribute was removed in ASDF 3. Do not use it.
2945 Use @code{:if-feature} instead (@pxref{required-features}, and @pxref{if-feature-option}).
2947 @item
2948 @code{:serial} When this attribute is set,
2949 each subcomponent of this component is assumed to depend on all subcomponents
2950 before it in the list given to @code{:components}, i.e.
2951 all of them are loaded before a compile or load operation is performed on it.
2953 @end itemize
2955 The default operation knows how to traverse a module, so
2956 most operations will not need to provide methods specialised on modules.
2958 @code{module} may be subclassed to represent components such as
2959 foreign-language linked libraries or archive files.
2960 @end deffn
2962 @deffn Component system
2964 @code{system} is a subclass of @code{module}.
2966 A system is a module with a few extra attributes for documentation
2967 purposes; these are given elsewhere.
2968 @xref{The defsystem grammar}.
2970 Users can create new classes for their systems:
2971 the default @code{defsystem} macro takes a @code{:class} keyword argument.
2972 @end deffn
2974 @node  Creating new component types,  , Pre-defined subclasses of component, Components
2975 @comment  node-name,  next,  previous,  up
2976 @subsection Creating new component types
2978 New component types are defined by subclassing one of the existing
2979 component classes and specializing methods on the new component class.
2981 @c FIXME: this should perhaps be explained more throughly,
2982 @c not only by example ...
2984 As an example, suppose we have some implementation-dependent
2985 functionality that we want to isolate
2986 in one subdirectory per Lisp implementation our system supports.
2987 We create a subclass of
2988 @code{cl-source-file}:
2990 @lisp
2991 (defclass unportable-cl-source-file (cl-source-file)
2992   ())
2993 @end lisp
2995 Function @code{asdf:implementation-type} (exported since 2.014.14)
2996 gives us the name of the subdirectory.
2997 All that's left is to define how to calculate the pathname
2998 of an @code{unportable-cl-source-file}.
3000 @lisp
3001 (defmethod component-pathname ((component unportable-cl-source-file))
3002   (merge-pathnames*
3003    (parse-unix-namestring (format nil "~(~A~)/" (asdf:implementation-type)))
3004    (call-next-method)))
3005 @end lisp
3007 The new component type is used in a @code{defsystem} form in this way:
3009 @lisp
3010 (defsystem :foo
3011     :components
3012     ((:file "packages")
3013      ...
3014      (:unportable-cl-source-file "threads"
3015       :depends-on ("packages" ...))
3016      ...
3017     )
3018 @end lisp
3020 @node Dependencies, Functions, Components, The object model of ASDF
3021 @section Dependencies
3022 @c FIXME: Moved this material here, but it isn't very comfortable
3023 @c here....  Also needs to be revised to be coherent.
3025 To be successfully build-able, this graph of actions must be acyclic.
3026 If, as a user, extender or implementer of ASDF, you introduce
3027 a cycle into the dependency graph,
3028 ASDF will fail loudly.
3029 To clearly distinguish the direction of dependencies,
3030 ASDF 3 uses the words @emph{requiring} and @emph{required}
3031 as applied to an action depending on the other:
3032 the requiring action @code{depends-on} the completion of all required actions
3033 before it may itself be @code{perform}ed.
3035 Using the @code{defsystem} syntax, users may easily express
3036 direct dependencies along the graph of the object hierarchy:
3037 between a component and its parent, its children, and its siblings.
3038 By defining custom CLOS methods, you can express more elaborate dependencies as you wish.
3039 Most common operations, such as @code{load-op}, @code{compile-op} or @code{load-source-op}
3040 are automatically propagate ``downward'' the component hierarchy and are ``covariant'' with it:
3041 to act the operation on the parent module, you must first act it on all the children components,
3042 with the action on the parent being parent of the action on each child.
3043 Other operations, such as @code{prepare-op} and @code{prepare-source-op}
3044 (introduced in ASDF 3) are automatically propagated ``upward'' the component hierarchy
3045 and are ``contravariant'' with it:
3046 to perform the operation of preparing for compilation of a child component,
3047 you must perform the operation of preparing for compilation of its parent component, and so on,
3048 ensuring that all the parent's dependencies are (compiled and) loaded
3049 before the child component may be compiled and loaded.
3050 Yet other operations, such as @code{test-op} or @code{load-bundle-op}
3051 remain at the system level, and are not propagated along the hierarchy,
3052 but instead do something global on the system.
3055 @node Functions,  , Dependencies, The object model of ASDF
3056 @comment  node-name,  next,  previous,  up
3057 @section Functions
3059 @c FIXME: this does not belong here....
3060 @defun version-satisfies @var{version} @var{version-spec}
3061 Does @var{version} satisfy the @var{version-spec}.  A generic function.
3062 ASDF provides built-in methods for @var{version} being a @code{component} or @code{string}.
3063 @var{version-spec} should be a string.
3064 If it's a component, its version is extracted as a string before further processing.
3066 A version string satisfies the version-spec if after parsing,
3067 the former is no older than the latter.
3068 Therefore @code{"1.9.1"}, @code{"1.9.2"} and @code{"1.10"} all satisfy @code{"1.9.1"},
3069 but @code{"1.8.4"} or @code{"1.9"} do not.
3070 For more information about how @code{version-satisfies} parses and interprets
3071 version strings and specifications,
3072 @pxref{The defsystem grammar} (version specifiers) and
3073 @ref{Common attributes of components}.
3075 Note that in versions of ASDF prior to 3.0.1,
3076 including the entire ASDF 1 and ASDF 2 series,
3077 @code{version-satisfies} would also require that the version and the version-spec
3078 have the same major version number (the first integer in the list);
3079 if the major version differed, the version would be considered as not matching the spec.
3080 But that feature was not documented, therefore presumably not relied upon,
3081 whereas it was a nuisance to several users.
3082 Starting with ASDF 3.0.1,
3083 @code{version-satisfies} does not treat the major version number specially,
3084 and returns T simply if the first argument designates a version that isn't older
3085 than the one specified as a second argument.
3086 If needs be, the @code{(:version ...)} syntax for specifying dependencies
3087 could be in the future extended to specify an exclusive upper bound for compatible versions
3088 as well as an inclusive lower bound.
3089 @end defun
3091 @node Controlling where ASDF searches for systems, Controlling where ASDF saves compiled files, The object model of ASDF, Top
3092 @comment  node-name,  next,  previous,  up
3093 @chapter Controlling where ASDF searches for systems
3097 @menu
3098 * Configurations::
3099 * Truenames and other dangers::
3100 * XDG base directory::
3101 * Backward Compatibility::
3102 * Configuration DSL::
3103 * Configuration Directories::
3104 * Shell-friendly syntax for configuration::
3105 * Search Algorithm::
3106 * Caching Results::
3107 * Configuration API::
3108 * Introspection::
3109 * Status::
3110 * Rejected ideas::
3111 * TODO::
3112 * Credits for the source-registry::
3113 @end menu
3115 @node  Configurations, Truenames and other dangers, Controlling where ASDF searches for systems, Controlling where ASDF searches for systems
3116 @section Configurations
3118 Configurations specify paths where to find system files.
3120 @enumerate
3122 @item
3123 The search registry may use some hardcoded wrapping registry specification.
3124 This allows some implementations (notably SBCL) to specify where to find
3125 some special implementation-provided systems that
3126 need to precisely match the version of the implementation itself.
3128 @item
3129 An application may explicitly initialize the source-registry configuration
3130 using the configuration API
3131 (@pxref{Controlling where ASDF searches for systems,Configuration API,Configuration API}, below)
3132 in which case this takes precedence.
3133 It may itself compute this configuration from the command-line,
3134 from a script, from its own configuration file, etc.
3136 @item
3137 The source registry will be configured from
3138 the environment variable @code{CL_SOURCE_REGISTRY} if it exists.
3140 @item
3141 The source registry will be configured from
3142 user configuration file
3143 @file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf}
3144 (which defaults to
3145 @file{~/.config/common-lisp/source-registry.conf})
3146 if it exists.
3148 @item
3149 The source registry will be configured from
3150 user configuration directory
3151 @file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf.d/}
3152 (which defaults to
3153 @file{~/.config/common-lisp/source-registry.conf.d/})
3154 if it exists.
3156 @item
3157 The source registry will be configured from
3158 default user configuration trees
3159 @file{~/common-lisp/} (since ASDF 3.1.2 only),
3160 @file{~/.sbcl/systems/} (on SBCL only),
3161 @file{$XDG_DATA_HOME/common-lisp/systems/} (no recursion, link farm)
3162 @file{$XDG_DATA_HOME/common-lisp/source/}.
3163 The @code{XDG_DATA_HOME} directory defaults to @file{~/.local/share/}.
3164 On Windows, the @code{local-appdata} and @code{appdata} directories are used instead.
3166 @item
3167 The source registry will be configured from
3168 system configuration file
3169 @file{/etc/common-lisp/source-registry.conf}
3170 if it exists.
3172 @item
3173 The source registry will be configured from
3174 system configuration directory
3175 @file{/etc/common-lisp/source-registry.conf.d/}
3176 if it exists.
3178 @item
3179 The source registry will be configured from a default configuration.
3180 This configuration may allow for implementation-specific systems
3181 to be found, for systems to be found the current directory
3182 (at the time that the configuration is initialized) as well as
3183 @code{:directory} entries for @file{$XDG_DATA_DIRS/common-lisp/systems/} and
3184 @code{:tree} entries for @file{$XDG_DATA_DIRS/common-lisp/source/},
3185 where @code{XDG_DATA_DIRS} defaults to @file{/usr/local/share} and @file{/usr/share} on Unix,
3186 and the @code{common-appdata} directory on Windows.
3188 @item
3189 The source registry may include implementation-dependent directories
3190 that correspond to implementation-provided extensions.
3192 @end enumerate
3194 Each of these configurations is specified as an s-expression
3195 in a trivial domain-specific language (defined below).
3196 Additionally, a more shell-friendly syntax is available
3197 for the environment variable (defined yet below).
3199 Each of these configurations is only used if the previous
3200 configuration explicitly or implicitly specifies that it
3201 includes its inherited configuration.
3203 Additionally, some implementation-specific directories
3204 may be automatically prepended to whatever directories are specified
3205 in configuration files, no matter if the last one inherits or not.
3207 @node Truenames and other dangers, XDG base directory, Configurations, Controlling where ASDF searches for systems
3208 @section Truenames and other dangers
3210 One great innovation of the original ASDF was its ability to leverage
3211 @code{CL:TRUENAME} to locate where your source code was and where to build it,
3212 allowing for symlink farms as a simple but effective configuration mechanism
3213 that is easy to control programmatically.
3214 ASDF 3 still supports this configuration style, and it is enabled by default;
3215 however we recommend you instead use
3216 our source-registry configuration mechanism described below,
3217 because it is easier to setup in a portable way across users and implementations.
3219 Additionally, some people dislike truename,
3220 either because it is very slow on their system, or
3221 because they are using content-addressed storage where the truename of a file
3222 is related to a digest of its individual contents,
3223 and not to other files in the same intended project.
3224 For these people, ASDF 3 allows to eschew the @code{TRUENAME} mechanism,
3225 by setting the variable @var{asdf:*resolve-symlinks*} to @code{nil}.
3227 PS: Yes, if you haven't read Vernor Vinge's short but great classic
3228 ``True Names... and Other Dangers'' then you're in for a treat.
3230 @node XDG base directory, Backward Compatibility, Truenames and other dangers, Controlling where ASDF searches for systems
3231 @section XDG base directory
3233 Note that we purport to respect the XDG base directory specification
3234 as to where configuration files are located,
3235 where data files are located,
3236 where output file caches are located.
3237 Mentions of XDG variables refer to that document.
3239 @url{http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html}
3241 This specification allows the user to specify some environment variables
3242 to customize how applications behave to his preferences.
3244 On Windows platforms, even when not using Cygwin, and starting with ASDF 3.1.5,
3245 we still do a best effort at following the XDG base directory specification,
3246 even though it doesn't exactly fit common practice for Windows applications.
3247 However, we replace the fixed Unix paths @file{~/.local}, @file{/usr/local} and @file{/usr}
3248 with their rough Windows equivalent @file{Local AppData}, @file{AppData}, @file{Common AppData}, etc.
3249 Since support for querying the Windows registry
3250 is not possible to do in reasonable amounts of portable Common Lisp code,
3251 ASDF 3 relies on the environment variables that Windows usually exports,
3252 and are hopefully in synch with the Windows registry.
3253 If you care about the details, see @file{uiop/configuration.lisp} and don't hesitate to suggest improvements.
3255 @node Backward Compatibility, Configuration DSL, XDG base directory, Controlling where ASDF searches for systems
3256 @section Backward Compatibility
3258 For backward compatibility as well as to provide a practical backdoor for hackers,
3259 ASDF will first search for @file{.asd} files in the directories specified in
3260 @code{asdf:*central-registry*}
3261 before it searches in the source registry above.
3263 @xref{Configuring ASDF,,Configuring ASDF to find your systems --- old style}.
3265 By default, @code{asdf:*central-registry*} will be empty.
3267 This old mechanism will therefore not affect you if you don't use it,
3268 but will take precedence over the new mechanism if you do use it.
3270 @node Configuration DSL, Configuration Directories, Backward Compatibility, Controlling where ASDF searches for systems
3271 @section Configuration DSL
3272 @cindex :inherit-configuration source config directive
3273 @cindex inherit-configuration source config directive
3274 @cindex :ignore-invalid-entries source config directive
3275 @cindex ignore-invalid-entries source config directive
3276 @cindex :directory source config directive
3277 @cindex directory source config directive
3278 @cindex :tree source config directive
3279 @cindex tree source config directive
3280 @cindex :exclude source config directive
3281 @cindex exclude source config directive
3282 @cindex :also-exclude source config directive
3283 @cindex also-exclude source config directive
3284 @cindex :include source config directive
3285 @cindex include source config directive
3286 @cindex :default-registry source config directive
3287 @cindex default-registry source config directive
3289 Here is the grammar of the s-expression (SEXP) DSL for source-registry
3290 configuration:
3292 @c FIXME: This is too wide for happy compilation into pdf.
3294 @example
3295 ;; A configuration is a single SEXP starting with the keyword
3296 ;; :source-registry followed by a list of directives.
3297 CONFIGURATION := (:source-registry DIRECTIVE ...)
3299 ;; A directive is one of the following:
3300 DIRECTIVE :=
3301     ;; INHERITANCE DIRECTIVE:
3302     ;; Your configuration expression MUST contain
3303     ;; exactly one of the following:
3304     :inherit-configuration |
3305     ;; splices inherited configuration (often specified last) or
3306     :ignore-inherited-configuration |
3307     ;; drop inherited configuration (specified anywhere)
3309     ;; forward compatibility directive (since ASDF 2.011.4), useful when
3310     ;; you want to use new configuration features but have to bootstrap
3311     ;; the newer required ASDF from an older release that doesn't
3312     ;; support said features:
3313     :ignore-invalid-entries |
3315     ;; add a single directory to be scanned (no recursion)
3316     (:directory DIRECTORY-PATHNAME-DESIGNATOR) |
3318     ;; add a directory hierarchy, recursing but
3319     ;; excluding specified patterns
3320     (:tree DIRECTORY-PATHNAME-DESIGNATOR) |
3322     ;; override the defaults for exclusion patterns
3323     (:exclude EXCLUSION-PATTERN ...) |
3324     ;; augment the defaults for exclusion patterns
3325     (:also-exclude EXCLUSION-PATTERN ...) |
3326     ;; Note that the scope of a an exclude pattern specification is
3327     ;; the rest of the current configuration expression or file.
3329     ;; splice the parsed contents of another config file
3330     (:include REGULAR-FILE-PATHNAME-DESIGNATOR) |
3332     ;; This directive specifies that some default must be spliced.
3333     :default-registry
3335 REGULAR-FILE-PATHNAME-DESIGNATOR
3336     := PATHNAME-DESIGNATOR ; interpreted as a file
3337 DIRECTORY-PATHNAME-DESIGNATOR
3338     := PATHNAME-DESIGNATOR ; interpreted as a directory
3340 PATHNAME-DESIGNATOR :=
3341     NIL | ;; Special: skip this entry.
3342     ABSOLUTE-COMPONENT-DESIGNATOR ;; see pathname DSL
3344 EXCLUSION-PATTERN := a string without wildcards, that will be matched
3345     exactly against the name of a any subdirectory in the directory
3346     component of a path. e.g. @code{"_darcs"} will match
3347     @file{#p"/foo/bar/_darcs/src/bar.asd"}
3348 @end example
3350 Pathnames are designated using another DSL,
3351 shared with the output-translations configuration DSL below.
3352 The DSL is resolved by the function @code{asdf::resolve-location},
3353 to be documented and exported at some point in the future.
3355 @example
3356 ABSOLUTE-COMPONENT-DESIGNATOR :=
3357     (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...) |
3358     STRING |
3359     ;; namestring (better be absolute or bust, directory assumed where
3360     ;; applicable).  In output-translations, directory is assumed and
3361     ;; **/*.*.* added if it's last.  On MCL, a MacOSX-style POSIX
3362     ;; namestring (for MacOS9 style, use #p"..."); Note that none of the
3363     ;; above applies to strings used in *central-registry*, which
3364     ;; doesn't use this DSL: they are processed as normal namestrings.
3365     ;; however, you can compute what you put in the *central-registry*
3366     ;; based on the results of say
3367     ;; (asdf::resolve-location "/Users/fare/cl/cl-foo/")
3368     PATHNAME |
3369     ;; pathname (better be an absolute path, or bust)
3370     ;; In output-translations, unless followed by relative components,
3371     ;; it better have appropriate wildcards, as in **/*.*.*
3372     :HOME | ; designates the user-homedir-pathname ~/
3373     :USER-CACHE | ; designates the default location for the user cache
3374     :HERE |
3375     ;; designates the location of the configuration file
3376     ;; (or *default-pathname-defaults*, if invoked interactively)
3377     :ROOT
3378     ;; magic, for output-translations source only: paths that are relative
3379     ;; to the root of the source host and device
3381 They keyword :SYSTEM-CACHE is not accepted in ASDF 3.1 and beyond: it
3382 was a security hazard.
3384 RELATIVE-COMPONENT-DESIGNATOR :=
3385     (RELATIVE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...) |
3386     STRING |
3387       ;; relative directory pathname as interpreted by
3388       ;; parse-unix-namestring.
3389       ;; In output translations, if last component, **/*.*.* is added
3390     PATHNAME | ; pathname; unless last component, directory is assumed.
3391     :IMPLEMENTATION |
3392        ;; directory based on implementation, e.g. sbcl-1.0.45-linux-x64
3393     :IMPLEMENTATION-TYPE |
3394        ;; a directory based on lisp-implementation-type only, e.g. sbcl
3395     :DEFAULT-DIRECTORY |
3396        ;; a relativized version of the default directory
3397     :*/ | ;; any direct subdirectory (since ASDF 2.011.4)
3398     :**/ | ;; any recursively inferior subdirectory (since ASDF 2.011.4)
3399     :*.*.* | ;; any file (since ASDF 2.011.4)
3401 The keywords :UID and :USERNAME are no longer supported.
3402 @end example
3404 For instance, as a simple case, my @file{~/.config/common-lisp/source-registry.conf},
3405 which is the default place ASDF looks for this configuration, once contained:
3406 @example
3407 (:source-registry
3408   (:tree (:home "cl")) ;; will expand to e.g. "/home/joeluser/cl/"
3409   :inherit-configuration)
3410 @end example
3412 @node Configuration Directories, Shell-friendly syntax for configuration, Configuration DSL, Controlling where ASDF searches for systems
3413 @section Configuration Directories
3415 Configuration directories consist in files each containing
3416 a list of directives without any enclosing @code{(:source-registry ...)} form.
3417 The files will be sorted by namestring as if by @code{string<} and
3418 the lists of directives of these files with be concatenated in order.
3419 An implicit @code{:inherit-configuration} will be included
3420 at the @emph{end} of the list.
3422 System-wide or per-user Common Lisp software distributions
3423 such as Debian packages or some future version of @code{clbuild}
3424 may then include files such as
3425 @file{/etc/common-lisp/source-registry.conf.d/10-foo.conf} or
3426 @file{~/.config/common-lisp/source-registry.conf.d/10-foo.conf}
3427 to easily and modularly register configuration information
3428 about software being distributed.
3430 The convention is that, for sorting purposes,
3431 the names of files in such a directory begin with two digits
3432 that determine the order in which these entries will be read.
3433 Also, the type of these files must be @file{.conf},
3434 which not only simplifies the implementation by allowing
3435 for more portable techniques in finding those files,
3436 but also makes it trivial to disable a file, by renaming it to a different file type.
3438 Directories may be included by specifying a directory pathname
3439 or namestring in an @code{:include} directive, e.g.:
3441 @example
3442         (:include "/foo/bar/")
3443 @end example
3445 Hence, to achieve the same effect as
3446 my example @file{~/.config/common-lisp/source-registry.conf} above,
3447 I could simply create a file
3448 @file{~/.config/common-lisp/source-registry.conf.d/33-home-fare-cl.conf}
3449 alone in its directory with the following contents:
3450 @example
3451 (:tree "/home/fare/cl/")
3452 @end example
3454 @menu
3455 * The here directive::
3456 @end menu
3458 @node The here directive,  , Configuration Directories, Configuration Directories
3459 @subsection The :here directive
3461 The @code{:here} directive is an absolute pathname designator that
3462 refers to the directory containing the configuration file currently
3463 being processed.
3465 The @code{:here} directive is intended to simplify the delivery of
3466 complex CL systems, and for easy configuration of projects shared through
3467 revision control systems, in accordance with our design principle that
3468 each participant should be able to provide all and only the information
3469 available to him or her.
3471 Consider a person X who has set up the source code repository for a
3472 complex project with a master directory @file{dir/}.  Ordinarily, one
3473 might simply have the user add a directive that would look something
3474 like this:
3475 @example
3476    (:tree "path/to/dir")
3477 @end example
3478 But what if X knows that there are very large subtrees
3479 under dir that are filled with, e.g., Java source code, image files for
3480 icons, etc.?  All of the asdf system definitions are contained in the
3481 subdirectories @file{dir/src/lisp/} and @file{dir/extlib/lisp/}, and
3482 these are the only directories that should be searched.
3484 In this case, X can put into @file{dir/} a file @file{asdf.conf} that
3485 contains the following:
3486 @example
3487 (:source-registry
3488    (:tree (:here "src/lisp/"))
3489    (:tree (:here "extlib/lisp"))
3490    (:directory (:here "outlier/")))
3491 @end example
3493 Then when someone else (call her Y) checks out a copy of this
3494 repository, she need only add
3495 @example
3496 (:include "/path/to/my/checkout/directory/asdf.conf")
3497 @end example
3498 to one of her previously-existing asdf source location configuration
3499 files, or invoke @code{initialize-source-registry} with a configuration
3500 form containing that s-expression.  ASDF will find the .conf file that X
3501 has provided, and then set up source locations within the working
3502 directory according to X's (relative) instructions.
3504 @node Shell-friendly syntax for configuration, Search Algorithm, Configuration Directories, Controlling where ASDF searches for systems
3505 @section Shell-friendly syntax for configuration
3507 When considering environment variable @code{CL_SOURCE_REGISTRY}
3508 ASDF will skip to next configuration if it's an empty string.
3509 It will @code{READ} the string as a SEXP in the DSL
3510 if it begins with a paren @code{(},
3511 otherwise it will be interpreted much like @code{TEXINPUTS},
3512 as a list of paths, where
3514   * paths are separated
3515    by a @code{:} (colon) on Unix platforms (including cygwin),
3516    by a @code{;} (semicolon) on other platforms (mainly, Windows).
3518   * each entry is a directory to add to the search path.
3520   * if the entry ends with a double slash @code{//}
3521     then it instead indicates a tree in the subdirectories
3522     of which to recurse.
3524   * if the entry is the empty string (which may only appear once),
3525     then it indicates that the inherited configuration should be
3526     spliced there.
3528 @node Search Algorithm, Caching Results, Shell-friendly syntax for configuration, Controlling where ASDF searches for systems
3529 @section Search Algorithm
3530 @vindex *default-source-registry-exclusions*
3532 In case that isn't clear, the semantics of the configuration is that
3533 when searching for a system of a given name,
3534 directives are processed in order.
3536 When looking in a directory, if the system is found, the search succeeds,
3537 otherwise it continues.
3539 When looking in a tree, if one system is found, the search succeeds.
3540 If multiple systems are found, the consequences are unspecified:
3541 the search may succeed with any of the found systems,
3542 or an error may be raised.
3543 ASDF currently returns the first system found,
3544 XCVB currently raised an error.
3545 If none is found, the search continues.
3547 Exclude statements specify patterns of subdirectories
3548 the systems from which to ignore.
3549 Typically you don't want to use copies of files kept by such
3550 version control systems as Darcs.
3551 Exclude statements are not propagated to further included or inherited
3552 configuration files or expressions;
3553 instead the defaults are reset around every configuration statement
3554 to the default defaults from @code{asdf::*default-source-registry-exclusions*}.
3556 Include statements cause the search to recurse with the path specifications
3557 from the file specified.
3559 An inherit-configuration statement cause the search to recurse with the path
3560 specifications from the next configuration
3561 (@pxref{Configurations} above).
3564 @node Caching Results, Configuration API, Search Algorithm, Controlling where ASDF searches for systems
3565 @section Caching Results
3567 The implementation is allowed to either eagerly compute the information
3568 from the configurations and file system, or to lazily re-compute it
3569 every time, or to cache any part of it as it goes.
3570 In practice, the recommended @code{source-registry} eagerly collects and caches results
3571 and you need to explicitly flush the cache for change to be taken into account,
3572 whereas the old-style @code{*central-registry*} mechanism queries the filesystem every time.
3574 To explicitly flush any information cached by the system
3575 after a change was made in the filesystem, @xref{Configuration API},
3576 and e.g. call @code{asdf:clear-source-registry}.
3578 Starting with ASDF 3.1.4, you can also explicitly build a persistent cache
3579 of the @file{.asd} files found under a tree:
3580 when recursing into a directory declared by @code{:tree} and its transitive subdirectories,
3581 if a file @file{.cl-source-registry.cache} exists containing a form
3582 that is a list starting with @code{:source-registry-cache} followed by a list of strings,
3583 as in @code{(:source-registry-cache @emph{"foo/bar.asd" "path/to/more.asd" ...})},
3584 then the strings are assumed to be @code{unix-namestring}s designating
3585 the available asd files under that tree, and the recursion otherwise stops.
3586 The list can also be empty, allowing to stop a costly recursion in a huge directory tree.
3588 To update such a cache after you install, update or remove source repositories,
3589 you can run a script distributed with ASDF:
3590 @code{tools/cl-source-registry-cache.lisp @emph{/path/to/directory}}.
3591 To wholly invalidate the cache, you can
3592 delete the file @file{.cl-source-registry.cache} in that directory.
3593 In either case, for an existing Lisp process to see this change,
3594 it needs to clear its own cache with e.g. @code{(asdf:clear-source-registry)}.
3596 Developers may safely create a cache in their development tree,
3597 and we recommend they do it at the top of their source tree if
3598 it contains more than a small number of files and directories;
3599 they only need update it when they create, remove or move @file{.asd} files.
3600 Software distribution managers may also safely create such a cache,
3601 but they must be careful to update it every time they install, update or remove
3602 a software source repository or installation package.
3603 Finally, advanced developers who juggle with a lot of code
3604 in their @code{source-registry} may manually manage such a cache,
3605 to allow for faster startup of Lisp programs.
3607 This persistence cache can help you reduce startup latency.
3608 For instance, on one machine with hundreds of source repositories,
3609 such a cache shaves half a second at the startup
3610 of every @code{#!/usr/bin/cl} script using SBCL, more on other implementations;
3611 this makes a notable difference as to
3612 their subjective interactivity and usability.
3613 The speedup will only happen if the implementation-provided ASDF is recent enough
3614 (3.1.3.7 or later); it is not enough for a recent ASDF upgrade to be present,
3615 since the upgrade will itself be found but
3616 after the old version has scanned the directories without heeding such a cache.
3617 To upgrade the implementation-provided ASDF,
3618 use our script @code{tools/install-asdf.lisp}.
3621 @node Configuration API, Introspection, Caching Results, Controlling where ASDF searches for systems
3622 @section Configuration API
3624 The specified functions are exported from your build system's package.
3625 Thus for ASDF the corresponding functions are in package ASDF,
3626 and for XCVB the corresponding functions are in package XCVB.
3628 @defun initialize-source-registry @Aoptional{} PARAMETER
3629    will read the configuration and initialize all internal variables.
3630    You may extend or override configuration
3631    from the environment and configuration files
3632    with the given @var{PARAMETER}, which can be
3633    @code{nil} (no configuration override),
3634    or a SEXP (in the SEXP DSL),
3635    a string (as in the string DSL),
3636    a pathname (of a file or directory with configuration),
3637    or a symbol (fbound to function that when called returns one of the above).
3638 @end defun
3640 @defun clear-source-registry
3641    undoes any source registry configuration
3642    and clears any cache for the search algorithm.
3643    You might want to call this function
3644    (or better, @code{clear-configuration})
3645    before you dump an image that would be resumed
3646    with a different configuration,
3647    and return an empty configuration.
3648    Note that this does not include clearing information about
3649    systems defined in the current image, only about
3650    where to look for systems not yet defined.
3651 @end defun
3653 @defun ensure-source-registry @Aoptional{} PARAMETER
3654    checks whether a source registry has been initialized.
3655    If not, initialize it with the given @var{PARAMETER}.
3656 @end defun
3658 Every time you use ASDF's @code{find-system}, or
3659 anything that uses it (such as @code{operate}, @code{load-system}, etc.),
3660 @code{ensure-source-registry} is called with parameter @code{nil},
3661 which the first time around causes your configuration to be read.
3662 If you change a configuration file,
3663 you need to explicitly @code{initialize-source-registry} again,
3664 or maybe simply to @code{clear-source-registry} (or @code{clear-configuration})
3665 which will cause the initialization to happen next time around.
3667 @node Introspection, Status, Configuration API, Controlling where ASDF searches for systems
3668 @section Introspection
3670 @menu
3671 * *source-registry-parameter* variable::
3672 * Information about system dependencies::
3673 @end menu
3675 @node *source-registry-parameter* variable, Information about system dependencies, Introspection, Introspection
3676 @subsection *source-registry-parameter* variable
3677 @vindex *source-registry-parameter*
3679 We have made available the variable @code{*source-registry-parameter*}
3680 that can be used by code that wishes to introspect about the (past)
3681 configuration of ASDF's source registry.  @strong{This variable should
3682 never be set!}  It will be set as a side-effect of calling
3683 @code{initialize-source-registry}; user code should treat it as
3684 read-only.
3686 @node Information about system dependencies,  , *source-registry-parameter* variable, Introspection
3687 @subsection Information about system dependencies
3689 ASDF makes available three functions to read system interdependencies.
3690 These are intended to aid programmers who wish to perform dependency
3691 analyses.
3693 @defun system-defsystem-depends-on system
3694 @end defun
3696 @defun system-depends-on system
3697 @end defun
3699 @defun system-weakly-depends-on system
3700 Returns a list of names of systems that are weakly depended on by
3701 @var{system}.  Weakly depended on systems are optionally loaded only if
3702 ASDF can find them; failure to find such systems does @emph{not} cause an
3703 error in loading.
3705 Note that the return value for @code{system-weakly-depends-on} is simpler
3706 than the return values of the other two system dependency introspection
3707 functions.
3708 @end defun
3710 @node Status, Rejected ideas, Introspection, Controlling where ASDF searches for systems
3711 @section Status
3713 This mechanism is vastly successful, and we have declared
3714 that @code{asdf:*central-registry*} is not recommended anymore,
3715 though we will continue to support it.
3716 All hooks into implementation-specific search mechanisms
3717 have been integrated in the @code{wrapping-source-registry}
3718 that everyone uses implicitly.
3720 @node Rejected ideas, TODO, Status, Controlling where ASDF searches for systems
3721 @section Rejected ideas
3723 Alternatives I (FRR) considered and rejected while developing ASDF 2 included:
3725 @enumerate
3726 @item Keep @code{asdf:*central-registry*} as the master with its current semantics,
3727    and somehow the configuration parser expands the new configuration
3728    language into a expanded series of directories of subdirectories to
3729    lookup, pre-recursing through specified hierarchies. This is kludgy,
3730    and leaves little space of future cleanups and extensions.
3732 @item Keep @code{asdf:*central-registry*} as the master but extend its semantics
3733    in completely new ways, so that new kinds of entries may be implemented
3734    as a recursive search, etc. This seems somewhat backwards.
3736 @item Completely remove @code{asdf:*central-registry*}
3737    and break backwards compatibility.
3738    Hopefully this will happen in a few years after everyone migrate to
3739    a better ASDF and/or to XCVB, but it would be very bad to do it now.
3741 @item Replace @code{asdf:*central-registry*} by a symbol-macro with appropriate magic
3742    when you dereference it or setf it. Only the new variable with new
3743    semantics is handled by the new search procedure.
3744    Complex and still introduces subtle semantic issues.
3745 @end enumerate
3748 I've been suggested the below features, but have rejected them,
3749 for the sake of keeping ASDF no more complex than strictly necessary.
3751 @itemize
3752 @item
3753   More syntactic sugar: synonyms for the configuration directives, such as
3754   @code{(:add-directory X)} for @code{(:directory X)}, or @code{(:add-directory-hierarchy X)}
3755   or @code{(:add-directory X :recurse t)} for @code{(:tree X)}.
3757 @item
3758   The possibility to register individual files instead of directories.
3760 @item
3761   Integrate Xach Beane's tilde expander into the parser,
3762   or something similar that is shell-friendly or shell-compatible.
3763   I'd rather keep ASDF minimal. But maybe this precisely keeps it
3764   minimal by removing the need for evaluated entries that ASDF has?
3765   i.e. uses of @code{USER-HOMEDIR-PATHNAME} and @code{$SBCL_HOME}
3766   Hopefully, these are already superseded by the @code{:default-registry}
3768 @item
3769   Using the shell-unfriendly syntax @code{/**} instead of TEXINPUTS-like @code{//} to specify recursion
3770   down a filesystem tree in the environment variable.
3771   It isn't that Lisp friendly either.
3772 @end itemize
3774 @node TODO, Credits for the source-registry, Rejected ideas, Controlling where ASDF searches for systems
3775 @section TODO
3777 @itemize
3778 @item Add examples
3779 @end itemize
3781 @node Credits for the source-registry,  , TODO, Controlling where ASDF searches for systems
3782 @section Credits for the source-registry
3784 Thanks a lot to Stelian Ionescu for the initial idea.
3786 Thanks to Rommel Martinez for the initial implementation attempt.
3788 All bad design ideas and implementation bugs are mine, not theirs.
3789 But so are good design ideas and elegant implementation tricks.
3791  --- Francois-Rene Rideau @email{fare@@tunes.org}, Mon, 22 Feb 2010 00:07:33 -0500
3795 @node Controlling where ASDF saves compiled files, Error handling, Controlling where ASDF searches for systems, Top
3796 @comment  node-name,  next,  previous,  up
3797 @chapter Controlling where ASDF saves compiled files
3798 @cindex asdf-output-translations
3799 @vindex ASDF_OUTPUT_TRANSLATIONS
3801 Each Common Lisp implementation has its own format
3802 for compiled files or fasls.@footnote{``FASL'' is short for ``FASt Loading.''}
3803 If you use multiple implementations
3804 (or multiple versions of the same implementation),
3805 you'll soon find your source directories
3806 littered with various @file{fasl}s, @file{dfsl}s, @file{cfsl}s and so
3808 Worse yet, multiple implementations use the same file extension and
3809 some implementations maintain the same file extension
3810 while changing formats from version to version (or platform to
3811 platform).
3812 This can lead to many errors and much confusion
3813 as you switch from one implementation to the next.
3814 Finally, this requires write access to the source directory,
3815 and therefore precludes sharing of a same source code directory between multiple users.
3817 Since ASDF 2, ASDF includes the @code{asdf-output-translations} facility
3818 to mitigate the problem.
3820 @menu
3821 * Output Configurations::
3822 * Output Backward Compatibility::
3823 * Output Configuration DSL::
3824 * Output Configuration Directories::
3825 * Output Shell-friendly syntax for configuration::
3826 * Semantics of Output Translations::
3827 * Output Caching Results::
3828 * Output location API::
3829 * Credits for output translations::
3830 @end menu
3832 @node Output Configurations, Output Backward Compatibility, Controlling where ASDF saves compiled files, Controlling where ASDF saves compiled files
3833 @section Configurations
3835 @c FIXME: Explain how configurations work: can't expect reader will have
3836 @c looked at previous chapter. Probably cut and paste will do.
3839 Configurations specify mappings from input locations to output locations.
3840 Once again we rely on the XDG base directory specification for configuration.
3841 @xref{Controlling where ASDF searches for systems,,XDG base directory}.
3843 @enumerate
3845 @item
3846 Some hardcoded wrapping output translations configuration may be used.
3847 This allows special output translations (or usually, invariant directories)
3848 to be specified corresponding to the similar special entries in the source registry.
3850 @item
3851 An application may explicitly initialize the output-translations
3852 configuration using the Configuration API
3853 in which case this takes precedence.
3854 (@pxref{Controlling where ASDF saves compiled files,,Configuration API}.)
3855 It may itself compute this configuration from the command-line,
3856 from a script, from its own configuration file, etc.
3858 @item
3859 The source registry will be configured from
3860 the environment variable @code{ASDF_OUTPUT_TRANSLATIONS} if it exists.
3862 @item
3863 The source registry will be configured from
3864 user configuration file
3865 @file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf}
3866 (which defaults to
3867 @file{~/.config/common-lisp/asdf-output-translations.conf})
3868 if it exists.
3870 @item
3871 The source registry will be configured from
3872 user configuration directory
3873 @file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf.d/}
3874 (which defaults to
3875 @file{~/.config/common-lisp/asdf-output-translations.conf.d/})
3876 if it exists.
3878 @item
3879 The source registry will be configured from
3880 system configuration file
3881 @file{/etc/common-lisp/asdf-output-translations.conf}
3882 if it exists.
3884 @item
3885 The source registry will be configured from
3886 system configuration directory
3887 @file{/etc/common-lisp/asdf-output-translations.conf.d/}
3888 if it exists.
3890 @end enumerate
3892 Each of these configurations is specified as a SEXP
3893 in a trivial domain-specific language (@pxref{Configuration DSL}).
3894 Additionally, a more shell-friendly syntax is available
3895 for the environment variable (@pxref{Shell-friendly syntax for configuration}).
3897 When processing an entry in the above list of configuration methods,
3898 ASDF will stop unless that entry
3899 explicitly or implicitly specifies that it
3900 includes its inherited configuration.
3902 Note that by default, a per-user cache is used for output files.
3903 This allows the seamless use of shared installations of software
3904 between several users, and takes files out of the way of the developers
3905 when they browse source code,
3906 at the expense of taking a small toll when developers have to clean up
3907 output files and find they need to get familiar with output-translations
3908 first.@footnote{A @code{CLEAN-OP} would be a partial solution to this problem.}
3911 @node Output Backward Compatibility, Output Configuration DSL, Output Configurations, Controlling where ASDF saves compiled files
3912 @section Backward Compatibility
3913 @cindex ASDF-BINARY-LOCATIONS compatibility
3914 @c FIXME: Demote this section -- the typical reader doesn't care about
3915 @c backwards compatibility.
3918 We purposely do @emph{not} provide backward compatibility with earlier versions of
3919 @code{ASDF-Binary-Locations} (8 Sept 2009),
3920 @code{common-lisp-controller} (7.0) or
3921 @code{cl-launch} (2.35),
3922 each of which had similar general capabilities.
3923 The APIs of these programs were not designed
3924 for easy user configuration
3925 through configuration files.
3926 Recent versions of @code{common-lisp-controller} (7.2) and @code{cl-launch} (3.000)
3927 use the new @code{asdf-output-translations} API as defined below.
3928 @code{ASDF-Binary-Locations} is fully superseded and not to be used anymore.
3930 This incompatibility shouldn't inconvenience many people.
3931 Indeed, few people use and customize these packages;
3932 these few people are experts who can trivially adapt to the new configuration.
3933 Most people are not experts, could not properly configure these features
3934 (except inasmuch as the default configuration of
3935 @code{common-lisp-controller} and/or @code{cl-launch}
3936 might have been doing the right thing for some users),
3937 and yet will experience software that ``just works'',
3938 as configured by the system distributor, or by default.
3940 Nevertheless, if you are a fan of @code{ASDF-Binary-Locations},
3941 we provide a limited emulation mode:
3943 @defun enable-asdf-binary-locations-compatibility @Akey{} centralize-lisp-binaries default-toplevel-directory include-per-user-information map-all-source-files source-to-target-mappings
3944 This function will initialize the new @code{asdf-output-translations} facility in a way
3945 that emulates the behaviour of the old @code{ASDF-Binary-Locations} facility.
3946 Where you would previously set global variables
3947 @var{*centralize-lisp-binaries*},
3948 @var{*default-toplevel-directory*},
3949 @var{*include-per-user-information*},
3950 @var{*map-all-source-files*} or @var{*source-to-target-mappings*}
3951 you will now have to pass the same values as keyword arguments to this function.
3952 Note however that as an extension the @code{:source-to-target-mappings} keyword argument
3953 will accept any valid pathname designator for @code{asdf-output-translations}
3954 instead of just strings and pathnames.
3955 @end defun
3957 If you insist, you can also keep using the old @code{ASDF-Binary-Locations}
3958 (the one available as an extension to load of top of ASDF,
3959 not the one built into a few old versions of ASDF),
3960 but first you must disable @code{asdf-output-translations}
3961 with @code{(asdf:disable-output-translations)},
3962 or you might experience ``interesting'' issues.
3964 Also, note that output translation is enabled by default.
3965 To disable it, use @code{(asdf:disable-output-translations)}.
3967 @node Output Configuration DSL, Output Configuration Directories, Output Backward Compatibility, Controlling where ASDF saves compiled files
3968 @section Configuration DSL
3970 Here is the grammar of the SEXP DSL
3971 for @code{asdf-output-translations} configuration:
3973 @verbatim
3974 ;; A configuration is single SEXP starting with keyword :source-registry
3975 ;; followed by a list of directives.
3976 CONFIGURATION := (:output-translations DIRECTIVE ...)
3978 ;; A directive is one of the following:
3979 DIRECTIVE :=
3980     ;; INHERITANCE DIRECTIVE:
3981     ;; Your configuration expression MUST contain
3982     ;; exactly one of either of these:
3983     :inherit-configuration |
3984       ;; splices inherited configuration (often specified last)
3985     :ignore-inherited-configuration |
3986       ;; drop inherited configuration (specified anywhere)
3988     ;; forward compatibility directive (since ASDF 2.011.4), useful when
3989     ;; you want to use new configuration features but have to bootstrap a
3990     ;; the newer required ASDF from an older release that doesn't have
3991     ;; said features:
3992     :ignore-invalid-entries |
3994     ;; include a configuration file or directory
3995     (:include PATHNAME-DESIGNATOR) |
3997     ;; enable global cache in ~/.common-lisp/cache/sbcl-1.0.45-linux-amd64/
3998     ;; or something.
3999     :enable-user-cache |
4000     ;; Disable global cache. Map / to /
4001     :disable-cache |
4003     ;; add a single directory to be scanned (no recursion)
4004     (DIRECTORY-DESIGNATOR DIRECTORY-DESIGNATOR)
4006     ;; use a function to return the translation of a directory designator
4007     (DIRECTORY-DESIGNATOR (:function TRANSLATION-FUNCTION))
4009 DIRECTORY-DESIGNATOR :=
4010     NIL | ; As source: skip this entry. As destination: same as source
4011     T | ; as source matches anything, as destination
4012         ; maps pathname to itself.
4013     ABSOLUTE-COMPONENT-DESIGNATOR ; same as in the source-registry language
4015 TRANSLATION-FUNCTION :=
4016     SYMBOL | ;; symbol naming a function that takes two arguments:
4017              ;; the pathname to be translated and the matching
4018              ;; DIRECTORY-DESIGNATOR
4019     LAMBDA   ;; A form which evaluates to a function taking two arguments:
4020              ;; the pathname to be translated and the matching
4021              ;; DIRECTORY-DESIGNATOR
4023 @end verbatim
4025 Relative components better be either relative
4026 or subdirectories of the path before them, or bust.
4028 @c FIXME: the following assumes that the reader is familiar with the use
4029 @c of this pattern in logical pathnames, which may not be a reasonable
4030 @c assumption.  Expand.
4031 The last component, if not a pathname, is notionally completed by @file{/**/*.*}.
4032 You can specify more fine-grained patterns
4033 by using a pathname object as the last component
4034 e.g. @file{#p"some/path/**/foo*/bar-*.fasl"}
4036 You may use @code{#+features} to customize the configuration file.
4038 The second designator of a mapping may be @code{nil}, indicating that files are not mapped
4039 to anything but themselves (same as if the second designator was the same as the first).
4041 When the first designator is @code{t},
4042 the mapping always matches.
4043 When the first designator starts with @code{:root},
4044 the mapping matches any host and device.
4045 In either of these cases, if the second designator
4046 isn't @code{t} and doesn't start with @code{:root},
4047 then strings indicating the host and pathname are somehow copied
4048 in the beginning of the directory component of the source pathname
4049 before it is translated.
4051 When the second designator is @code{t}, the mapping is the identity.
4052 When the second designator starts with @code{:root},
4053 the mapping preserves the host and device of the original pathname.
4054 Notably, this allows you to map files
4055 to a subdirectory of the whichever directory the file is in.
4056 Though the syntax is not quite as easy to use as we'd like,
4057 you can have an (source destination) mapping entry such as follows
4058 in your configuration file,
4059 or you may use @code{enable-asdf-binary-locations-compatibility}
4060 with @code{:centralize-lisp-binaries nil}
4061 which will do the same thing internally for you:
4062 @lisp
4063 #.(let ((wild-subdir
4064           (make-pathname :directory '(:relative :wild-inferiors)))
4065         (wild-file
4066           (make-pathname :name :wild :version :wild :type :wild)))
4067    `((:root ,wild-subdir ,wild-file)
4068      (:root ,wild-subdir :implementation ,wild-file)))
4069 @end lisp
4070 Starting with ASDF 2.011.4, you can use the simpler:
4071         @code{`(:root (:root :**/ :implementation :*.*.*))}
4075 @code{:include} statements cause the search to recurse with the path specifications
4076 from the file specified.
4078 If the @code{translate-pathname} mechanism cannot achieve a desired
4079 translation, the user may provide a function which provides the
4080 required algorithm.  Such a translation function is specified by
4081 supplying a list as the second @code{directory-designator}
4082 the first element of which is the keyword @code{:function},
4083 and the second element of which is
4084 either a symbol which designates a function or a lambda expression.
4085 The function designated by the second argument must take two arguments,
4086 the first being the pathname of the source file,
4087 the second being the wildcard that was matched.
4088 When invoked, the function should return the translated pathname.
4090 An @code{:inherit-configuration} statement causes the search to recurse with the path
4091 specifications from the next configuration in the bulleted list.
4092 @xref{Controlling where ASDF saves compiled files,,Configurations}, above.
4094 @vindex @code{asdf::*user-cache*}
4095 @itemize
4096 @item
4097 @code{:enable-user-cache} is the same as @code{(t :user-cache)}.
4098 @item
4099 @code{:disable-cache} is the same as @code{(t t)}.
4100 @item
4101 @code{:user-cache} uses the contents of variable @code{asdf::*user-cache*}
4102 which by default is the same as using
4103 @code{(:home ".cache" "common-lisp" :implementation)}.
4104 @end itemize
4107 @node Output Configuration Directories, Output Shell-friendly syntax for configuration, Output Configuration DSL, Controlling where ASDF saves compiled files
4108 @section Configuration Directories
4110 Configuration directories consist of files, each of which contains
4111 a list of directives without any enclosing
4112 @code{(:output-translations ...)} form.
4113 The files will be sorted by namestring as if by @code{string<} and
4114 the lists of directives of these files with be concatenated in order.
4115 An implicit @code{:inherit-configuration} will be included
4116 at the @emph{end} of the list.
4118 System-wide or per-user Common Lisp software distributions
4119 such as Debian packages or some future version of @code{clbuild}
4120 may then include files such as
4121 @file{/etc/common-lisp/asdf-output-translations.conf.d/10-foo.conf} or
4122 @file{~/.config/common-lisp/asdf-output-translations.conf.d/10-foo.conf}
4123 to easily and modularly register configuration information
4124 about software being distributed.
4126 The convention is that, for sorting purposes,
4127 the names of files in such a directory begin with two digits
4128 that determine the order in which these entries will be read.
4129 Also, the type of these files must be @file{.conf},
4130 which not only simplifies the implementation by allowing
4131 for more portable techniques in finding those files,
4132 but also makes it trivial to disable a file, by renaming it to a different file type.
4134 Directories may be included by specifying a directory pathname
4135 or namestring in an @code{:include} directive, e.g.:
4137 @verbatim
4138         (:include "/foo/bar/")
4139 @end verbatim
4141 @node Output Shell-friendly syntax for configuration, Semantics of Output Translations, Output Configuration Directories, Controlling where ASDF saves compiled files
4142 @section Shell-friendly syntax for configuration
4144 When considering environment variable @code{ASDF_OUTPUT_TRANSLATIONS}
4145 ASDF will skip to the next configuration if it's an empty string.
4146 It will @code{READ} the string as an SEXP in the DSL
4147 if it begins with a paren @code{(}
4148 and it will be interpreted as a list of directories.
4149 Directories should come by pairs, indicating a mapping directive.
4150 Entries are separated
4151 by a @code{:} (colon) on Unix platforms (including cygwin),
4152 by a @code{;} (semicolon) on other platforms (mainly, Windows).
4154 The magic empty entry,
4155 if it comes in what would otherwise be the first entry in a pair,
4156 indicates the splicing of inherited configuration.
4157 If it comes as the second entry in a pair,
4158 it indicates that the directory specified first is to be left untranslated
4159 (which has the same effect as if the directory had been repeated).
4160 Thus @code{"/foo:/bar::/baz:"} means that
4161 things under directory @file{/foo/}
4162 are translated to be under @file{/bar/},
4163 then include the inherited configuration,
4164 then specify that things under directory @file{/baz/} are not translated.
4166 @node Semantics of Output Translations, Output Caching Results, Output Shell-friendly syntax for configuration, Controlling where ASDF saves compiled files
4167 @section Semantics of Output Translations
4169 From the specified configuration,
4170 a list of mappings is extracted in a straightforward way:
4171 mappings are collected in order, recursing through
4172 included or inherited configuration as specified.
4173 To this list is prepended some implementation-specific mappings,
4174 and is appended a global default.
4176 The list is then compiled to a mapping table as follows:
4177 for each entry, in order, resolve the first designated directory
4178 into an actual directory pathname for source locations.
4179 If no mapping was specified yet for that location,
4180 resolve the second designated directory to an output location directory
4181 add a mapping to the table mapping the source location to the output location,
4182 and add another mapping from the output location to itself
4183 (unless a mapping already exists for the output location).
4185 Based on the table, a mapping function is defined,
4186 mapping source pathnames to output pathnames:
4187 given a source pathname, locate the longest matching prefix
4188 in the source column of the mapping table.
4189 Replace that prefix by the corresponding output column
4190 in the same row of the table, and return the result.
4191 If no match is found, return the source pathname.
4192 (A global default mapping the filesystem root to itself
4193 may ensure that there will always be a match,
4194 with same fall-through semantics).
4196 @node Output Caching Results, Output location API, Semantics of Output Translations, Controlling where ASDF saves compiled files
4197 @section Caching Results
4199 The implementation is allowed to either eagerly compute the information
4200 from the configurations and file system, or to lazily re-compute it
4201 every time, or to cache any part of it as it goes.
4202 To explicitly flush any information cached by the system, use the API below.
4205 @node Output location API, Credits for output translations, Output Caching Results, Controlling where ASDF saves compiled files
4206 @section Output location API
4208 The specified functions are exported from package ASDF.
4210 @defun initialize-output-translations @Aoptional{} PARAMETER
4211    will read the configuration and initialize all internal variables.
4212    You may extend or override configuration
4213    from the environment and configuration files
4214    with the given @var{PARAMETER}, which can be
4215    @code{nil} (no configuration override),
4216    or a SEXP (in the SEXP DSL),
4217    a string (as in the string DSL),
4218    a pathname (of a file or directory with configuration),
4219    or a symbol (fbound to function that when called returns one of the above).
4220 @end defun
4222 @defun disable-output-translations
4223    will initialize output translations in a way
4224    that maps every pathname to itself,
4225    effectively disabling the output translation facility.
4226 @end defun
4228 @defun clear-output-translations
4229    undoes any output translation configuration
4230    and clears any cache for the mapping algorithm.
4231    You might want to call this function
4232    (or better, @code{clear-configuration})
4233    before you dump an image that would be resumed
4234    with a different configuration,
4235    and return an empty configuration.
4236    Note that this does not include clearing information about
4237    systems defined in the current image, only about
4238    where to look for systems not yet defined.
4239 @end defun
4241 @defun ensure-output-translations @Aoptional{} PARAMETER
4242    checks whether output translations have been initialized.
4243    If not, initialize them with the given @var{PARAMETER}.
4244    This function will be called before any attempt to operate on a system.
4245 @end defun
4247 @defun apply-output-translations PATHNAME
4248    Applies the configured output location translations to @var{PATHNAME}
4249    (calls @code{ensure-output-translations} for the translations).
4250 @end defun
4252 Every time you use ASDF's @code{output-files}, or
4253 anything that uses it (that may compile, such as @code{operate}, @code{perform}, etc.),
4254 @code{ensure-output-translations} is called with parameter @code{nil},
4255 which the first time around causes your configuration to be read.
4256 If you change a configuration file,
4257 you need to explicitly @code{initialize-output-translations} again,
4258 or maybe @code{clear-output-translations} (or @code{clear-configuration}),
4259 which will cause the initialization to happen next time around.
4262 @node Credits for output translations,  , Output location API, Controlling where ASDF saves compiled files
4263 @section Credits for output translations
4265 Thanks a lot to Peter van Eynde for @code{Common Lisp Controller}
4266 and to Bjorn Lindberg and Gary King for @code{ASDF-Binary-Locations}.
4268 All bad design ideas and implementation bugs are to mine, not theirs.
4269 But so are good design ideas and elegant implementation tricks.
4271  --- Francois-Rene Rideau @email{fare@@tunes.org}
4273 @c @section Default locations
4274 @c @findex output-files-for-system-and-operation
4276 @c The default binary location for each Lisp implementation
4277 @c is a subdirectory of each source directory.
4278 @c To account for different Lisps, Operating Systems, Implementation versions,
4279 @c and so on, ASDF borrows code from SLIME
4280 @c to create reasonable custom directory names.
4281 @c Here are some examples:
4283 @c @itemize
4284 @c @item
4285 @c SBCL, version 1.0.45 on Mac OS X for Intel: @code{sbcl-1.0.45-darwin-x86}
4287 @c @item
4288 @c Franz Allegro, version 8.0, ANSI Common Lisp: @code{allegro-8.0a-macosx-x86}
4290 @c @item
4291 @c Franz Allegro, version 8.1, Modern (case sensitive) Common Lisp: @code{allegro-8.1m-macosx-x86}
4292 @c @end itemize
4294 @c By default, all output file pathnames will be relocated
4295 @c to some thus-named subdirectory of @file{~/.cache/common-lisp/}.
4297 @c See the document @file{README.asdf-output-translations}
4298 @c for a full specification on how to configure @code{asdf-output-translations}.
4300 @node  Error handling, Miscellaneous additional functionality, Controlling where ASDF saves compiled files, Top
4301 @comment  node-name,  next,  previous,  up
4302 @chapter Error handling
4303 @findex SYSTEM-DEFINITION-ERROR
4304 @findex OPERATION-ERROR
4306 @section ASDF errors
4308 If ASDF detects an incorrect system definition, it will signal a generalised instance of
4309 @code{SYSTEM-DEFINITION-ERROR}.
4311 Operations may go wrong (for example when source files contain errors).
4312 These are signalled using generalised instances of
4313 @code{OPERATION-ERROR}.
4315 @section Compilation error and warning handling
4316 @vindex *compile-file-warnings-behaviour*
4317 @vindex *compile-file-failure-behaviour*
4319 ASDF checks for warnings and errors when a file is compiled.
4320 The variables @var{*compile-file-warnings-behaviour*} and
4321 @var{*compile-file-failure-behaviour*}
4322 control the handling of any such events.
4323 The valid values for these variables are
4324 @code{:error}, @code{:warn}, and @code{:ignore}.
4326 @node  Miscellaneous additional functionality, Getting the latest version, Error handling, Top
4327 @comment  node-name,  next,  previous,  up
4328 @chapter Miscellaneous additional functionality
4330 ASDF includes several additional features that are generally
4331 useful for system definition and development.
4333 @menu
4334 * Controlling file compilation::
4335 * Controlling source file character encoding::
4336 * Miscellaneous Functions::
4337 * Some Utility Functions::
4338 @end menu
4340 @node Controlling file compilation, Controlling source file character encoding, Miscellaneous additional functionality, Miscellaneous additional functionality
4341 @section Controlling file compilation
4342 @cindex :around-compile
4343 @cindex around-compile keyword
4344 @cindex compile-check keyword
4345 @cindex :compile-check
4346 @findex compile-file*
4348 @c FIXME: Needs rewrite.  Start with motivation -- why are we doing
4349 @c this?  (there is some, but it's buried).  Also, all of a sudden in
4350 @c the middle of the discussion we start talking about a "hook," which
4351 @c is confusing.
4353 When declaring a component (system, module, file),
4354 you can specify a keyword argument @code{:around-compile function}.
4355 If left unspecified (and therefore unbound),
4356 the value will be inherited from the parent component if any,
4357 or with a default of @code{nil}
4358 if no value is specified in any transitive parent.
4360 The argument must be either @code{nil}, an fbound symbol,
4361 a lambda-expression (e.g. @code{(lambda (thunk) ...(funcall thunk ...) ...)})
4362 a function object (e.g. using @code{#.#'} but that's discouraged
4363 because it prevents the introspection done by e.g. asdf-dependency-grovel),
4364 or a string that when @code{read} yields a symbol or a lambda-expression.
4365 @code{nil} means the normal compile-file function will be called.
4366 A non-nil value designates a function of one argument
4367 that will be called with a function that will
4368 invoke @code{compile-file*} with various arguments;
4369 the around-compile hook may supply additional keyword arguments
4370 to pass to that call to @code{compile-file*}.
4372 One notable argument that is heeded by @code{compile-file*} is
4373 @code{:compile-check},
4374 a function called when the compilation was otherwise a success,
4375 with the same arguments as @code{compile-file};
4376 the function shall return true if the compilation
4377 and its resulting compiled file respected all system-specific invariants,
4378 and false (@code{nil}) if it broke any of those invariants;
4379 it may issue warnings or errors before it returns @code{nil}.
4380 (NB: The ability to pass such extra flags
4381 is only available starting with ASDF 2.22.3.)
4382 This feature is notably exercised by asdf-finalizers.
4384 By using a string, you may reference
4385 a function, symbol and/or package
4386 that will only be created later during the build, but
4387 isn't yet present at the time the defsystem form is evaluated.
4388 However, if your entire system is using such a hook, you may have to
4389 explicitly override the hook with @code{nil} for all the modules and files
4390 that are compiled before the hook is defined.
4392 Using this hook, you may achieve such effects as:
4393 locally renaming packages,
4394 binding @var{*readtables*} and other syntax-controlling variables,
4395 handling warnings and other conditions,
4396 proclaiming consistent optimization settings,
4397 saving code coverage information,
4398 maintaining meta-data about compilation timings,
4399 setting gensym counters and PRNG seeds and other sources of non-determinism,
4400 overriding the source-location and/or timestamping systems,
4401 checking that some compile-time side-effects were properly balanced,
4402 etc.
4404 Note that there is no around-load hook. This is on purpose.
4405 Some implementations such as ECL, GCL or MKCL link object files,
4406 which allows for no such hook.
4407 Other implementations allow for concatenating FASL files,
4408 which doesn't allow for such a hook either.
4409 We aim to discourage something that's not portable,
4410 and has some dubious impact on performance and semantics
4411 even when it is possible.
4412 Things you might want to do with an around-load hook
4413 are better done around-compile,
4414 though it may at times require some creativity
4415 (see e.g. the @code{package-renaming} system).
4418 @node Controlling source file character encoding, Miscellaneous Functions, Controlling file compilation, Miscellaneous additional functionality
4419 @section Controlling source file character encoding
4421 Starting with ASDF 2.21, components accept a @code{:encoding} option
4422 so authors may specify which character encoding should be used
4423 to read and evaluate their source code.
4424 When left unspecified, the encoding is inherited
4425 from the parent module or system;
4426 if no encoding is specified at any point,
4427 or if @code{nil} is explicitly specified,
4428 an extensible protocol described below is followed,
4429 that ultimately defaults to @code{:utf-8} since ASDF 3.
4431 The protocol to determine the encoding is
4432 to call the function @code{detect-encoding},
4433 which itself, if provided a valid file,
4434 calls the function specified by @var{*encoding-detection-hook*},
4435 or else defaults to the @var{*default-encoding*}.
4436 The @var{*encoding-detection-hook*} is by default bound
4437 to function @code{always-default-encoding},
4438 that always returns the contents of @var{*default-encoding*}.
4439 @var{*default-encoding*} is bound to @code{:utf-8} by default
4440 (before ASDF 3, the default was @code{:default}).
4442 Whichever encoding is returned must be a portable keyword,
4443 that will be translated to an implementation-specific external-format designator
4444 by function @code{encoding-external-format},
4445 which itself simply calls the function specified @var{*encoding-external-format-hook*};
4446 that function by default is @code{default-encoding-external-format},
4447 that only recognizes @code{:utf-8} and @code{:default},
4448 and translates the former to the implementation-dependent @var{*utf-8-external-format*},
4449 and the latter to itself (that itself is portable but has an implementation-dependent meaning).
4451 In other words, there now are plenty of extension hooks, but
4452 by default ASDF enforces the previous @emph{de facto} standard behaviour
4453 of using @code{:utf-8}, independently from
4454 whatever configuration the user may be using.
4455 Thus, system authors can now rely on @code{:utf-8}
4456 being used while compiling their files,
4457 even if the user is currently using @code{:koi8-r} or @code{:euc-jp}
4458 as their interactive encoding.
4459 (Before ASDF 3, there was no such guarantee, @code{:default} was used,
4460 and only plain ASCII was safe to include in source code.)
4462 Some legacy implementations only support 8-bit characters,
4463 and some implementations provide 8-bit only variants.
4464 On these implementations, the @var{*utf-8-external-format*}
4465 gracefully falls back to @code{:default},
4466 and Unicode characters will be read as multi-character mojibake.
4467 To detect such situations, UIOP will push the @code{:asdf-unicode} feature
4468 on implementations that support Unicode, and you can use reader-conditionalization
4469 to protect any @code{:encoding @emph{encoding}} statement, as in
4470 @code{#+asdf-unicode :encoding #+asdf-unicode :utf-8}.
4471 We recommend that you avoid using unprotected @code{:encoding} specifications
4472 until after ASDF 2.21 or later becomes widespread.
4473 As of May 2015, all maintained implementations provide ASDF 3,
4474 so you may prudently start using this and other features without such protection.
4476 While it offers plenty of hooks for extension,
4477 and one such extension is available (see @code{asdf-encodings} below),
4478 ASDF itself only recognizes one encoding beside @code{:default},
4479 and that is @code{:utf-8}, which is the @emph{de facto} standard,
4480 already used by the vast majority of libraries that use more than ASCII.
4481 On implementations that do not support unicode,
4482 the feature @code{:asdf-unicode} is absent, and
4483 the @code{:default} external-format is used
4484 to read even source files declared as @code{:utf-8}.
4485 On these implementations, non-ASCII characters
4486 intended to be read as one CL character
4487 may thus end up being read as multiple CL characters.
4488 In most cases, this shouldn't affect the software's semantics:
4489 comments will be skipped just the same, strings with be read and printed
4490 with slightly different lengths, symbol names will be accordingly longer,
4491 but none of it should matter.
4492 But a few systems that actually depend on unicode characters
4493 may fail to work properly, or may work in a subtly different way.
4494 See for instance @code{lambda-reader}.
4496 We invite you to embrace UTF-8
4497 as the encoding for non-ASCII characters starting today,
4498 even without any explicit specification in your @file{.asd} files.
4499 Indeed, on some implementations and configurations,
4500 UTF-8 is already the @code{:default},
4501 and loading your code may cause errors if it is encoded in anything but UTF-8.
4502 Therefore, even with the legacy behaviour,
4503 non-UTF-8 is guaranteed to break for some users,
4504 whereas UTF-8 is pretty much guaranteed not to break anywhere
4505 (provided you do @emph{not} use a BOM),
4506 although it might be read incorrectly on some implementations.
4507 @code{:utf-8} has been the default value of @code{*default-encoding*} since ASDF 3.
4509 If you need non-standard character encodings for your source code,
4510 use the extension system @code{asdf-encodings}, by specifying
4511 @code{:defsystem-depends-on ("asdf-encodings")} in your @code{defsystem}.
4512 This extension system will register support for more encodings using the
4513 @code{*encoding-external-format-hook*} facility,
4514 so you can explicitly specify @code{:encoding :latin1}
4515 in your @file{.asd} file.
4516 Using the @code{*encoding-detection-hook*} it will also
4517 eventually implement some autodetection of a file's encoding
4518 from an emacs-style @code{-*- mode: lisp ; coding: latin1 -*-} declaration,
4519 or otherwise based on an analysis of octet patterns in the file.
4520 At this point, @code{asdf-encoding} only supports the encodings
4521 that are supported as part of your implementation.
4522 Since the list varies depending on implementations,
4523 we still recommend you use @code{:utf-8} everywhere,
4524 which is the most portable (next to it is @code{:latin1}).
4526 Recent versions of Quicklisp include @code{asdf-encodings};
4527 if you're not using it, you may get this extension using git:
4528 @kbd{git clone https://gitlab.common-lisp.net/asdf/asdf-encodings.git}
4530 @kbd{git clone git@@gitlab.common-lisp.net:asdf/asdf-encodings.git}.
4531 You can also browse the repository on
4532 @url{https://gitlab.common-lisp.net/asdf/asdf-encodings}.
4534 When you use @code{asdf-encodings},
4535 any @file{.asd} file loaded
4536 will use the autodetection algorithm to determine its encoding.
4537 If you depend on this detection happening,
4538 you should explicitly load @code{asdf-encodings} early in your build.
4539 Note that @code{:defsystem-depends-on} cannot be used here: by the time
4540 the @code{:defsystem-depends-on} is loaded, the enclosing
4541 @code{defsystem} form has already been read.
4543 In practice, this means that the @code{*default-encoding*}
4544 is usually used for @file{.asd} files.
4545 Currently, this defaults to @code{:utf-8}, and
4546 you should be safe using Unicode characters in those files.
4547 This might matter, for instance, in meta-data about author's names.
4548 Otherwise, the main data in these files is component (path)names,
4549 and we don't recommend using non-ASCII characters for these,
4550 for the result probably isn't very portable.
4552 @node Miscellaneous Functions, Some Utility Functions, Controlling source file character encoding, Miscellaneous additional functionality
4553 @section Miscellaneous Functions
4555 These functions are exported by ASDF for your convenience.
4557 @anchor{system-relative-pathname}
4558 @defun system-relative-pathname system name @Akey{} type
4560 It's often handy to locate a file relative to some system.
4561 The @code{system-relative-pathname} function meets this need.
4563 It takes two mandatory arguments @var{system} and @var{name}
4564 and a keyword argument @var{type}:
4565 @var{system} is name of a system, whereas @var{name} and optionally @var{type}
4566 specify a relative pathname, interpreted like a component pathname specifier
4567 by @code{coerce-pathname}. @xref{The defsystem grammar,,Pathname specifiers}.
4569 It returns a pathname built from the location of the system's
4570 source directory and the relative pathname. For example:
4572 @lisp
4573 > (asdf:system-relative-pathname 'cl-ppcre "regex.data")
4574 #P"/repository/other/cl-ppcre/regex.data"
4575 @end lisp
4577 @end defun
4579 @defun system-source-directory system-designator
4581 ASDF does not provide a turnkey solution for locating
4582 data (or other miscellaneous) files
4583 that are distributed together with the source code of a system.
4584 Programmers can use @code{system-source-directory} to find such files.
4585 Returns a pathname object.
4586 The @var{system-designator} may be a string, symbol, or ASDF system object.
4587 @end defun
4589 @defun clear-system system-designator
4591 It is sometimes useful to force recompilation of a previously loaded system.
4592 For these cases, @code{(asdf:clear-system :foo)}
4593 will remove the system from the table of currently loaded systems:
4594 the next time the system @code{foo} or one that depends on it is re-loaded,
4595 @code{foo} will be loaded again.@footnote{Alternatively, you could touch @code{foo.asd} or
4596 remove the corresponding fasls from the output file cache.}
4598 Note that this does not and cannot undo
4599 the previous loading of the system.
4600 Common Lisp has no provision for such an operation,
4601 and its reliance on irreversible side-effects to global data structures
4602 makes such a thing impossible in the general case.
4603 If the software being re-loaded is not conceived with hot upgrade in mind,
4604 re-loading may cause many errors, warnings or subtle silent problems,
4605 as packages, generic function signatures, structures, types, macros, constants, etc.
4606 are being redefined incompatibly.
4607 It is up to the user to make sure that reloading is possible and has the desired effect.
4608 In some cases, extreme measures such as recursively deleting packages,
4609 unregistering symbols, defining methods on @code{update-instance-for-redefined-class}
4610 and much more are necessary for reloading to happen smoothly.
4611 ASDF itself goes to extensive effort to make a hot upgrade possible
4612 with respect to its own code.
4613 If you want, you can reuse some of its utilities such as
4614 @code{uiop:define-package} and @code{uiop:with-upgradability},
4615 and get inspiration (or disinspiration)
4616 from what it does in @file{header.lisp} and @file{upgrade.lisp}.
4617 @end defun
4619 @defun register-preloaded-system name @Arest{} keys
4620 A system with name @var{name},
4621 created by @code{make-instance} with extra keys @var{keys}
4622 (e.g. @code{:version}),
4623 is registered as @emph{preloaded}.
4624 That is, its code has already been loaded into the current image,
4625 and if at some point some other system @code{:depends-on} it yet no source code is found,
4626 it is considered as already provided,
4627 and ASDF will not raise a @code{missing-component} error.
4629 This function is particularly useful if you distribute your code
4630 as fasls with either @code{compile-bundle-op} or @code{monolithic-compile-bundle-op},
4631 and want to register systems so that dependencies will work uniformly
4632 whether you're using your software from source or from fasl.
4633 @end defun
4635 @defun register-immutable-system name @Arest{} keys
4636 A system with name @var{name},
4637 created by @code{make-instance} with extra keys @var{keys}
4638 (e.g. @code{:version}),
4639 is registered as @emph{immutable}.
4640 That is, its code has already been loaded into the current image,
4641 and if at some point some other system @code{:depends-on} it,
4642 it is considered as already provided, and
4643 no attempt will be made to search for an updated version from the source-registry
4644 or any other method.
4645 There will be no search for an @file{.asd} file, and no @code{missing-component} error.
4647 This function (available since ASDF 3.1.5) is particularly useful if
4648 you distribute a large body of code as a precompiled image,
4649 and want to allow users to extend the image with further extension systems,
4650 but without making thousands of filesystem requests looking for inexistent (or worse, out of date) source code
4651 for all the systems that came bundled with the image but aren't
4652 distributed as source code to regular users.
4653 @cindex immutable systems
4654 @end defun
4656 @defun run-shell-command control-string @Arest{} args
4658 This function is obsolete and present only for the sake of backwards-compatibility:
4659 ``If it's not backwards, it's not compatible''. We @emph{strongly} discourage its use.
4660 Its current behaviour is only well-defined on Unix platforms
4661 (which include MacOS X and cygwin). On Windows, anything goes.
4662 The following documentation is only for the purpose of your migrating away from it
4663 in a way that preserves semantics.
4665 Instead we recommend the use @code{run-program}, described in the next section, and
4666 available as part of ASDF since ASDF 3.
4668 @code{run-shell-command} takes as arguments a format @code{control-string}
4669 and arguments to be passed to @code{format} after this control-string
4670 to produce a string.
4671 This string is a command that will be evaluated with a POSIX shell if possible;
4672 yet, on Windows, some implementations will use CMD.EXE,
4673 while others (like SBCL) will make an attempt at invoking a POSIX shell
4674 (and fail if it is not present).
4675 @end defun
4677 @node Some Utility Functions,  , Miscellaneous Functions, Miscellaneous additional functionality
4678 @section Some Utility Functions
4680 The below functions are not exported by ASDF itself, but by UIOP, available since ASDF 3.
4681 Some of them have precursors in ASDF 2, but we recommend
4682 you rely on ASDF 3 for active developments.
4683 UIOP provides many, many more utility functions, and we recommend
4684 you read its README and sources for more information.
4687 @defun parse-unix-namestring name @Akey{} type defaults dot-dot ensure-directory @AallowOtherKeys
4688 Coerce NAME into a PATHNAME using standard Unix syntax.
4690 Unix syntax is used whether or not the underlying system is Unix;
4691 on non-Unix systems it is only usable for relative pathnames.
4692 In order to manipulate relative pathnames portably, it is crucial
4693 to possess a portable pathname syntax independent of the underlying OS.
4694 This is what @code{parse-unix-namestring} provides, and why we use it in ASDF.
4696 When given a @code{pathname} object, just return it untouched.
4697 When given @code{nil}, just return @code{nil}.
4698 When given a non-null @code{symbol}, first downcase its name and treat it as a string.
4699 When given a @code{string}, portably decompose it into a pathname as below.
4701 @code{#\/} separates directory components.
4703 The last @code{#\/}-separated substring is interpreted as follows:
4704 1- If @var{type} is @code{:directory} or @var{ensure-directory} is true,
4705  the string is made the last directory component, and its @code{name} and @code{type} are @code{nil}.
4706  if the string is empty, it's the empty pathname with all slots @code{nil}.
4707 2- If @var{type} is @code{nil}, the substring is a file-namestring,
4708  and its @code{name} and @code{type} are separated by @code{split-name-type}.
4709 3- If @var{type} is a string, it is the given @code{type}, and the whole string is the @code{name}.
4711 Directory components with an empty name the name @code{.} are removed.
4712 Any directory named @code{..} is read as @var{dot-dot},
4713 which must be one of @code{:back} or @code{:up} and defaults to @code{:back}.
4715 @vindex *nil-pathname*
4716 @code{host}, @code{device} and @code{version} components are taken from @var{defaults},
4717 which itself defaults to @code{*nil-pathname*}.
4718 @code{*nil-pathname*} is also used if @var{defaults} is @code{nil}.
4719 No host or device can be specified in the string itself,
4720 which makes it unsuitable for absolute pathnames outside Unix.
4722 For relative pathnames, these components (and hence the defaults) won't matter
4723 if you use @code{merge-pathnames*} but will matter if you use @code{merge-pathnames},
4724 which is an important reason to always use @code{merge-pathnames*}.
4726 Arbitrary keys are accepted, and the parse result is passed to @code{ensure-pathname}
4727 with those keys, removing @var{type}, @var{defaults} and @var{dot-dot}.
4728 When you're manipulating pathnames that are supposed to make sense portably
4729 even though the OS may not be Unixish, we recommend you use @code{:want-relative t}
4730 so that @code{parse-unix-namestring} will throw an error if the pathname is absolute.
4731 @end defun
4733 @defun merge-pathnames* specified @Aoptional{} defaults
4735 This function is a replacement for @code{merge-pathnames} that uses the host and device
4736 from the @var{defaults} rather than the @var{specified} pathname when the latter
4737 is a relative pathname. This allows ASDF and its users to create and use relative pathnames
4738 without having to know beforehand what are the host and device
4739 of the absolute pathnames they are relative to.
4741 @end defun
4743 @defun subpathname pathname subpath @Akey{} type
4745 This function takes a @var{pathname} and a @var{subpath} and a @var{type}.
4746 If @var{subpath} is already a @code{pathname} object (not namestring),
4747 and is an absolute pathname at that, it is returned unchanged;
4748 otherwise, @var{subpath} is turned into a relative pathname with given @var{type}
4749 as per @code{parse-unix-namestring} with @code{:want-relative t :type }@var{type},
4750 then it is merged with the @code{pathname-directory-pathname} of @var{pathname},
4751 as per @code{merge-pathnames*}.
4753 We strongly encourage the use of this function
4754 for portably resolving relative pathnames in your code base.
4755 @end defun
4757 @defun subpathname* pathname subpath @Akey{} type
4759 This function returns @code{nil} if the base @var{pathname} is @code{nil},
4760 otherwise acts like @code{subpathname}.
4761 @end defun
4763 @defun run-program command @Akey{} ignore-error-status force-shell input output @
4764 error-output if-input-does-not-exist if-output-exists if-error-output-exists @
4765 element-type external-format @AallowOtherKeys
4767 @code{run-program} takes a @var{command} argument that is either
4768 a list of a program name or path and its arguments,
4769 or a string to be executed by a shell.
4770 It spawns the command, waits for it to return,
4771 verifies that it exited cleanly (unless told not too below),
4772 and optionally captures and processes its output.
4773 It accepts many keyword arguments to configure its behaviour.
4775 @code{run-program} returns three values: the first for the output,
4776 the second for the error-output, and the third for the return value.
4777 (Beware that before ASDF 3.0.2.11, it didn't handle input or error-output,
4778 and returned only one value,
4779 the one for the output if any handler was specified, or else the exit code;
4780 please upgrade ASDF, or at least UIOP, to rely on the new enhanced behaviour.)
4782 @var{output} is its most important argument;
4783 it specifies how the output is captured and processed.
4784 If it is @code{nil}, then the output is redirected to the null device,
4785 that will discard it.
4786 If it is @code{:interactive}, then it is inherited from the current process
4787 (beware: this may be different from your @var{*standard-output*},
4788 and under SLIME will be on your @code{*inferior-lisp*} buffer).
4789 If it is @code{t}, output goes to your current @var{*standard-output*} stream.
4790 Otherwise, @var{output} should be a value that is a suitable first argument to
4791 @code{slurp-input-stream} (see below), or
4792 a list of such a value and keyword arguments.
4793 In this case, @code{run-program} will
4794 create a temporary stream for the program output;
4795 the program output, in that stream,
4796 will be processed by a call to @code{slurp-input-stream},
4797 using @var{output} as the first argument
4798 (or if it's a list the first element of @var{output} and the rest as keywords).
4799 The primary value resulting from that call
4800 (or @code{nil} if no call was needed)
4801 will be the first value returned by @code{run-program}.
4802 E.g., using @code{:output :string}
4803 will have it return the entire output stream as a string.
4804 And using @code{:output '(:string :stripped t)}
4805 will have it return the same string stripped of any ending newline.
4807 @var{error-output} is similar to @var{output}, except that
4808 the resulting value is returned as the second value of @code{run-program}.
4809 @code{t} designates the @var{*error-output*}.
4810 Also @code{:output} means redirecting the error output to the output stream,
4811 in which case @code{nil} is returned.
4813 @var{input} is similar to @var{output}, except that
4814 @code{vomit-output-stream} is used, no value is returned,
4815 and @code{t} designates the @var{*standard-input*}.
4817 @code{element-type} and @code{external-format} are passed on
4818 to your Lisp implementation, when applicable, for creation of the output stream.
4820 One and only one of the stream slurping or vomiting may or may not happen
4821 in parallel in parallel with the subprocess,
4822 depending on options and implementation,
4823 and with priority being given to output processing.
4824 Other streams are completely produced or consumed
4825 before or after the subprocess is spawned, using temporary files.
4827 @code{force-shell} forces evaluation of the command through a shell,
4828 even if it was passed as a list rather than a string.
4829 If a shell is used, it is @file{/bin/sh} on Unix or @file{CMD.EXE} on Windows,
4830 except on implementations that (erroneously, IMNSHO)
4831 insist on consulting @code{$SHELL} like clisp.
4833 @code{ignore-error-status} causes @code{run-program}
4834 to not raise an error if the spawned program exits in error.
4835 Following POSIX convention, an error is anything but
4836 a normal exit with status code zero.
4837 By default, an error of type @code{subprocess-error} is raised in this case.
4839 @code{run-program} works on all platforms supported by ASDF, except Genera.
4840 See the source code for more documentation.
4842 @end defun
4844 @defun slurp-input-stream processor input-stream @Akey{}
4846 @code{slurp-input-stream} is a generic function of two arguments, a target object and an input stream,
4847 and accepting keyword arguments.
4848 Predefined methods based on the target object are as follows:
4850 @itemize
4851 @item
4852 If the object is a function, the function is called with the stream as argument.
4854 @item If the object is a cons, its first element is applied to its rest appended by
4855 a list of the input stream.
4857 @item If the object is an output stream, the contents of the input stream are copied to it.
4858 If the @var{linewise} keyword argument is provided, copying happens line by line,
4859 and an optional @var{prefix} is printed before each line.
4860 Otherwise, copying happen based on a buffer of size @var{buffer-size},
4861 using the specified @var{element-type}.
4863 @item If the object is @code{'string} or @code{:string}, the content is captured into a string.
4864 Accepted keywords include the @var{element-type} and a flag @var{stripped},
4865 which when true causes any single line ending to be removed as per @code{uiop:stripln}.
4867 @item If the object is @code{:lines}, the content is captured as a list of strings,
4868 one per line, without line ending. If the @var{count} keyword argument is provided,
4869 it is a maximum count of lines to be read.
4871 @item If the object is @code{:line}, the content is captured as with @code{:lines} above,
4872 and then its sub-object is extracted with the @var{at} argument,
4873 which defaults to @code{0}, extracting the first line.
4874 A number will extract the corresponding line.
4875 See the documentation for @code{uiop:access-at}.
4877 @item If the object is @code{:forms}, the content is captured as a list of S-expressions,
4878 as read by the Lisp reader.
4879 If the @var{count} argument is provided,
4880 it is a maximum count of lines to be read.
4881 We recommend you control the syntax with such macro as
4882 @code{uiop:with-safe-io-syntax}.
4884 @item If the object is @code{:form}, the content is captured as with @code{:forms} above,
4885 and then its sub-object is extracted with the @var{at} argument,
4886 which defaults to @code{0}, extracting the first form.
4887 A number will extract the corresponding form.
4888 See the documentation for @code{uiop:access-at}.
4889 We recommend you control the syntax with such macro as
4890 @code{uiop:with-safe-io-syntax}.
4891 @end itemize
4892 @end defun
4895 @node Getting the latest version, FAQ, Miscellaneous additional functionality, Top
4896 @comment  node-name,  next,  previous,  up
4897 @chapter Getting the latest version
4900 Decide which version you want.
4901 The @code{master} branch is where development happens;
4902 its @code{HEAD} is usually OK, including the latest fixes and portability tweaks,
4903 but an occasional regression may happen despite our (limited) test suite.
4905 The @code{release} branch is what cautious people should be using;
4906 it has usually been tested more, and releases are cut at a point
4907 where there isn't any known unresolved issue.
4909 You may get the ASDF source repository using git:
4910 @kbd{git clone https://gitlab.common-lisp.net/asdf/asdf.git}
4912 You will find the above referenced tags in this repository.
4913 You can also browse the repository on
4914 @url{https://gitlab.common-lisp.net/asdf/asdf}.
4916 Discussion of ASDF development is conducted on the
4917 mailing list (@pxref{Mailing list}).
4919 @node FAQ, Ongoing Work, Getting the latest version, Top
4920 @comment  node-name,  next,  previous,  up
4921 @chapter FAQ
4923 @menu
4924 * Where do I report a bug?::
4925 * Mailing list::
4926 * What has changed between ASDF 1 ASDF 2 and ASDF 3?::
4927 * Issues with installing the proper version of ASDF::
4928 * Issues with configuring ASDF::
4929 * Issues with using and extending ASDF to define systems::
4930 * ASDF development FAQs::
4931 @end menu
4933 @node Where do I report a bug?, Mailing list, FAQ, FAQ
4934 @section  ``Where do I report a bug?''
4935 @cindex bug tracker
4936 @cindex launchpad
4937 ASDF bugs are tracked on launchpad: @url{https://launchpad.net/asdf}.
4939 If you're unsure about whether something is a bug, or for general discussion,
4940 use the asdf-devel mailing list (@pxref{Mailing list}).
4942 @node Mailing list, What has changed between ASDF 1 ASDF 2 and ASDF 3?, Where do I report a bug?, FAQ
4943 @section Mailing list
4944 @cindex mailing list
4946 Discussion of ASDF development is conducted on the
4947 mailing list
4948 @kbd{asdf-devel@@common-lisp.net}.
4949 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel}
4952 @node What has changed between ASDF 1 ASDF 2 and ASDF 3?, Issues with installing the proper version of ASDF, Mailing list, FAQ
4953 @section ``What has changed between ASDF 1, ASDF 2, and ASDF 3?''
4955 We released ASDF 2.000 on May 31st 2010,
4956 ASDF 3.0.0 on May 15th 2013,
4957 ASDF 3.1.2 on May 6th 2014.
4958 Releases of ASDF 2 and now ASDF 3 have since then been included
4959 in all actively maintained CL implementations that used to bundle ASDF 1,
4960 plus many implementations that previously did not.
4961 ASDF has been made to work with all actively maintained CL
4962 implementations and even a few implementations that are @emph{not}
4963 actively maintained.
4964 @xref{FAQ,,``What has changed between ASDF 1 ASDF 2 and ASDF 3?''}.
4966 Furthermore, it is possible to upgrade from ASDF 1 to ASDF 2 or ASDF 3 on the fly
4967 (though we recommend instead upgrading your implementation or replacing its ASDF module).
4968 For this reason, we have stopped supporting ASDF 1 and ASDF 2.
4969 If you are using ASDF 1 or ASDF 2 and are experiencing any kind of issues or limitations,
4970 we recommend you upgrade to ASDF 3
4971 --- and we explain how to do that. @xref{Loading ASDF}.
4973 Note that in the context of compatibility requirements,
4974 ASDF 2.27, released on Feb 1st 2013, and further releases up to 2.33,
4975 count as pre-releases of ASDF 3, and define the @code{:asdf3} feature,
4976 though the first stable release of ASDF 3 was release 3.0.1.
4977 Significant new or improved functionality were added in ASDF 3.1;
4978 the @code{:asdf3.1} feature is present in recent enough versions to detect this functionality;
4979 the first stable release since then was ASDF 3.1.2.
4980 New @code{*features*} are only added at major milestones,
4981 and the next one will probably be @code{:asdf3.2}.
4984 @menu
4985 * What are ASDF 1 2 3?::
4986 * How do I detect the ASDF version?::
4987 * ASDF can portably name files in subdirectories::
4988 * Output translations::
4989 * Source Registry Configuration::
4990 * Usual operations are made easier to the user::
4991 * Many bugs have been fixed::
4992 * ASDF itself is versioned::
4993 * ASDF can be upgraded::
4994 * Decoupled release cycle::
4995 * Pitfalls of the transition to ASDF 2::
4996 * Pitfalls of the upgrade to ASDF 3::
4997 * What happened to the bundle operations::
4998 @end menu
5000 @node What are ASDF 1 2 3?, How do I detect the ASDF version?, What has changed between ASDF 1 ASDF 2 and ASDF 3?, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5001 @subsection What are ASDF 1, ASDF 2, and ASDF 3?
5003 ASDF 1 refers to any release earlier than 1.369 or so (from August 2001 to October 2009),
5004 and to any development revision earlier than 2.000 (May 2010).
5005 If your copy of ASDF doesn't even contain version information, it's an old ASDF 1.
5006 Revisions between 1.656 and 1.728 may count as development releases for ASDF 2.
5008 ASDF 2 refers to releases from 2.000 (May 31st 2010) to 2.26 (Oct 30th 2012),
5009 and any development revision newer than ASDF 1 and older than 2.27 (Feb 1st 2013).
5011 ASDF 3 refers to releases from 2.27 (Feb 1st 2013) to 2.33 and 3.0.0 onward (May 15th 2013).
5012 2.27 to 2.33 count as pre-releases to ASDF 3.
5014 ASDF 3.1 refers to releases from 3.1.2 (May 6th 2014) onward.
5015 These releases are also considered part of ASDF 3.
5017 @node How do I detect the ASDF version?, ASDF can portably name files in subdirectories, What are ASDF 1 2 3?, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5018 @subsection How do I detect the ASDF version?
5019 @findex asdf-version
5020 @cindex *features*
5022 All releases of ASDF
5023 push @code{:asdf} onto @code{*features*}.
5024 Releases starting with ASDF 2
5025 push @code{:asdf2} onto @code{*features*}.
5026 Releases starting with ASDF 3 (including 2.27 and later pre-releases)
5027 push @code{:asdf3} onto @code{*features*}.
5028 Furthermore, releases starting with ASDF 3.1.2 (May 2014),
5029 though they count as ASDF 3, include enough progress that they
5030 also push @code{:asdf3.1} onto @code{*features*}.
5031 You may depend on the presence or absence of these features
5032 to write code that takes advantage of recent ASDF functionality
5033 but still works on older versions, or at least detects the old version and signals an error.
5035 Additionally, all releases starting with ASDF 2
5036 define a function @code{(asdf:asdf-version)} you may use to query the version.
5037 All releases starting with 2.013 display the version number prominently
5038 on the second line of the @file{asdf.lisp} source file.
5040 If you are experiencing problems or limitations of any sort with ASDF 1 or ASDF 2,
5041 we recommend that you should upgrade to the latest release, be it ASDF 3 or other.
5043 Finally, here is a code snippet to programmatically determine what version of ASDF is loaded, if any,
5044 that works on all versions including very old ones:
5046 @lisp
5047 (when (find-package :asdf)
5048   (let ((ver (symbol-value
5049                    (or (find-symbol (string :*asdf-version*) :asdf)
5050                        (find-symbol (string :*asdf-revision*) :asdf)))))
5051     (etypecase ver
5052       (string ver)
5053       (cons (with-output-to-string (s)
5054               (loop for (n . m) on ver
5055                     do (princ n s)
5056                        (when m (princ "." s)))))
5057       (null "1.0"))))
5058 @end lisp
5060 If it returns @code{nil} then ASDF is not installed.
5061 Otherwise it should return a string.
5062 If it returns @code{"1.0"}, then it can actually be
5063 any version before 1.77 or so, or some buggy variant of 1.x.
5064 If it returns anything older than @code{"3.0.1"},
5065 you really need to upgrade your implementation or at least upgrade its ASDF.
5066 @xref{Replacing your implementation's ASDF}.
5070 @node ASDF can portably name files in subdirectories, Output translations, How do I detect the ASDF version?, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5071 @subsection ASDF can portably name files in subdirectories
5073 Common Lisp namestrings are not portable,
5074 except maybe for logical pathname namestrings,
5075 that themselves have various limitations and require a lot of setup
5076 that is itself ultimately non-portable.
5078 In ASDF 1, the only portable ways to refer to pathnames inside systems and components
5079 were very awkward, using @code{#.(make-pathname ...)} and
5080 @code{#.(merge-pathnames ...)}.
5081 Even the above were themselves were inadequate in the general case
5082 due to host and device issues, unless horribly complex patterns were used.
5083 Plenty of simple cases that looked portable actually weren't,
5084 leading to much confusion and greavance.
5086 ASDF 2 implements its own portable syntax for strings as pathname specifiers.
5087 Naming files within a system definition becomes easy and portable again.
5088 @xref{Miscellaneous additional functionality,system-relative-pathname},
5089 @code{merge-pathnames*},
5090 @code{coerce-pathname}.
5092 On the other hand, there are places where systems used to accept namestrings
5093 where you must now use an explicit pathname object:
5094 @code{(defsystem ... :pathname "LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
5095 must now be written with the @code{#p} syntax:
5096 @code{(defsystem ... :pathname #p"LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
5098 @xref{The defsystem grammar,,Pathname specifiers}.
5101 @node Output translations, Source Registry Configuration, ASDF can portably name files in subdirectories, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5102 @subsection Output translations
5104 A popular feature added to ASDF was output pathname translation:
5105 @code{asdf-binary-locations}, @code{common-lisp-controller},
5106 @code{cl-launch} and other hacks were all implementing it in ways
5107 both mutually incompatible and difficult to configure.
5109 Output pathname translation is essential to share
5110 source directories of portable systems across multiple implementations
5111 or variants thereof,
5112 or source directories of shared installations of systems across multiple users,
5113 or combinations of the above.
5115 In ASDF 2, a standard mechanism is provided for that,
5116 @code{asdf-output-translations},
5117 with sensible defaults, adequate configuration languages,
5118 a coherent set of configuration files and hooks,
5119 and support for non-Unix platforms.
5121 @xref{Controlling where ASDF saves compiled files}.
5123 @node Source Registry Configuration, Usual operations are made easier to the user, Output translations, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5124 @subsection Source Registry Configuration
5126 Configuring ASDF used to require special magic
5127 to be applied just at the right moment,
5128 between the moment ASDF is loaded and the moment it is used,
5129 in a way that is specific to the user,
5130 the implementation he is using and the application he is building.
5132 This made for awkward configuration files and startup scripts
5133 that could not be shared between users, managed by administrators
5134 or packaged by distributions.
5136 ASDF 2 provides a well-documented way to configure ASDF,
5137 with sensible defaults, adequate configuration languages,
5138 and a coherent set of configuration files and hooks.
5140 We believe it's a vast improvement because it decouples
5141 application distribution from library distribution.
5142 The application writer can avoid thinking where the libraries are,
5143 and the library distributor (dpkg, clbuild, advanced user, etc.)
5144 can configure them once and for every application.
5145 Yet settings can be easily overridden where needed,
5146 so whoever needs control has exactly as much as required.
5148 At the same time, ASDF 2 remains compatible
5149 with the old magic you may have in your build scripts
5150 (using @code{*central-registry*} and
5151 @code{*system-definition-search-functions*})
5152 to tailor the ASDF configuration to your build automation needs,
5153 and also allows for new magic, simpler and more powerful magic.
5155 @xref{Controlling where ASDF searches for systems}.
5158 @node Usual operations are made easier to the user, Many bugs have been fixed, Source Registry Configuration, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5159 @subsection Usual operations are made easier to the user
5161 In ASDF 1, you had to use the awkward syntax
5162 @code{(asdf:oos 'asdf:load-op :foo)}
5163 to load a system,
5164 and similarly for @code{compile-op}, @code{test-op}.
5166 In ASDF 2, you can use shortcuts for the usual operations:
5167 @code{(asdf:load-system :foo)}, and
5168 similarly for @code{compile-system}, @code{test-system}.
5171 @node Many bugs have been fixed, ASDF itself is versioned, Usual operations are made easier to the user, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5172 @subsection Many bugs have been fixed
5174 The following issues and many others have been fixed:
5176 @itemize
5177 @item
5178 The infamous TRAVERSE function has been revamped completely
5179 between ASDF 1 and ASDF 2, with many bugs squashed.
5180 In particular, dependencies were not correctly propagated
5181 across modules but now are.
5182 It has been completely rewritten many times over
5183 between ASDF 2.000 and ASDF 3,
5184 with fundamental issues in the original model being fixed.
5185 Timestamps were not propagated at all, and now are.
5186 The internal model of how actions depend on each other
5187 is now both consistent and complete.
5188 The @code{:version} and
5189 the @code{:force (system1 .. systemN)} feature have been fixed.
5191 @item
5192 Performance has been notably improved for large systems
5193 (say with thousands of components) by using
5194 hash-tables instead of linear search,
5195 and linear-time list accumulation instead of cubic time recursive append,
5196 for an overall @emph{O(n)} complexity vs @emph{O(n^4)}.
5198 @item
5199 Many features used to not be portable,
5200 especially where pathnames were involved.
5201 Windows support was notably quirky because of such non-portability.
5203 @item
5204 The internal test suite used to massively fail on many implementations.
5205 While still incomplete, it now fully passes
5206 on all implementations supported by the test suite,
5207 though some tests are commented out on a few implementations.
5209 @item
5210 Support was lacking for some implementations.
5211 ABCL and GCL were notably wholly broken.
5212 ECL extensions were not integrated with ASDF release.
5214 @item
5215 The documentation was grossly out of date.
5217 @end itemize
5220 @node ASDF itself is versioned, ASDF can be upgraded, Many bugs have been fixed, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5221 @subsection ASDF itself is versioned
5223 Between new features, old bugs fixed, and new bugs introduced,
5224 there were various releases of ASDF in the wild,
5225 and no simple way to check which release had which feature set.
5226 People using or writing systems had to either make worst-case assumptions
5227 as to what features were available and worked,
5228 or take great pains to have the correct version of ASDF installed.
5230 With ASDF 2, we provide a new stable set of working features
5231 that everyone can rely on from now on.
5232 Use @code{#+asdf2} to detect presence of ASDF 2,
5233 @code{(asdf:version-satisfies (asdf:asdf-version) "2.345.67")}
5234 to check the availability of a version no earlier than required.
5237 @node ASDF can be upgraded, Decoupled release cycle, ASDF itself is versioned, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5238 @subsection ASDF can be upgraded
5240 When an old version of ASDF was loaded,
5241 it was very hard to upgrade ASDF in your current image
5242 without breaking everything.
5243 Instead you had to exit the Lisp process and
5244 somehow arrange to start a new one from a simpler image.
5245 Something that can't be done from within Lisp,
5246 making automation of it difficult,
5247 which compounded with difficulty in configuration,
5248 made the task quite hard.
5249 Yet as we saw before, the task would have been required
5250 to not have to live with the worst case or non-portable
5251 subset of ASDF features.
5253 With ASDF 2, it is easy to upgrade
5254 from ASDF 2 to later versions from within Lisp,
5255 and not too hard to upgrade from ASDF 1 to ASDF 2 from within Lisp.
5256 We support hot upgrade of ASDF and any breakage is a bug
5257 that we will do our best to fix.
5258 There are still limitations on upgrade, though,
5259 most notably the fact that after you upgrade ASDF,
5260 you must also reload or upgrade all ASDF extensions.
5262 @node Decoupled release cycle, Pitfalls of the transition to ASDF 2, ASDF can be upgraded, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5263 @subsection Decoupled release cycle
5265 When vendors were releasing their Lisp implementations with ASDF,
5266 they had to basically never change version
5267 because neither upgrade nor downgrade was possible
5268 without breaking something for someone,
5269 and no obvious upgrade path was visible and recommendable.
5271 With ASDF 2, upgrade is possible, easy and can be recommended.
5272 This means that vendors can safely ship a recent version of ASDF,
5273 confident that if a user isn't fully satisfied,
5274 he can easily upgrade ASDF and deal
5275 with a supported recent version of it.
5276 This means that release cycles will be causally decoupled,
5277 the practical consequence of which will mean faster convergence
5278 towards the latest version for everyone.
5281 @node Pitfalls of the transition to ASDF 2, Pitfalls of the upgrade to ASDF 3, Decoupled release cycle, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5282 @subsection Pitfalls of the transition to ASDF 2
5284 The main pitfalls in upgrading to ASDF 2 seem to be related
5285 to the output translation mechanism.
5287 @itemize
5289 @item
5290 Output translations is enabled by default. This may surprise some users,
5291 most of them in pleasant way (we hope), a few of them in an unpleasant way.
5292 It is trivial to disable output translations.
5293 @xref{FAQ,,``How can I wholly disable the compiler output cache?''}.
5295 @item
5296 Some systems in the large have been known
5297 not to play well with output translations.
5298 They were relatively easy to fix.
5299 Once again, it is also easy to disable output translations,
5300 or to override its configuration.
5302 @item
5303 The new ASDF output translations are incompatible with ASDF-Binary-Locations.
5304 They replace A-B-L, and there is compatibility mode to emulate
5305 your previous A-B-L configuration.
5306 See @code{enable-asdf-binary-locations-compatibility} in
5307 @pxref{Controlling where ASDF saves compiled files,,Backward Compatibility}.
5308 But thou shalt not load ABL on top of ASDF 2.
5310 @end itemize
5312 Other issues include the following:
5314 @itemize
5316 @item
5317 ASDF pathname designators are now specified
5318 in places where they were unspecified,
5319 and a few small adjustments have to be made to some non-portable defsystems.
5320 Notably, in the @code{:pathname} argument
5321 to a @code{defsystem} and its components,
5322 a logical pathname (or implementation-dependent hierarchical pathname)
5323 must now be specified with @code{#p} syntax
5324 where the namestring might have previously sufficed;
5325 moreover when evaluation is desired @code{#.} must be used,
5326 where it wasn't necessary in the toplevel @code{:pathname} argument
5327 (but necessary in other @code{:pathname} arguments).
5329 @item
5330 There is a slight performance bug, notably on SBCL,
5331 when initially searching for @file{asd} files,
5332 the implicit @code{(directory "/configured/path/**/*.asd")}
5333 for every configured path @code{(:tree "/configured/path/")}
5334 in your @code{source-registry} configuration can cause a slight pause.
5335 Try to @code{(time (asdf:initialize-source-registry))}
5336 to see how bad it is or isn't on your system.
5337 If you insist on not having this pause,
5338 you can avoid the pause by overriding the default source-registry configuration
5339 and not use any deep @code{:tree} entry but only @code{:directory} entries
5340 or shallow @code{:tree} entries.
5341 Or you can fix your implementation to not be quite that slow
5342 when recursing through directories.
5343 @emph{Update}: This performance bug fixed the hard way in 2.010.
5345 @item
5346 On Windows, only LispWorks supports proper default configuration pathnames
5347 based on the Windows registry.
5348 Other implementations make do with environment variables,
5349 that you may have to define yourself
5350 if you're using an older version of Windows.
5351 Windows support is somewhat less tested than Unix support.
5352 Please help report and fix bugs.
5353 @emph{Update}: As of ASDF 2.21, all implementations
5354 should now use the same proper default configuration pathnames
5355 and they should actually work, though they haven't all been tested.
5357 @item
5358 The mechanism by which one customizes a system so that Lisp files
5359 may use a different extension from the default @file{.lisp} has changed.
5360 Previously, the pathname for a component
5361 was lazily computed when operating on a system,
5362 and you would
5363 @code{(defmethod source-file-type ((component cl-source-file) (system (eql (find-system 'foo))))
5364   (declare (ignorable component system)) "lis")}.
5365 Now, the pathname for a component is eagerly computed when defining the system,
5366 and instead you will @code{(defclass cl-source-file.lis (cl-source-file) ((type :initform "lis")))}
5367 and use @code{:default-component-class cl-source-file.lis}
5368 as argument to @code{defsystem},
5369 as detailed in a @pxref{FAQ,How do I create a system definition where all the source files have a .cl extension?} below.
5370 @code{source-file-type} is deprecated.  To access a component's
5371 file-type, use @code{file-type}, instead.  @code{source-file-type} will
5372 be removed.
5374 @findex source-file-type
5375 @findex file-type
5377 @end itemize
5380 @node Pitfalls of the upgrade to ASDF 3, What happened to the bundle operations, Pitfalls of the transition to ASDF 2, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5381 @subsection Pitfalls of the upgrade to ASDF 3
5383 While ASDF 3 is largely compatible with ASDF 2,
5384 there are a few pitfalls when upgrading from ASDF 2,
5385 due to limitations in ASDF 2.
5387 @itemize
5389 @item
5390 ASDF 2 was designed so it could be upgraded;
5391 but upgrading it required a special setup at the beginning of your build files.
5392 Failure to upgrade it early could result in catastrophic attempt to self-upgrade in mid-build.
5394 @item
5395 Starting with ASDF 3 (2.27 or later),
5396 ASDF will automatically attempt to upgrade itself
5397 as the first step before any system operation,
5398 to avoid any possibility of such catastrophic mid-build self-upgrade.
5399 But that doesn't help if your old implementation still provides ASDF 2.
5401 @item
5402 It was unsafe in ASDF 2 for a system definition to declare a dependency on ASDF,
5403 since it could trigger such catastrophe for users who were not carefully configured.
5404 If you declare a dependency on a recent enough ASDF,
5405 yet want to be nice with these potentially misconfigured users,
5406 we recommend that you not only specify a recent ASDF in your dependencies with
5407 @code{:depends-on ((:version "asdf" "3.1.2"))},
5408 but that you @emph{also} check that ASDF 3 is installed,
5409 or else the upgrade catastrophe might happen before that specification is checked,
5410 by starting your @file{.asd} file with a version check as follows:
5411 @example
5412 #-asdf3 (error "@var{MY-SYSTEM} requires ASDF 3.1.2")
5413 @end example
5415 @item
5416 When you upgrade from too old a version of ASDF,
5417 previously loaded ASDF extensions become invalid, and will need to be reloaded.
5418 Example extensions include CFFI-Grovel, hacks used by ironclad, etc.
5419 Since it isn't possible to automatically detect what extensions
5420 need to be invalidated and what systems use them,
5421 ASDF will invalidate @emph{all} previously loaded systems
5422 when it is loaded on top of a forward-incompatible ASDF version.
5423 @footnote{
5424 @vindex *oldest-forward-compatible-asdf-version*
5425 Forward incompatibility can be determined using the variable
5426 @code{asdf/upgrade::*oldest-forward-compatible-asdf-version*},
5427 which is 2.33 at the time of this writing.}
5429 @item
5430 To write a portable build script, you need to rely on a recent version of UIOP,
5431 but until you have ensured a recent ASDF is loaded,
5432 you can't rely on UIOP being present,
5433 and thus must manually avoid all the pathname pitfalls when loading ASDF itself.
5435 @item
5436 Bugs in CMUCL and XCL prevent upgrade of ASDF from an old forward-incompatible version.
5437 Happily, CMUCL comes with a recent ASDF,
5438 and XCL is more of a working demo than something you'd use seriously anyway.
5440 @item
5441 For the above reasons, your build and startup scripts
5442 should load, configure and upgrade ASDF among the very first things they do,
5443 and ensure that ASDF 3 or later is present indeed,
5444 before they start using ASDF to load anything else.
5446 @item
5447 Now that all implementations provide ASDF 3 or later (since May 2015),
5448 the simple solution is just to use code as below in your setup,
5449 and when it fails, upgrade your implementation or replace its ASDF.
5450 (@pxref{Replacing your implementation's ASDF}):
5451 @example
5452 (require "asdf")
5453 #-asdf3 (error "ASDF 3 or bust")
5454 @end example
5456 @item
5457 For scripts that try to use ASDF simply via @code{require} at first, and
5458 make heroic attempts to load it the hard way if at first they don't succeed,
5459 see @file{tools/load-asdf.lisp} distributed with the ASDF source repository,
5460 or the code of @url{https://cliki.net/cl-launch,@code{cl-launch}}.
5462 @item
5463 Note that in addition to the pitfalls and constraints above,
5464 these heroic scripts (should you wish to write or modify one),
5465 must take care to configure ASDF @emph{twice}.
5466 One first time, right after you load the old ASDF 2 and before you upgrade to the new ASDF 3,
5467 so it may find where you put ASDF 3.
5468 One second time, because some implementations can't handle a smooth upgrade to ASDF 3,
5469 and lose configuration as they do.
5470 @lisp
5471 (require "asdf")
5472 ;; <--- insert heroics here, if that failed to provide ASDF 2 or 3
5473 ;; <--- insert configuration here, if that succeeded
5474 (asdf:load-system "asdf")
5475 ;; <--- re-configure here, too, in case at first you got ASDF 2
5476 @end lisp
5478 @end itemize
5481 @node What happened to the bundle operations,  , Pitfalls of the upgrade to ASDF 3, What has changed between ASDF 1 ASDF 2 and ASDF 3?
5482 @subsection What happened to the bundle operations?
5484 @tindex fasl-op (obsolete)
5485 @tindex load-fasl-op (obsolete)
5486 @tindex binary-op (obsolete)
5487 @tindex monolithic-fasl-op (obsolete)
5488 @tindex monolithic-load-fasl-op (obsolete)
5489 @tindex monolithic-binary-op (obsolete)
5490 @tindex compile-bundle-op
5491 @tindex load-bundle-op
5492 @tindex deliver-asd-op
5493 @tindex monolithic-compile-bundle-op
5494 @tindex monolithic-load-bundle-op
5495 @tindex monolithic-deliver-asd-op
5497 @code{asdf-ecl} and its short-lived successor @code{asdf-bundle} are no more,
5498 having been replaced by code now built into ASDF 3.
5499 Moreover, the name of the bundle operations has changed since ASDF 3.1.3.
5500 @xref{What happened to the bundle operations}.
5502 And yet, the feature is not enabled to be used by @code{load-system} by default on ECL as originally intended,
5503 because of a bug in ECL itself found during testing.
5506 Some of the bundle operations were renamed after ASDF 3.1.3, and the old
5507 names have been removed.  Old bundle operations, and their modern
5508 equivalents are:
5510 @itemize
5511 @item
5512 @code{fasl-op} is now @code{compile-bundle-op}
5513 @item
5514 @code{load-fasl-op} is now @code{load-bundle-op}
5515 @item
5516 @code{binary-op} is now @code{deliver-asd-op}
5517 @item
5518 @code{monolithic-fasl-op} is now @code{monolithic-compile-bundle-op}
5519 @item
5520 @code{monolithic-load-fasl-op} is now @code{monolithic-load-bundle-op}
5521 @item
5522 @code{monolithic-binary-op} is now @code{monolithic-deliver-asd-op}
5523 @end itemize
5527 @node Issues with installing the proper version of ASDF, Issues with configuring ASDF, What has changed between ASDF 1 ASDF 2 and ASDF 3?, FAQ
5528 @section Issues with installing the proper version of ASDF
5530 @menu
5531 * My Common Lisp implementation comes with an outdated version of ASDF. What to do?::
5532 * I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?::
5533 @end menu
5535 @node My Common Lisp implementation comes with an outdated version of ASDF. What to do?, I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?, Issues with installing the proper version of ASDF, Issues with installing the proper version of ASDF
5536 @subsection ``My Common Lisp implementation comes with an outdated version of ASDF. What to do?''
5538 If you have a recent implementation, it should already come with ASDF 3 or later.
5539 If you need a more recent version than is provided,
5540 we recommend you simply upgrade ASDF by installing a recent version
5541 in a path configured in your source-registry.
5542 @xref{Upgrading ASDF}.
5544 If you have an old implementation that does not provide ASDF 3,
5545 we recommend you replace your implementation's ASDF.
5546 @xref{Replacing your implementation's ASDF}.
5549 @node I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?,  , My Common Lisp implementation comes with an outdated version of ASDF. What to do?, Issues with installing the proper version of ASDF
5550 @subsection ``I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?''
5552 Since ASDF 2,
5553 it should always be a good time to upgrade to a recent version of ASDF.
5554 You may consult with the maintainer for which specific version they recommend,
5555 but the latest @code{release} should be correct.
5556 Though we do try to test ASDF releases against all implementations that we can,
5557 we may not be testing against all variants of your implementation,
5558 and we may not be running enough tests;
5559 we trust you to thoroughly test it with your own implementation
5560 before you release it.
5561 If there are any issues with the current release,
5562 it's a bug that you should report upstream and that we will fix ASAP.
5564 As to how to include ASDF, we recommend the following:
5566 @itemize
5567 @item
5568 If ASDF isn't loaded yet, then @code{(require "asdf")}
5569 should load the version of ASDF that is bundled with your system.
5570 If possible so should @code{(require "ASDF")}.
5571 You may have it load some other version configured by the user,
5572 if you allow such configuration.
5574 @item
5575 If your system provides a mechanism to hook into @code{cl:require},
5576 then it would be nice to add ASDF to this hook the same way that
5577 ABCL, CCL, CLISP, CMUCL, ECL, SBCL and SCL do it.
5578 Please send us appropriate code to this end.
5580 @item
5581 You may, like SBCL since 1.1.13 or MKCL since 1.1.9,
5582 have ASDF create bundle FASLs
5583 that are provided as modules by your Lisp distribution.
5584 You may also, but we don't recommend that anymore,
5585 as in SBCL up until 1.1.12, have ASDF be implicitly used
5586 to @code{cl:require} these modules that are provided by your Lisp distribution;
5587 if you do, you should add these modules in the beginning of both
5588 @code{wrapping-source-registry} and @code{wrapping-output-translations}.
5590 @item
5591 If you have magic systems as above, like SBCL used to do,
5592 then we explicitly ask you to @emph{NOT} distribute
5593 @file{asdf.asd} as part of those magic systems.
5594 You should still include the file @file{asdf.lisp} in your source distribution
5595 and precompile it in your binary distribution,
5596 but @file{asdf.asd} if included at all,
5597 should be secluded from the magic systems,
5598 in a separate file hierarchy.
5599 Alternatively, you may provide the system
5600 after renaming it and its @file{.asd} file to e.g.
5601 @code{asdf-ecl} and @file{asdf-ecl.asd}, or
5602 @code{sb-asdf} and @file{sb-asdf.asd}.
5603 Indeed, if you made @file{asdf.asd} a magic system,
5604 then users would no longer be able to upgrade ASDF using ASDF itself
5605 to some version of their preference that
5606 they maintain independently from your Lisp distribution.
5608 @item
5609 If you do not have any such magic systems, or have other non-magic systems
5610 that you want to bundle with your implementation,
5611 then you may add them to the @code{wrapping-source-registry},
5612 and you are welcome to include @file{asdf.asd} amongst them.
5613 Non-magic systems should be at the back of the @code{wrapping-source-registry}
5614 while magic systems are at the front.
5615 If they are precompiled,
5616 they should also be in the @code{wrapping-output-translations}.
5618 @item
5619 Since ASDF 3, the library UIOP comes transcluded in ASDF.
5620 But if you want to be nice to users who care for UIOP but not for ASDF,
5621 you may package UIOP separately,
5622 so that one may @code{(require "uiop")} and not load ASDF,
5623 or one may @code{(require "asdf")}
5624 which would implicitly require and load the former.
5626 @item
5627 Please send us upstream any patches you make to ASDF itself,
5628 so we can merge them back in for the benefit of your users
5629 when they upgrade to the upstream version.
5631 @end itemize
5635 @node Issues with configuring ASDF, Issues with using and extending ASDF to define systems, Issues with installing the proper version of ASDF, FAQ
5636 @section Issues with configuring ASDF
5638 @menu
5639 * How can I customize where fasl files are stored?::
5640 * How can I wholly disable the compiler output cache?::
5641 @end menu
5643 @node How can I customize where fasl files are stored?, How can I wholly disable the compiler output cache?, Issues with configuring ASDF, Issues with configuring ASDF
5644 @subsection ``How can I customize where fasl files are stored?''
5646 @xref{Controlling where ASDF saves compiled files}.
5648 Note that in the past there was an add-on to ASDF called
5649 @code{ASDF-binary-locations}, developed by Gary King.
5650 That add-on has been merged into ASDF proper,
5651 then superseded by the @code{asdf-output-translations} facility.
5653 Note that use of @code{asdf-output-translations}
5654 can interfere with one aspect of your systems
5655 --- if your system uses @code{*load-truename*} to find files
5656 (e.g., if you have some data files stored with your program),
5657 then the relocation that this ASDF customization performs
5658 is likely to interfere.
5659 Use @code{asdf:system-relative-pathname} to locate a file
5660 in the source directory of some system, and
5661 use @code{asdf:apply-output-translations} to locate a file
5662 whose pathname has been translated by the facility.
5664 @node How can I wholly disable the compiler output cache?,  , How can I customize where fasl files are stored?, Issues with configuring ASDF
5665 @subsection ``How can I wholly disable the compiler output cache?''
5667 To permanently disable the compiler output cache
5668 for all future runs of ASDF, you can:
5670 @example
5671 mkdir -p ~/.config/common-lisp/asdf-output-translations.conf.d/
5672 echo ':disable-cache' > \
5673 ~/.config/common-lisp/asdf-output-translations.conf.d/99-disable-cache.conf
5674 @end example
5676 This assumes that you didn't otherwise configure the ASDF files
5677 (if you did, edit them again),
5678 and don't somehow override the configuration at runtime
5679 with a shell variable (see below) or some other runtime command
5680 (e.g. some call to @code{asdf:initialize-output-translations}).
5682 To disable the compiler output cache in Lisp processes
5683 run by your current shell, try (assuming @code{bash} or @code{zsh})
5684 (on Unix and cygwin only):
5686 @example
5687 export ASDF_OUTPUT_TRANSLATIONS=/:
5688 @end example
5690 To disable the compiler output cache just in the current Lisp process,
5691 use (after loading ASDF but before using it):
5693 @example
5694 (asdf:disable-output-translations)
5695 @end example
5697 Note that this does @emph{NOT} belong in a @file{.asd} file.
5698 Please do not tamper with ASDF configuration from a @file{.asd} file,
5699 and only do this from your personal configuration or build scripts.
5701 @node Issues with using and extending ASDF to define systems, ASDF development FAQs, Issues with configuring ASDF, FAQ
5702 @section Issues with using and extending ASDF to define systems
5704 @menu
5705 * How can I cater for unit-testing in my system?::
5706 * How can I cater for documentation generation in my system?::
5707 * How can I maintain non-Lisp (e.g. C) source files?::
5708 * I want to put my module's files at the top level.  How do I do this?::
5709 * How do I create a system definition where all the source files have a .cl extension?::
5710 * How do I mark a source file to be loaded only and not compiled?::
5711 * How do I work with readtables?::
5712 @end menu
5714 @node How can I cater for unit-testing in my system?, How can I cater for documentation generation in my system?, Issues with using and extending ASDF to define systems, Issues with using and extending ASDF to define systems
5715 @subsection ``How can I cater for unit-testing in my system?''
5717 ASDF provides a predefined test operation, @code{test-op}.
5718 @xref{Predefined operations of ASDF, test-op}.
5719 The test operation, however, is largely left to the system definer to specify.
5720 @code{test-op} has been
5721 a topic of considerable discussion on the
5722 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
5723 (@pxref{Mailing list}),
5724 and on the
5725 @url{https://launchpad.net/asdf,launchpad bug-tracker} (@pxref{Where do I report a bug?}).
5726 We provide some guidelines in the discussion of @code{test-op}.
5728 @c cut the following because it's discussed in the discussion of test-op.
5729 @c Here are some guidelines:
5731 @c @itemize
5732 @c @item
5733 @c For a given system, @var{foo}, you will want to define a corresponding
5734 @c test system, such as @var{foo-test}.  The reason that you will want this
5735 @c separate system is that ASDF does not out of the box supply components
5736 @c that are conditionally loaded.  So if you want to have source files
5737 @c (with the test definitions) that will not be loaded except when testing,
5738 @c they should be put elsewhere.
5740 @c @item
5741 @c The @var{foo-test} system can be defined in an asd file of its own or
5742 @c together with @var{foo}.  An aesthetic preference against cluttering up
5743 @c the filesystem with extra asd files should be balanced against the
5744 @c question of whether one might want to directly load @var{foo-test}.
5745 @c Typically one would not want to do this except in early stages of
5746 @c debugging.
5748 @c @item
5749 @c Record that testing is implemented by @var{foo-test}.  For example:
5750 @c @example
5751 @c (defsystem @var{foo}
5752 @c    :in-order-to ((test-op (test-op @var{foo-test})))
5753 @c    ....)
5755 @c (defsystem @var{foo-test}
5756 @c    :depends-on (@var{foo} @var{my-test-library} ...)
5757 @c    ....)
5758 @c @end example
5759 @c @end itemize
5761 @c This procedure will allow you to support users who do not wish to
5762 @c install your test framework.
5764 @c One oddity of ASDF is that @code{operate} (@pxref{Operations,operate})
5765 @c does not return a value.  So in current versions of ASDF there is no
5766 @c reliable programmatic means of determining whether or not a set of tests
5767 @c has passed, or which tests have failed.  The user must simply read the
5768 @c console output.  This limitation has been the subject of much
5769 @c discussion.
5771 @node How can I cater for documentation generation in my system?, How can I maintain non-Lisp (e.g. C) source files?, How can I cater for unit-testing in my system?, Issues with using and extending ASDF to define systems
5772 @subsection ``How can I cater for documentation generation in my system?''
5774 Various ASDF extensions provide some kind of @code{doc-op} operation.
5775 See also @url{https://bugs.launchpad.net/asdf/+bug/479470}.
5778 @node How can I maintain non-Lisp (e.g. C) source files?, I want to put my module's files at the top level.  How do I do this?, How can I cater for documentation generation in my system?, Issues with using and extending ASDF to define systems
5779 @subsection ``How can I maintain non-Lisp (e.g. C) source files?''
5781 See @code{cffi}'s @code{cffi-grovel}.
5783 @anchor{report-bugs}
5786 @node I want to put my module's files at the top level.  How do I do this?, How do I create a system definition where all the source files have a .cl extension?, How can I maintain non-Lisp (e.g. C) source files?, Issues with using and extending ASDF to define systems
5787 @subsection ``I want to put my module's files at the top level.  How do I do this?''
5789 By default, the files contained in an asdf module go
5790 in a subdirectory with the same name as the module.
5791 However, this can be overridden by adding a @code{:pathname ""} argument
5792 to the module description.
5793 For example, here is how it could be done
5794 in the spatial-trees ASDF system definition for ASDF 2 or later:
5796 @example
5797 (asdf:defsystem "spatial-trees"
5798   :components
5799   ((:module "base"
5800             :pathname ""
5801             :components
5802             ((:file "package")
5803              (:file "basedefs" :depends-on ("package"))
5804              (:file "rectangles" :depends-on ("package"))))
5805    (:module tree-impls
5806             :depends-on ("base")
5807             :pathname ""
5808             :components
5809             ((:file "r-trees")
5810              (:file "greene-trees" :depends-on ("r-trees"))
5811              (:file "rstar-trees" :depends-on ("r-trees"))
5812              (:file "rplus-trees" :depends-on ("r-trees"))
5813              (:file "x-trees" :depends-on ("r-trees" "rstar-trees"))))
5814    (:module viz
5815             :depends-on ("base")
5816             :pathname ""
5817             :components
5818             ((:static-file "spatial-tree-viz.lisp")))
5819    (:module tests
5820             :depends-on ("base")
5821             :pathname ""
5822             :components
5823             ((:static-file "spatial-tree-test.lisp")))
5824    (:static-file "LICENCE")
5825    (:static-file "TODO")))
5826 @end example
5828 All of the files in the @code{tree-impls} module are at the top level,
5829 instead of in a @file{tree-impls/} subdirectory.
5831 Note that the argument to @code{:pathname} can be either a pathname object or a string.
5832 A pathname object can be constructed with the @file{#p"foo/bar/"} syntax,
5833 but this is discouraged because the results of parsing a namestring are not portable.
5834 A pathname can only be portably constructed with such syntax as
5835 @code{#.(make-pathname :directory '(:relative "foo" "bar"))},
5836 and similarly the current directory can only be portably specified as
5837 @code{#.(make-pathname :directory '(:relative))}.
5838 However, as of ASDF 2, you can portably use a string to denote a pathname.
5839 The string will be parsed as a @code{/}-separated path from the current directory,
5840 such that the empty string @code{""} denotes the current directory, and
5841 @code{"foo/bar"} (no trailing @code{/} required in the case of modules)
5842 portably denotes the same subdirectory as above.
5843 When files are specified, the last @code{/}-separated component is interpreted
5844 either as the name component of a pathname
5845 (if the component class specifies a pathname type),
5846 or as a name component plus optional dot-separated type component
5847 (if the component class doesn't specifies a pathname type).
5849 @node How do I create a system definition where all the source files have a .cl extension?, How do I mark a source file to be loaded only and not compiled?, I want to put my module's files at the top level.  How do I do this?, Issues with using and extending ASDF to define systems
5850 @subsection How do I create a system definition where all the source files have a .cl extension?
5852 Starting with ASDF 2.014.14, you may just pass
5853 the builtin class @code{cl-source-file.cl} as
5854 the @code{:default-component-class} argument to @code{defsystem}:
5856 @lisp
5857 (defsystem my-cl-system
5858   :default-component-class cl-source-file.cl
5859   ...)
5860 @end lisp
5862 Another builtin class @code{cl-source-file.lsp} is offered
5863 for files ending in @file{.lsp}.
5865 If you want to use a different extension
5866 for which ASDF doesn't provide builtin support,
5867 or want to support versions of ASDF
5868 earlier than 2.014.14 (but later than 2.000),
5869 you can define a class as follows:
5871 @lisp
5872 ;; Prologue: make sure we're using a sane package.
5873 (defpackage :my-asdf-extension
5874    (:use :asdf :common-lisp)
5875    (:export #:cl-source-file.lis))
5876 (in-package :my-asdf-extension)
5878 (defclass cl-source-file.lis (cl-source-file)
5879   ((type :initform "lis")))
5880 @end lisp
5882 Then you can use it as follows:
5883 @lisp
5884 (defsystem my-cl-system
5885   :default-component-class my-asdf-extension:cl-source-file.lis
5886   ...)
5887 @end lisp
5889 Of course, if you're in the same package, e.g. in the same file,
5890 you won't need to use the package qualifier before @code{cl-source-file.lis}.
5891 Actually, if all you're doing is defining this class
5892 and using it in the same file without other fancy definitions,
5893 you might skip package complications:
5895 @lisp
5896 (in-package :asdf)
5897 (defclass cl-source-file.lis (cl-source-file)
5898    ((type :initform "lis")))
5899 (defsystem my-cl-system
5900   :default-component-class cl-source-file.lis
5901   ...)
5902 @end lisp
5904 @node How do I mark a source file to be loaded only and not compiled?, How do I work with readtables?, How do I create a system definition where all the source files have a .cl extension?, Issues with using and extending ASDF to define systems
5905 @subsection How do I mark a source file to be loaded only and not compiled?
5907 There is no provision in ASDF for ensuring that
5908 some components are always loaded as source, while others are always
5909 compiled.
5910 There is @code{load-source-op} (@pxref{Predefined operations of
5911 ASDF,load-source-op}), but that is an operation to be applied to a
5912 system as a whole, not to one or another specific source files.
5913 While this idea often comes up in discussions,
5914 it doesn't play well with either the linking model of ECL
5915 or with various bundle operations.
5916 In addition, the dependency model of ASDF would have to be modified incompatibly
5917 to allow for such a trick.
5918 @c If your code doesn't compile cleanly, fix it.
5919 @c If compilation makes it slow, use @code{declaim} or @code{eval-when}
5920 @c to adjust your compiler settings,
5921 @c or eschew compilation by @code{eval}uating a quoted source form at load-time.
5923 @node How do I work with readtables?,  , How do I mark a source file to be loaded only and not compiled?, Issues with using and extending ASDF to define systems
5924 @subsection How do I work with readtables?
5926 @cindex readtables
5928 It is possible to configure the lisp syntax by modifying the currently-active readtable.
5929 However, this same readtable is shared globally by all software being compiled by ASDF,
5930 especially since @code{load} and @code{compile-file} both bind @var{*readtable*},
5931 so that its value is the same across the build at the start of every file
5932 (unless overridden by some @code{perform :around} method),
5933 even if a file locally binds it to a different readtable during the build.
5935 Therefore, the following hygiene restrictions apply. If you don't abide by these restrictions,
5936 there will be situations where your output files will be corrupted during an incremental build.
5937 We are not trying to prescribe new restrictions for the sake of good style:
5938 these restrictions have always applied implicitly, and
5939 we are simply describing what they have always been.
5941 @itemize
5942 @item It is forbidden to modifying any standard character or standard macro dispatch defined in the CLHS.
5943 @item No two dependencies may assign different meanings to the same non-standard character.
5944 @item Using any non-standard character while expecting the implementation to treat some way
5945     counts as such an assignment of meaning.
5946 @item libraries need to document these assignments of meaning to non-standard characters.
5947 @item free software libraries will register these changes on:
5948         @url{http://www.cliki.net/Macro%20Characters}
5949 @end itemize
5951 If you want to use readtable modifications that cannot abide by those restrictions,
5952 you @emph{must} create a different readtable object and set @var{*readtable*}
5953 to temporarily bind it to your new readtable (which will be undone after processing the file).
5955 For that, we recommend you use system @code{named-readtables}
5956 to define or combine such readtables using @code{named-readtables:defreadtable}
5957 and use them using @code{named-readtables:in-readtable}.
5958 Equivalently, you can use system @code{cl-syntax},
5959 that itself uses @code{named-readtables},
5960 but may someday do more with, e.g. @var{*print-pprint-dispatch*}.
5962 For even more advanced syntax modification beyond what a readtable can express,
5963 you may consider either:
5964 @itemize
5965 @item a @code{perform} method that compiles a constant file that contains a single form
5966   @code{#.*code-read-with-alternate-reader*} in an environment where this special variable
5967   was bound to the code read by your alternate reader, or
5968 @item using the system @code{reader-interception}.
5969 @end itemize
5971 Beware that @c unless and until the @code{syntax-control} branch is merged,
5972 it is unsafe to use ASDF from the REPL to compile or load systems
5973 while the readtable isn't the shared readtable previously used to build software.
5974 You @emph{must} manually undo any binding of @var{*readtable*} at the REPL
5975 and restore its initial value whenever you call @code{operate}
5976 (via e.g. @code{load-system}, @code{test-system} or @code{require})
5977 from a REPL that is using a different readtable.
5979 @subsubsection How should my system use a readtable exported by another system?
5981 Use from the @code{named-readtables} system the macro @code{named-readtables:in-readtable}.
5983 If the other system fails to use @code{named-readtables}, fix it and send a patch upstream.
5984 In the day and age of Quicklisp and clbuild, there is little reason
5985 to eschew using such an important library anymore.
5987 @subsubsection How should my library make a readtable available to other systems?
5989 Use from the @code{named-readtables} system the macro @code{named-readtables:defreadtable}.
5991 @node ASDF development FAQs,  , Issues with using and extending ASDF to define systems, FAQ
5992 @section ASDF development FAQs
5994 @menu
5995 * How do run the tests interactively in a REPL?::
5996 @end menu
5998 @node How do run the tests interactively in a REPL?,  , ASDF development FAQs, ASDF development FAQs
5999 @subsection How do run the tests interactively in a REPL?
6001 This not-so-frequently asked question is primarily for ASDF developers,
6002 but those who encounter an unexpected error in some test may be
6003 interested, too.
6005 Here's the procedure for experimenting with tests in a REPL:
6006 @example
6007 ;; BEWARE! Some tests expect you to be in the .../asdf/test directory
6008 ;; If your REPL is not there yet, change your current directory:
6009 ;; under SLIME, you may: ,change-directory ~/common-lisp/asdf/test/
6010 ;; otherwise you may evaluate something like:
6011 (require "asdf") (asdf:upgrade-asdf) ;load UIOP & update asdf.lisp
6012 (uiop:chdir (asdf:system-relative-pathname :asdf "test/"))
6013 (setf *default-pathname-defaults* (uiop:getcwd))
6015 ;; Load the test script support.
6016 (load "script-support.lisp")
6018 ;; Initialize the script support.
6019 ;; This will also change your *package* to asdf-test.
6020 ;; NB: this function is also available from package cl-user,
6021 ;; and also available with the shorter name da in both packages.
6022 (asdf-test::debug-asdf)
6024 ;; In case you modified ASDF since you last tested it,
6025 ;; you need to update asdf.lisp itself by evaluating 'make' in a shell,
6026 ;; or (require "asdf") (asdf:load-system :asdf) in another CL REPL,
6027 ;; if not done in this REPL above.
6028 ;; *Then*, in this REPL, you need to evaluate:
6029 ;(asdf-test::compile-load-asdf)
6031 ;; Now, you may experiment with test code from a .script file.
6032 ;; See the instructions given at the end of your failing test
6033 ;; to identify which form is needed, e.g.
6034 (frob-packages)
6035 (asdf::with-asdf-cache () (load "test-utilities.script"))
6036 @end example
6039 @comment FIXME: Add a FAQ about how to use a new system class...
6041 @comment  node-name,  next,  previous,  up
6042 @node  Ongoing Work, Bibliography, FAQ, Top
6043 @unnumbered Ongoing Work
6044 For an active list of things to be done,
6045 see the @file{TODO} file in the source repository.
6047 Also, bugs are currently tracked on launchpad:
6048 @url{https://launchpad.net/asdf}.
6050 @node Bibliography, Concept Index, Ongoing Work, Top
6051 @unnumbered Bibliography
6053 @itemize
6054 @item Francois-Rene Rideau:
6055   ``ASDF 3, or Why Lisp is Now an Acceptable Scripting Language'', 2014.
6056   This article describes the innovations in ASDF 3 and 3.1,
6057   as well as historical information on previous versions.
6058   @url{https://github.com/fare/asdf3-2013}
6059 @item Alastair Bridgewater:
6060   ``Quick-build'' (private communication), 2012.
6061   @code{quick-build} is a simple and robust one file, one package build system,
6062   similar to @code{faslpath}, in 182 lines of code
6063   (117 of which are not blank, not comments, not docstrings).
6064   Unhappily, it remains unpublished and its IP status is unclear as of April 2014.
6065   @code{asdf/package-system} is mostly compatible with it,
6066   modulo a different setup for toplevel hierarchies.
6067 @item Zach Beane:
6068   ``Quicklisp'', 2011.
6069   The Quicklisp blog and Xach's livejournal contain information on Quicklisp.
6070   @url{http://blog.quicklisp.org/}
6071   @url{http://xach.livejournal.com/}
6072 @item Francois-Rene Rideau and Robert Goldman:
6073   ``Evolving ASDF: More Cooperation, Less Coordination'', 2010.
6074   This article describes the main issues solved by ASDF 2.
6075   @url{https://common-lisp.net/project/asdf/doc/ilc2010draft.pdf}
6076   @url{https://gitlab.common-lisp.org/asdf/ilc2010}
6077 @item Francois-Rene Rideau and Spencer Brody:
6078   ``XCVB: an eXtensible Component Verifier and Builder for Common Lisp'', 2009.
6079   This article describes XCVB, a proposed competitor for ASDF;
6080   many of its ideas have been incorporated into ASDF 2 and 3,
6081   though many other ideas still haven't.
6082   @url{https://common-lisp.net/project/xcvb/}
6083 @item Peter von Etter:
6084   ``faslpath'', 2009.
6085   @code{faslpath} is similar to the latter @code{quick-build}
6086   and our yet latter @code{asdf/package-system} extension,
6087   except that it uses dot @code{.} rather than slash @code{/} as a separator.
6088   @url{https://code.google.com/p/faslpath/}
6089 @item Drew McDermott:
6090   ``A Framework for Maintaining the Coherence of a Running Lisp,''
6091   International Lisp Conference, 2005, available in pre-print form at
6092   @url{http://www.cs.yale.edu/homes/dvm/papers/lisp05.pdf}
6093 @item Dan Barlow: ``ASDF Manual'', 2004.
6094   Older versions of this document from the days of ASDF 1;
6095   they include ideas laid down by Dan Barlow,
6096   and comparisons with older defsystems (@code{mk-defsystem})
6097   and defsystem (@code{defsystem-4}, kmp's Memo 801).
6098 @item Marco Antoniotti and Peter Van Eynde:
6099  ``@code{DEFSYSTEM}: A @code{make} for Common Lisp, A Thoughtful Re-Implementation of an Old Idea'', 2002.
6100   The @file{defsystem-4} proposal available in the CLOCC repository.
6101 @item Mark Kantrovitz: ``Defsystem: A Portable Make Facility for Common Lisp'', 1990.
6102   The classic @file{mk-defsystem}, later variants of which
6103   are available in the CLOCC repository as @code{defsystem-3.x}.
6104 @item Richard Elliot Robbins:
6105   ``BUILD: A Tool for Maintaining Consistency in Modular Systems'', MIT AI TR 874, 1985.
6106   @url{ftp://publications.ai.mit.edu/ai-publications/pdf/AITR-874.pdf}
6107 @item Kent M. Pitman (kmp): ``The Description of Large Systems'', MIT AI Memo 801, 1984.
6108   Available in updated-for-CL form on the web at
6109   @url{http://nhplace.com/kent/Papers/Large-Systems.html}
6110 @item Dan Weinreb and David Moon:
6111   ``Lisp Machine Manual'', MIT, 1981.
6112   The famous CHINE NUAL describes one of the earliest variants of DEFSYSTEM.
6113   @url{https://bitsavers.trailing-edge.com/pdf/mit/cadr/chinual_4thEd_Jul81.pdf}
6114 @end itemize
6117 @node Concept Index, Function and Class Index, Bibliography, Top
6118 @unnumbered Concept Index
6120 @printindex cp
6122 @node Function and Class Index, Variable Index, Concept Index, Top
6123 @unnumbered Function and Class Index
6125 @printindex fn
6127 @node Variable Index,  , Function and Class Index, Top
6128 @unnumbered Variable Index
6130 @printindex vr
6132 @bye
6134 @c  LocalWords:  clbuild tarballs defsystem Quicklisp initarg uiop fasl
6135 @c  LocalWords:  namestring initargs fasls