source: trunk/abcl/doc/asdf/asdf.texinfo @ 14626

Last change on this file since 14626 was 14626, checked in by Mark Evenson, 10 years ago

asdf 3.1.0.65: restores BUNDLE-OP as working.

File size: 186.0 KB
Line 
1\input texinfo          @c -*- texinfo -*-
2@c %**start of header
3@setfilename asdf.info
4@settitle ASDF Manual
5@c %**end of header
6
7@c We use @&key, etc to escape & from TeX in lambda lists --
8@c so we need to define them for info as well.
9@macro AallowOtherKeys
10&allow-other-keys
11@end macro
12@macro Aoptional
13&optional
14@end macro
15@macro Arest
16&rest
17@end macro
18@macro Akey
19&key
20@end macro
21@macro Abody
22&body
23@end macro
24
25@c for install-info
26@dircategory Software development
27@direntry
28* asdf: (asdf).           Another System Definition Facility (for Common Lisp)
29@end direntry
30
31@copying
32This manual describes ASDF, a system definition facility
33for Common Lisp programs and libraries.
34
35You can find the latest version of this manual at
36@url{http://common-lisp.net/project/asdf/asdf.html}.
37
38ASDF Copyright @copyright{} 2001-2014 Daniel Barlow and contributors.
39
40This manual Copyright @copyright{} 2001-2014 Daniel Barlow and contributors.
41
42This manual revised @copyright{} 2009-2014 Robert P. Goldman and Francois-Rene Rideau.
43
44Permission is hereby granted, free of charge, to any person obtaining
45a copy of this software and associated documentation files (the
46``Software''), to deal in the Software without restriction, including
47without limitation the rights to use, copy, modify, merge, publish,
48distribute, sublicense, and/or sell copies of the Software, and to
49permit persons to whom the Software is furnished to do so, subject to
50the following conditions:
51
52The above copyright notice and this permission notice shall be
53included in all copies or substantial portions of the Software.
54
55THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
56EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
59LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
60OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
61WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62
63@end copying
64
65
66
67@titlepage
68@title ASDF: Another System Definition Facility
69
70@c The following two commands start the copyright page.
71@page
72@vskip 0pt plus 1filll
73@insertcopying
74@end titlepage
75
76@c Output the table of contents at the beginning.
77@contents
78
79@c -------------------
80
81@ifnottex
82
83@node Top, Introduction, (dir), (dir)
84@top asdf: another system definition facility
85
86@insertcopying
87
88@menu
89* Introduction::
90* Loading ASDF::
91* Configuring ASDF::
92* Using ASDF::
93* Defining systems with defsystem::
94* The object model of ASDF::
95* Controlling where ASDF searches for systems::
96* Controlling where ASDF saves compiled files::
97* Error handling::
98* Miscellaneous additional functionality::
99* Getting the latest version::
100* FAQ::
101* TODO list::
102* Inspiration::
103* Concept Index::
104* Function and Class Index::
105* Variable Index::
106
107@c @detailmenu
108@c  --- The Detailed Node Listing ---
109
110@c Defining systems with defsystem
111
112@c * The defsystem form::
113@c * A more involved example::
114@c * The defsystem grammar::
115@c * Other code in .asd files::
116
117@c The object model of ASDF
118
119@c * Operations::
120@c * Components::
121@c * Functions::
122
123@c Operations
124
125@c * Predefined operations of ASDF::
126@c * Creating new operations::
127
128@c Components
129
130@c * Common attributes of components::
131@c * Pre-defined subclasses of component::
132@c * Creating new component types::
133
134@c properties
135
136@c * Pre-defined subclasses of component::
137@c * Creating new component types::
138
139@c @end detailmenu
140@end menu
141
142@end ifnottex
143
144@c -------------------
145
146@node Introduction, Loading ASDF, Top, Top
147@comment  node-name,  next,  previous,  up
148@chapter Introduction
149@cindex ASDF-related features
150@vindex *features*
151@cindex Testing for ASDF
152@cindex ASDF versions
153@cindex :asdf
154@cindex :asdf2
155@cindex :asdf3
156
157ASDF is Another System Definition Facility:
158a tool for specifying how systems of Common Lisp software
159are comprised of components (sub-systems and files),
160and how to operate on these components in the right order
161so that they can be compiled, loaded, tested, etc.
162
163ASDF presents three faces:
164one for users of Common Lisp software who want to reuse other people's code,
165one for writers of Common Lisp software who want to specify how to build their systems,
166one for implementers of Common Lisp extensions who want to extend the build system.
167@xref{Using ASDF,,Loading a system},
168to learn how to use ASDF to load a system.
169@xref{Defining systems with defsystem},
170to learn how to define a system of your own.
171@xref{The object model of ASDF}, for a description of
172the ASDF internals and how to extend ASDF.
173
174@emph{Nota Bene}:
175We have released ASDF 2.000 on May 31st 2010,
176and ASDF 3.0.0 on May 15th 2013.
177Releases of ASDF 2 and later have since then been included
178in all actively maintained CL implementations that used to bundle ASDF 1,
179plus some implementations that didn't use to,
180and has been made to work with all actively used CL implementations and a few more.
181@xref{FAQ,,``What has changed between ASDF 1 and ASDF 2?''}.
182Furthermore, it is possible to upgrade from ASDF 1 to ASDF 2 or ASDF 3 on the fly.
183For this reason, we have stopped supporting ASDF 1 and ASDF 2.
184If you are using ASDF 1 or ASDF 2 and are experiencing any kind of issues or limitations,
185we recommend you upgrade to ASDF 3
186--- and we explain how to do that. @xref{Loading ASDF}.
187
188Also note that ASDF is not to be confused with ASDF-Install.
189ASDF-Install is not part of ASDF, but a separate piece of software.
190ASDF-Install is also unmaintained and obsolete.
191We recommend you use Quicklisp instead,
192which works great and is being actively maintained.
193If you want to download software from version control instead of tarballs,
194so you may more easily modify it, we recommend clbuild.
195
196
197@node Loading ASDF, Configuring ASDF, Introduction, Top
198@comment  node-name,  next,  previous,  up
199@chapter Loading ASDF
200@vindex *central-registry*
201@cindex link farm
202@findex load-system
203@findex require-system
204@findex compile-system
205@findex test-system
206@cindex system directory designator
207@findex operate
208@findex oos
209
210@c @menu
211@c * Installing ASDF::
212@c @end menu
213
214
215@section Loading a pre-installed ASDF
216
217Most recent Lisp implementations include a copy of ASDF 2, and soon ASDF 3.
218You can usually load this copy using Common Lisp's @code{require} function:
219
220@lisp
221(require "asdf")
222@end lisp
223
224As of the writing of this manual,
225the following implementations provide ASDF 2 this way:
226abcl allegro ccl clisp cmucl ecl lispworks mkcl sbcl xcl.
227The following implementation doesn't provide it yet but will in an upcoming release:
228scl.
229The following implementations are obsolete, not actively maintained,
230and most probably will never bundle it:
231cormanlisp gcl genera mcl.
232
233If the implementation you are using doesn't provide ASDF 2 or ASDF 3,
234see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below.
235If that implementation is still actively maintained,
236you may also send a bug report to your Lisp vendor and complain
237about their failing to provide ASDF.
238
239NB: all implementations except clisp also accept
240@code{(require "ASDF")}, @code{(require 'asdf)} and @code{(require :asdf)}.
241For portability's sake, you probably want to use @code{(require "asdf")}.
242
243
244@section Checking whether ASDF is loaded
245
246To check whether ASDF is properly loaded in your current Lisp image,
247you can run this form:
248
249@lisp
250(asdf:asdf-version)
251@end lisp
252
253If it returns a string,
254that is the version of ASDF that is currently installed.
255
256If it raises an error,
257then either ASDF is not loaded, or
258you are using an old version of ASDF.
259
260You can check whether an old version is loaded
261by checking if the ASDF package is present.
262The form below will allow you to programmatically determine
263whether a recent version is loaded, an old version is loaded,
264or none at all:
265
266@lisp
267(when (find-package :asdf)
268  (let ((ver (symbol-value (or (find-symbol (string :*asdf-version*) :asdf)
269                               (find-symbol (string :*asdf-revision*) :asdf)))))
270    (etypecase ver
271      (string ver)
272      (cons (with-output-to-string (s)
273              (loop for (n . m) on ver do (princ n s) (when m (princ "." s)))))
274      (null "1.0"))))
275@end lisp
276
277If it returns @code{nil} then ASDF is not installed.
278Otherwise it should return a string.
279If it returns @code{"1.0"}, then it can actually be
280any version before 1.77 or so, or some buggy variant of 1.x.
281
282If you are experiencing problems with ASDF,
283please try upgrading to the latest released version,
284using the method below,
285before you contact us and raise an issue.
286
287
288@section Upgrading ASDF
289
290If your implementation provides ASDF 3 or later,
291you only need to @code{(require "asdf")}:
292ASDF will automatically look whether an updated version of itself is available
293amongst the regularly configured systems, before it compiles anything else.
294See @pxref{Configuring ASDF} below.
295
296If your implementation does provide ASDF 2 or later,
297but not ASDF 3 or later,
298and you want to upgrade to a more recent version,
299you need to install and configure your ASDF as above,
300and additionally, you need to explicitly tell ASDF to load itself,
301right after you require your implementation's old ASDF 2:
302
303@lisp
304(require "asdf")
305(asdf:load-system :asdf)
306@end lisp
307
308If on the other hand, your implementation only provides an old ASDF,
309you will require a special configuration step and an old-style loading.
310Take special attention to not omit the trailing directory separator
311@code{/} at the end of your pathname:
312
313@lisp
314(require "asdf")
315(push #p"@var{/path/to/new/asdf/}" asdf:*central-registry*)
316(asdf:oos 'asdf:load-op :asdf)
317@end lisp
318
319Note that ASDF 1 won't redirect its output files,
320or at least won't do it according to your usual ASDF 2 configuration.
321You therefore need write access on the directory
322where you install the new ASDF,
323and make sure you're not using it
324for multiple mutually incompatible implementations.
325At worst, you may have to have multiple copies of the new ASDF,
326e.g. one per implementation installation, to avoid clashes.
327Note that to our knowledge all implementations that provide ASDF
328provide ASDF 2 in their latest release, so
329you may want to upgrade your implementation rather than go through that hoop.
330
331Finally, if you are using an unmaintained implementation
332that does not provide ASDF at all,
333see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below.
334
335Note that there are some limitations to upgrading ASDF:
336@itemize
337@item
338Previously loaded ASDF extension becomes invalid, and will need to be reloaded.
339This applies to e.g. CFFI-Grovel, or to hacks used by ironclad, etc.
340Since it isn't possible to automatically detect what extensions are present
341that need to be invalidated,
342ASDF will actually invalidate all previously loaded systems
343when it is loaded on top of a different ASDF version,
344starting with ASDF 2.014.8 (as far as releases go, 2.015);
345and it will automatically attempt this self-upgrade as its very first step
346starting with ASDF 3.
347
348@item
349For this an many other reasons,
350it important reason to load, configure and upgrade ASDF (if needed)
351as one of the very first things done by your build and startup scripts.
352Until all implementations provide ASDF 3 or later,
353it is safer if you upgrade ASDF and its extensions as a special step
354at the very beginning of whatever script you are running,
355before you start using ASDF to load anything else;
356even afterwards, it is still a good idea, to avoid having to
357load and reload code twice as it gets invalidated.
358
359@item
360Until all implementations provide ASDF 3 or later,
361it is unsafe to upgrade ASDF as part of loading a system
362that depends on a more recent version of ASDF,
363since the new one might shadow the old one while the old one is running,
364and the running old one will be confused
365when extensions are loaded into the new one.
366In the meantime, we recommend that your systems should @emph{not} specify
367@code{:depends-on (:asdf)}, or @code{:depends-on ((:version :asdf "2.010"))},
368but instead that they check that a recent enough ASDF is installed,
369with such code as:
370@example
371(unless (or #+asdf2 (asdf:version-satisfies
372                     (asdf:asdf-version) *required-asdf-version*))
373  (error "FOO requires ASDF ~A or later." *required-asdf-version*))
374@end example
375@item
376Until all implementations provide ASDF 3 or later,
377it is unsafe for a system to transitively depend on ASDF
378and not directly depend on ASDF;
379if any of the system you use either depends-on asdf,
380system-depends-on asdf, or transitively does,
381you should also do as well.
382@end itemize
383
384
385@section Loading an otherwise installed ASDF
386
387If your implementation doesn't include ASDF,
388if for some reason the upgrade somehow fails,
389does not or cannot apply to your case,
390you will have to install the file @file{asdf.lisp}
391somewhere and load it with:
392
393@lisp
394(load "/path/to/your/installed/asdf.lisp")
395@end lisp
396
397The single file @file{asdf.lisp} is all you normally need to use ASDF.
398
399You can extract this file from latest release tarball on the
400@url{http://common-lisp.net/project/asdf/,ASDF website}.
401If you are daring and willing to report bugs, you can get
402the latest and greatest version of ASDF from its git repository.
403@xref{Getting the latest version}.
404
405For maximum convenience you might want to have ASDF loaded
406whenever you start your Lisp implementation,
407for example by loading it from the startup script or dumping a custom core
408--- check your Lisp implementation's manual for details.
409
410
411@node Configuring ASDF, Using ASDF, Loading ASDF, Top
412@comment  node-name,  next,  previous,  up
413
414@chapter Configuring ASDF
415
416@section Configuring ASDF to find your systems
417
418So it may compile and load your systems, ASDF must be configured to find
419the @file{.asd} files that contain system definitions.
420
421Since ASDF 2, the preferred way to configure where ASDF finds your systems is
422the @code{source-registry} facility,
423fully described in its own chapter of this manual.
424@xref{Controlling where ASDF searches for systems}.
425
426The default location for a user to install Common Lisp software is under
427@file{~/.local/share/common-lisp/source/}.
428If you install software there (it can be a symlink),
429you don't need further configuration.
430If you're installing software yourself at a location that isn't standard,
431you have to tell ASDF where you installed it. See below.
432If you're using some tool to install software (e.g. Quicklisp),
433the authors of that tool should already have configured ASDF.
434
435The simplest way to add a path to your search path,
436say @file{/home/luser/.asd-link-farm/}
437is to create the directory
438@file{~/.config/common-lisp/source-registry.conf.d/}
439and there create a file with any name of your choice,
440and with the type @file{conf},
441for instance @file{42-asd-link-farm.conf}
442containing the line:
443
444@kbd{(:directory "/home/luser/.asd-link-farm/")}
445
446If you want all the subdirectories under @file{/home/luser/lisp/}
447to be recursively scanned for @file{.asd} files, instead use:
448
449@kbd{(:tree "/home/luser/lisp/")}
450
451Note that your Operating System distribution or your system administrator
452may already have configured system-managed libraries for you.
453
454The required @file{.conf} extension allows you to have disabled files
455or editor backups (ending in @file{~}), and works portably
456(for instance, it is a pain to allow both empty and non-empty extension on CLISP).
457Excluded are files the name of which start with a @file{.} character.
458It is customary to start the filename with two digits
459that specify the order in which the directories will be scanned.
460
461ASDF will automatically read your configuration
462the first time you try to find a system.
463You can reset the source-registry configuration with:
464
465@lisp
466(asdf:clear-source-registry)
467@end lisp
468
469And you probably should do so before you dump your Lisp image,
470if the configuration may change
471between the machine where you save it at the time you save it
472and the machine you resume it at the time you resume it.
473Actually, you should use @code{(asdf:clear-configuration)}
474before you dump your Lisp image, which includes the above.
475
476
477@section Configuring ASDF to find your systems --- old style
478
479The old way to configure ASDF to find your systems is by
480@code{push}ing directory pathnames onto the variable
481@code{asdf:*central-registry*}.
482
483You must configure this variable between the time you load ASDF
484and the time you first try to use it.
485Loading and configuring ASDF presumably happen
486as part of some initialization script that builds or starts
487your Common Lisp software system.
488(For instance, some SBCL users used to put it in their @file{~/.sbclrc}.)
489
490The @code{asdf:*central-registry*} is empty by default in ASDF 2 or ASDF 3,
491but is still supported for compatibility with ASDF 1.
492When used, it takes precedence over the above source-registry@footnote{
493It is possible to further customize
494the system definition file search.
495That's considered advanced use, and covered later:
496search forward for
497@code{*system-definition-search-functions*}.
498@xref{Defining systems with defsystem}.}.
499
500For instance, if you wanted ASDF to find the @file{.asd} file
501@file{/home/me/src/foo/foo.asd} your initialization script
502could after it loads ASDF with @code{(require "asdf")}
503configure it with:
504
505@lisp
506(push "/home/me/src/foo/" asdf:*central-registry*)
507@end lisp
508
509Note the trailing slash: when searching for a system,
510ASDF will evaluate each entry of the central registry
511and coerce the result to a pathname@footnote{
512ASDF will indeed call @code{eval} on each entry.
513It will also skip entries that evaluate to @code{nil}.
514
515Strings and pathname objects are self-evaluating,
516in which case the @code{eval} step does nothing;
517but you may push arbitrary SEXP onto the central registry,
518that will be evaluated to compute e.g. things that depend
519on the value of shell variables or the identity of the user.
520
521The variable @code{asdf:*central-registry*} is thus a list of
522``system directory designators''.
523A @dfn{system directory designator} is a form
524which will be evaluated whenever a system is to be found,
525and must evaluate to a directory to look in.
526By ``directory'' here, we mean
527``designator for a pathname with a supplied DIRECTORY component''.
528}
529at which point the presence of the trailing directory name separator
530is necessary to tell Lisp that you're discussing a directory
531rather than a file.
532
533Typically, however, there are a lot of @file{.asd} files, and
534a common idiom was to have to put
535a bunch of @emph{symbolic links} to @file{.asd} files
536in a common directory
537and push @emph{that} directory (the ``link farm'')
538to the
539@code{asdf:*central-registry*}
540instead of pushing each of the many involved directories
541to the @code{asdf:*central-registry*}.
542ASDF knows how to follow such @emph{symlinks}
543to the actual file location when resolving the paths of system components
544(on Windows, you can use Windows shortcuts instead of POSIX symlinks;
545if you try aliases under MacOS, we are curious to hear about your experience).
546
547For example, if @code{#p"/home/me/cl/systems/"} (note the trailing slash)
548is a member of @code{*central-registry*}, you could set up the
549system @var{foo} for loading with asdf with the following
550commands at the shell:
551
552@example
553$ cd /home/me/cl/systems/
554$ ln -s ~/src/foo/foo.asd .
555@end example
556
557This old style for configuring ASDF is not recommended for new users,
558but it is supported for old users, and for users who want to programmatically
559control what directories are added to the ASDF search path.
560
561
562@section Configuring where ASDF stores object files
563@findex clear-output-translations
564
565ASDF lets you configure where object files will be stored.
566Sensible defaults are provided and
567you shouldn't normally have to worry about it.
568
569This allows the same source code repository may be shared
570between several versions of several Common Lisp implementations,
571between several users using different compilation options
572and without write privileges on shared source directories, etc.
573This also allows to keep source directories uncluttered
574by plenty of object files.
575
576Starting with ASDF 2, the @code{asdf-output-translations} facility
577was added to ASDF itself, that controls where object files will be stored.
578This facility is fully described in a chapter of this manual,
579@ref{Controlling where ASDF saves compiled files}.
580
581The simplest way to add a translation to your search path,
582say from @file{/foo/bar/baz/quux/}
583to @file{/where/i/want/my/fasls/}
584is to create the directory
585@file{~/.config/common-lisp/asdf-output-translations.conf.d/}
586and there create a file with any name of your choice and the type @file{conf},
587for instance @file{42-bazquux.conf}
588containing the line:
589
590@kbd{("/foo/bar/baz/quux/" "/where/i/want/my/fasls/")}
591
592To disable output translations for source under a given directory,
593say @file{/toto/tata/}
594you can create a file @file{40-disable-toto.conf}
595with the line:
596
597@kbd{("/toto/tata/")}
598
599To wholly disable output translations for all directories,
600you can create a file @file{00-disable.conf}
601with the line:
602
603@kbd{(t t)}
604
605Note that your Operating System distribution or your system administrator
606may already have configured translations for you.
607In absence of any configuration, the default is to redirect everything
608under an implementation-dependent subdirectory of @file{~/.cache/common-lisp/}.
609@xref{Controlling where ASDF searches for systems}, for full details.
610
611The required @file{.conf} extension allows you to have disabled files
612or editor backups (ending in @file{~}), and works portably
613(for instance, it is a pain to allow both empty and non-empty extension on CLISP).
614Excluded are files the name of which start with a @file{.} character.
615It is customary to start the filename with two digits
616that specify the order in which the directories will be scanned.
617
618ASDF will automatically read your configuration
619the first time you try to find a system.
620You can reset the source-registry configuration with:
621
622@lisp
623(asdf:clear-output-translations)
624@end lisp
625
626And you probably should do so before you dump your Lisp image,
627if the configuration may change
628between the machine where you save it at the time you save it
629and the machine you resume it at the time you resume it.
630(Once again, you should use @code{(asdf:clear-configuration)}
631before you dump your Lisp image, which includes the above.)
632
633Finally note that before ASDF 2,
634other ASDF add-ons offered the same functionality,
635each in subtly different and incompatible ways:
636ASDF-Binary-Locations, cl-launch, common-lisp-controller.
637ASDF-Binary-Locations is now not needed anymore and should not be used.
638cl-launch 3.000 and common-lisp-controller 7.2 have been updated
639to just delegate this functionality to ASDF.
640
641@node Using ASDF, Defining systems with defsystem, Configuring ASDF, Top
642@comment  node-name,  next,  previous,  up
643
644
645@section Resetting Configuration
646
647When you dump and restore an image, or when you tweak your configuration,
648you may want to reset the ASDF configuration.
649For that you may use the following function:
650
651@defun clear-configuration
652   undoes any ASDF configuration,
653   regarding source-registry or output-translations.
654@end defun
655
656If you use SBCL, CMUCL or SCL, you may use this snippet
657so that the ASDF configuration be cleared automatically as you dump an image:
658
659@example
660#+(or cmu sbcl scl)
661(pushnew 'clear-configuration
662         #+(or cmu scl) ext:*before-save-initializations*
663         #+sbcl sb-ext:*save-hooks*)
664@end example
665
666For compatibility with all Lisp implementations, however,
667you might want instead your build script to explicitly call
668@code{(asdf:clear-configuration)} at an appropriate moment before dumping.
669
670
671@chapter Using ASDF
672
673@section Loading a system
674
675The system @var{foo} is loaded (and compiled, if necessary)
676by evaluating the following Lisp form:
677
678@example
679(asdf:load-system :@var{foo})
680@end example
681
682On some implementations (namely recent versions of
683ABCL, Allegro CL, Clozure CL, CMUCL, ECL, GNU CLISP,
684LispWorks, MKCL, SBCL and XCL),
685ASDF hooks into the @code{CL:REQUIRE} facility
686and you can just use:
687
688@example
689(require :@var{foo})
690@end example
691
692In older versions of ASDF, you needed to use
693@code{(asdf:oos 'asdf:load-op :@var{foo})}.
694If your ASDF is too old to provide @code{asdf:load-system} though
695we recommend that you upgrade to ASDF 3.
696@xref{Loading ASDF,,Loading an otherwise installed ASDF}.
697
698Note the name of a system is specified as a string or a symbol,
699typically a keyword.
700If a symbol (including a keyword), its name is taken and lowercased.
701The name must be a suitable value for the @code{:name} initarg
702to @code{make-pathname} in whatever filesystem the system is to be found.
703The lower-casing-symbols behaviour is unconventional,
704but was selected after some consideration.
705Observations suggest that the type of systems we want to support
706either have lowercase as customary case (unix, mac, windows)
707or silently convert lowercase to uppercase (lpns),
708so this makes more sense than attempting to use @code{:case :common},
709which is reported not to work on some implementations
710
711
712@section Other Operations
713
714ASDF provides three commands for the most common system operations:
715@code{load-system}, @code{compile-system} or @code{test-system}.
716It also provides @code{require-system}, a version of @code{load-system}
717that skips trying to update systems that are already loaded.
718
719Because ASDF is an extensible system
720for defining @emph{operations} on @emph{components},
721it also provides a generic function @code{operate}
722(which is usually abbreviated by @code{oos}).
723You'll use @code{oos} whenever you want to do something beyond
724compiling, loading and testing.
725
726Output from ASDF and ASDF extensions are supposed to be sent
727to the CL stream @code{*standard-output*},
728and so rebinding that stream around calls to @code{asdf:operate}
729should redirect all output from ASDF operations.
730
731Reminder: before ASDF can operate on a system, however,
732it must be able to find and load that system's definition.
733@xref{Configuring ASDF,,Configuring ASDF to find your systems}.
734
735@findex already-loaded-systems
736
737For the advanced users, note that
738@code{require-system} calls @code{load-system}
739with keyword arguments @code{:force-not (already-loaded-systems)}.
740@code{already-loaded-systems} returns a list of the names of loaded systems.
741@code{load-system} applies @code{operate} with the operation from
742@code{*load-system-operation*}, which by default is @code{load-op},
743the system, and any provided keyword arguments.
744
745@section Summary
746
747To use ASDF:
748
749@itemize
750@item
751Load ASDF itself into your Lisp image, either through
752@code{(require "asdf")} or else through
753@code{(load "/path/to/asdf.lisp")}.
754
755@item
756Make sure ASDF can find system definitions
757thanks to proper source-registry configuration.
758
759@item
760Load a system with @code{(asdf:load-system :my-system)}
761or use some other operation on some system of your choice.
762
763@end itemize
764
765@section Moving on
766
767That's all you need to know to use ASDF to load systems written by others.
768The rest of this manual deals with writing system definitions
769for Common Lisp software you write yourself,
770including how to extend ASDF to define new operation and component types.
771
772
773@node Defining systems with defsystem, The object model of ASDF, Using ASDF, Top
774@comment  node-name,  next,  previous,  up
775@chapter Defining systems with defsystem
776
777This chapter describes how to use asdf to define systems and develop
778software.
779
780
781@menu
782* The defsystem form::
783* A more involved example::
784* The defsystem grammar::
785* Other code in .asd files::
786* The package-system extension::
787@end menu
788
789@node  The defsystem form, A more involved example, Defining systems with defsystem, Defining systems with defsystem
790@comment  node-name,  next,  previous,  up
791@section The defsystem form
792
793Systems can be constructed programmatically
794by instantiating components using @code{make-instance}.
795Most of the time, however, it is much more practical to use
796a static @code{defsystem} form.
797This section begins with an example of a system definition,
798then gives the full grammar of @code{defsystem}.
799
800Let's look at a simple system.
801This is a complete file that would
802usually be saved as @file{hello-lisp.asd}:
803
804@lisp
805(in-package :asdf)
806
807(defsystem "hello-lisp"
808  :description "hello-lisp: a sample Lisp system."
809  :version "0.2.1"
810  :author "Joe User <joe@@example.com>"
811  :licence "Public Domain"
812  :components ((:file "packages")
813               (:file "macros" :depends-on ("packages"))
814               (:file "hello" :depends-on ("macros"))))
815@end lisp
816
817Some notes about this example:
818
819@itemize
820
821@item
822The file starts with an @code{in-package} form
823to use package @code{asdf}.
824You could instead start your definition by using
825a qualified name @code{asdf:defsystem}.
826
827@item
828If in addition to simply using @code{defsystem},
829you are going to define functions,
830create ASDF extension, globally bind symbols, etc.,
831it is recommended that to avoid namespace pollution between systems,
832you should create your own package for that purpose,
833for instance replacing the above @code{(in-package :asdf)} with:
834
835@lisp
836(defpackage :foo-system
837  (:use :cl :asdf))
838
839(in-package :foo-system)
840@end lisp
841
842@item
843The @code{defsystem} form defines a system named @code{hello-lisp}
844that contains three source files:
845@file{packages}, @file{macros} and @file{hello}.
846
847@item
848The file @file{macros} depends on @file{packages}
849(presumably because the package it's in is defined in @file{packages}),
850and the file @file{hello} depends on @file{macros}
851(and hence, transitively on @file{packages}).
852This means that ASDF will compile and load @file{packages} and @file{macros}
853before starting the compilation of file @file{hello}.
854
855@item
856The files are located in the same directory
857as the file with the system definition.
858ASDF resolves symbolic links (or Windows shortcuts)
859before loading the system definition file and
860stores its location in the resulting system@footnote{
861It is possible, though almost never necessary, to override this behaviour.}.
862This is a good thing because the user can move the system sources
863without having to edit the system definition.
864
865@c FIXME: Should have cross-reference to "Version specifiers" in the
866@c defsystem grammar, but the cross-referencing is so broken by
867@c insufficient node breakdown that I have not put one in.
868@item
869Make sure you know how the @code{:version} numbers will be parsed!
870They are parsed as period-separated lists of integers.
871I.e., in the example, @code{0.2.1} is to be interpreted,
872roughly speaking, as @code{(0 2 1)}.
873In particular, version @code{0.2.1}
874is interpreted the same as @code{0.0002.1} and
875is strictly version-less-than version @code{0.20.1},
876even though the two are the same when interpreted as decimal fractions.
877Instead of a string representing the version,
878the @code{:version} argument can be an expression that is resolved to
879such a string using the following trivial domain-specific language:
880in addition to being a literal string, it can be an expression of the form
881@code{(:read-file-form <pathname-or-string> :at <access-at-specifier>)},
882which will be resolved by reading a form in the specified pathname
883(read as a subpathname of the current system if relative or a unix-namestring).
884You may use a @code{uiop:access-at} specifier
885with the (optional) @code{:at} keyword,
886by default the specifier is @code{0}, meaning the first form is returned.
887
888@cindex :version
889
890@end itemize
891
892@node  A more involved example, The defsystem grammar, The defsystem form, Defining systems with defsystem
893@comment  node-name,  next,  previous,  up
894@section A more involved example
895
896Let's illustrate some more involved uses of @code{defsystem} via a
897slightly convoluted example:
898
899@lisp
900(defsystem "foo"
901  :version "1.0.0"
902  :components ((:module "mod"
903                            :components ((:file "bar")
904                                                  (:file"baz")
905                                                  (:file "quux"))
906                            :perform (compile-op :after (op c)
907                                                  (do-something c))
908                            :explain (compile-op :after (op c)
909                                            (explain-something c)))
910                         (:file "blah")))
911@end lisp
912
913The @code{:module} component named @code{"mod"} is a collection of three files,
914which will be located in a subdirectory of the main code directory named
915@file{mod} (this location can be overridden; see the discussion of the
916@code{:pathname} option in @ref{The defsystem grammar}).
917
918The method-form tokens provide a shorthand for defining methods on
919particular components.  This part
920
921@lisp
922                :perform (compile-op :after (op c)
923                          (do-something c))
924                :explain (compile-op :after (op c)
925                          (explain-something c))
926@end lisp
927
928has the effect of
929
930@lisp
931(defmethod perform :after ((op compile-op) (c (eql ...)))
932           (do-something c))
933(defmethod explain :after ((op compile-op) (c (eql ...)))
934           (explain-something c))
935@end lisp
936
937where @code{...} is the component in question.
938In this case @code{...} would expand to something like
939
940@lisp
941(find-component "foo" "mod")
942@end lisp
943
944For more details on the syntax of such forms, see @ref{The defsystem
945grammar}.
946For more details on what these methods do, @pxref{Operations} in
947@ref{The object model of ASDF}.
948
949@c The following plunge into the weeds is not appropriate in this
950@c location. [2010/10/03:rpg]
951@c note that although this also supports @code{:before} methods,
952@c they may not do what you want them to ---
953@c a @code{:before} method on perform @code{((op compile-op) (c (eql ...)))}
954@c will run after all the dependencies and sub-components have been processed,
955@c but before the component in question has been compiled.
956
957@node  The defsystem grammar, Other code in .asd files, A more involved example, Defining systems with defsystem
958@comment  node-name,  next,  previous,  up
959@section The defsystem grammar
960
961@c FIXME: @var typesetting not consistently used here.  We should either expand
962@c its use to everywhere, or we should kill it everywhere.
963
964
965@example
966system-definition := ( defsystem system-designator @var{system-option}* )
967
968system-option := :defsystem-depends-on system-list
969                 | :weakly-depends-on @var{system-list}
970                 | :class class-name (see discussion below)
971                 | module-option
972                 | option
973
974module-option := :components component-list
975                 | :serial [ t | nil ]
976
977option :=
978        | :pathname pathname-specifier
979        | :default-component-class class-name
980        | :perform method-form
981        | :explain method-form
982        | :output-files method-form
983        | :operation-done-p method-form
984        | :if-feature feature-expression
985        | :depends-on ( @var{dependency-def}* )
986        | :in-order-to ( @var{dependency}+ )
987
988
989system-list := ( @var{simple-component-name}* )
990
991component-list := ( @var{component-def}* )
992
993component-def  := ( component-type simple-component-name @var{option}* )
994
995component-type := :module | :file | :static-file | other-component-type
996
997other-component-type := symbol-by-name (@pxref{The defsystem grammar,,Component types})
998
999# This is used in :depends-on, as opposed to ``dependency,''
1000# which is used in :in-order-to
1001dependency-def := simple-component-name
1002               | (feature @var{feature-name})
1003               | ( :version simple-component-name version-specifier)
1004
1005# ``dependency'' is used in :in-order-to, as opposed to
1006# ``dependency-def''
1007dependency := (dependent-op @var{requirement}+)
1008requirement := (required-op @var{required-component}+)
1009             | (:feature @var{feature-name})
1010dependent-op := operation-name
1011required-op := operation-name
1012
1013simple-component-name := string
1014                      |  symbol
1015
1016pathname-specifier := pathname | string | symbol
1017
1018method-form := (operation-name qual lambda-list @Arest body)
1019qual := method qualifier
1020
1021component-dep-fail-option := :fail | :try-next | :ignore
1022
1023feature-expression := keyword | (:and @var{feature-expression}*)
1024                      | (:or @var{feature-expression}*) | (:not @var{feature-expression})
1025@end example
1026
1027
1028@subsection Component names
1029
1030Component names (@code{simple-component-name})
1031may be either strings or symbols.
1032
1033@subsection Component types
1034
1035Component type names, even if expressed as keywords, will be looked up
1036by name in the current package and in the asdf package, if not found in
1037the current package.  So a component type @code{my-component-type}, in
1038the current package @code{my-system-asd} can be specified as
1039@code{:my-component-type}, or @code{my-component-type}.
1040
1041@code{system} and its subclasses are @emph{not}
1042allowed as component types for such children components.
1043
1044@subsection System class names
1045
1046A system class name will be looked up
1047in the same way as a Component type (see above),
1048except that only @code{system} and its subclasses are allowed.
1049Typically, one will not need to specify a system
1050class name, unless using a non-standard system class defined in some
1051ASDF extension, typically loaded through @code{DEFSYSTEM-DEPENDS-ON},
1052see below.  For such class names in the ASDF package, we recommend that
1053the @code{:class} option be specified using a keyword symbol, such as
1054
1055@example
1056:class :MY-NEW-SYSTEM-SUBCLASS
1057@end example
1058
1059This practice will ensure that package name conflicts are avoided.
1060Otherwise, the symbol @code{MY-NEW-SYSTEM-SUBCLASS} will be read into
1061the current package @emph{before} it has been exported from the ASDF
1062extension loaded by @code{:defsystem-depends-on}, causing a name
1063conflict in the current package.
1064
1065@subsection Defsystem depends on
1066@cindex :defsystem-depends-on
1067
1068The @code{:defsystem-depends-on} option to @code{defsystem} allows the
1069programmer to specify another ASDF-defined system or set of systems that
1070must be loaded @emph{before} the system definition is processed.
1071Typically this is used to load an ASDF extension that is used in the
1072system definition.
1073
1074@subsection Weakly depends on
1075@cindex :weakly-depends-on
1076
1077We do @emph{NOT} recommend you use this feature.
1078If you are tempted to write a system @var{foo}
1079that weakly-depends-on a system @var{bar},
1080we recommend that you should instead
1081write system @var{foo} in a parametric way,
1082and offer some special variable and/or some hook to specialize its behavior;
1083then you should write a system @var{foo+bar}
1084that does the hooking of things together.
1085
1086The (deprecated) @code{:weakly-depends-on} option to @code{defsystem}
1087allows the programmer to specify another ASDF-defined system or set of systems
1088that ASDF should @emph{try} to load,
1089but need not load in order to be successful.
1090Typically this is used if there are a number of systems
1091that, if present, could provide additional functionality,
1092but which are not necessary for basic function.
1093
1094Currently, although it is specified to be an option only to @code{defsystem},
1095this option is accepted at any component, but it probably
1096only makes sense at the @code{defsystem} level.
1097Programmers are cautioned not
1098to use this component option except at the @code{defsystem} level, as
1099this anomalous behavior may be removed without warning.
1100
1101Finally, you might look into the @code{asdf-system-connections} extension,
1102that will let you define additional code to be loaded
1103when two systems are simultaneously loaded.
1104It may or may not be considered good style, but at least it can be used
1105in a way that has deterministic behavior independent of load order,
1106unlike @code{weakly-depends-on}.
1107
1108
1109@subsection Pathname specifiers
1110@cindex pathname specifiers
1111
1112A pathname specifier (@code{pathname-specifier})
1113may be a pathname, a string or a symbol.
1114When no pathname specifier is given for a component,
1115which is the usual case, the component name itself is used.
1116
1117If a string is given, which is the usual case,
1118the string will be interpreted as a Unix-style pathname
1119where @code{/} characters will be interpreted as directory separators.
1120Usually, Unix-style relative pathnames are used
1121(i.e. not starting with @code{/}, as opposed to absolute pathnames);
1122they are relative to the path of the parent component.
1123Finally, depending on the @code{component-type},
1124the pathname may be interpreted as either a file or a directory,
1125and if it's a file,
1126a file type may be added corresponding to the @code{component-type},
1127or else it will be extracted from the string itself (if applicable).
1128
1129For instance, the @code{component-type} @code{:module}
1130wants a directory pathname, and so a string @code{"foo/bar"}
1131will be interpreted as the pathname @file{#p"foo/bar/"}.
1132On the other hand, the @code{component-type} @code{:file}
1133wants a file of type @code{lisp}, and so a string @code{"foo/bar"}
1134will be interpreted as the pathname @file{#p"foo/bar.lisp"},
1135and a string @code{"foo/bar.quux"}
1136will be interpreted as the pathname @file{#p"foo/bar.quux.lisp"}.
1137Finally, the @code{component-type} @code{:static-file}
1138wants a file without specifying a type, and so a string @code{"foo/bar"}
1139will be interpreted as the pathname @file{#p"foo/bar"},
1140and a string @code{"foo/bar.quux"}
1141will be interpreted as the pathname @file{#p"foo/bar.quux"}.
1142
1143ASDF does not interpret the string @code{".."} to designate the parent
1144directory.  This string will be passed through to the underlying
1145operating system for interpretation.  We @emph{believe} that this will
1146work on all platforms where ASDF is deployed, but do not guarantee this
1147behavior.  A pathname object with a relative directory component of
1148@code{:up} or @code{:back} is the only guaranteed way to specify a
1149parent directory.
1150
1151If a symbol is given, it will be translated into a string,
1152and downcased in the process.
1153The downcasing of symbols is unconventional,
1154but was selected after some consideration.
1155Observations suggest that the type of systems we want to support
1156either have lowercase as customary case (Unix, Mac, windows)
1157or silently convert lowercase to uppercase (lpns),
1158so this makes more sense than attempting to use @code{:case :common}
1159as argument to @code{make-pathname},
1160which is reported not to work on some implementations.
1161
1162Pathname objects may be given to override the path for a component.
1163Such objects are typically specified using reader macros such as @code{#p}
1164or @code{#.(make-pathname ...)}.
1165Note however, that @code{#p...} is
1166a shorthand for @code{#.(parse-namestring ...)}
1167and that the behavior of @code{parse-namestring} is completely non-portable,
1168unless you are using Common Lisp @code{logical-pathname}s,
1169which themselves involve other non-portable behavior
1170(@pxref{The defsystem grammar,,Using logical pathnames}, below).
1171Pathnames made with @code{#.(make-pathname ...)}
1172can usually be done more easily with the string syntax above.
1173The only case that you really need a pathname object is to override
1174the component-type default file type for a given component.
1175Therefore, pathname objects should only rarely be used.
1176Unhappily, ASDF 1 didn't properly support
1177parsing component names as strings specifying paths with directories,
1178and the cumbersome @code{#.(make-pathname ...)} syntax had to be used.
1179An alternative to @code{#.} read-time evaluation is to use
1180@code{(eval `(defsystem ... ,pathname ...))}.
1181
1182Note that when specifying pathname objects,
1183ASDF does not do any special interpretation of the pathname
1184influenced by the component type, unlike the procedure for
1185pathname-specifying strings.
1186On the one hand, you have to be careful to provide a pathname that correctly
1187fulfills whatever constraints are required from that component type
1188(e.g. naming a directory or a file with appropriate type);
1189on the other hand, you can circumvent the file type that would otherwise
1190be forced upon you if you were specifying a string.
1191
1192@subsection Version specifiers
1193@cindex version specifiers
1194@cindex :version
1195
1196Version specifiers are strings to be parsed as period-separated lists of integers.
1197I.e., in the example, @code{"0.2.1"} is to be interpreted,
1198roughly speaking, as @code{(0 2 1)}.
1199In particular, version @code{"0.2.1"} is interpreted the same as @code{"0.0002.1"},
1200though the latter is not canonical and may lead to a warning being issued.
1201Also, @code{"1.3"} and @code{"1.4"} are both strictly @code{uiop:version<} to @code{"1.30"},
1202quite unlike what would have happened
1203had the version strings been interpreted as decimal fractions.
1204
1205System definers are encouraged to use version identifiers of the form
1206@var{x}.@var{y}.@var{z} for
1207major version, minor version and patch level,
1208where significant API incompatibilities are signaled by an increased major number.
1209
1210@xref{Common attributes of components}.
1211
1212
1213@subsection Using logical pathnames
1214@cindex logical pathnames
1215
1216We do not generally recommend the use of logical pathnames,
1217especially not so to newcomers to Common Lisp.
1218However, we do support the use of logical pathnames by old timers,
1219when such is their preference.
1220
1221To use logical pathnames,
1222you will have to provide a pathname object as a @code{:pathname} specifier
1223to components that use it, using such syntax as
1224@code{#p"LOGICAL-HOST:absolute;path;to;component.lisp"}.
1225
1226You only have to specify such logical pathname
1227for your system or some top-level component.
1228Sub-components' relative pathnames,
1229specified using the string syntax for names,
1230will be properly merged with the pathnames of their parents.
1231The specification of a logical pathname host however is @emph{not}
1232otherwise directly supported in the ASDF syntax
1233for pathname specifiers as strings.
1234
1235The @code{asdf-output-translation} layer will
1236avoid trying to resolve and translate logical pathnames.
1237The advantage of this is that
1238you can define yourself what translations you want to use
1239with the logical pathname facility.
1240The disadvantage is that if you do not define such translations,
1241any system that uses logical pathnames will behave differently under
1242asdf-output-translations than other systems you use.
1243
1244If you wish to use logical pathnames you will have to configure the
1245translations yourself before they may be used.
1246ASDF currently provides no specific support
1247for defining logical pathname translations.
1248
1249Note that the reasons we do not recommend logical pathnames are that
1250(1) there is no portable way to set up logical pathnames before they are used,
1251(2) logical pathnames are limited to only portably use
1252a single character case, digits and hyphens.
1253While you can solve the first issue on your own,
1254describing how to do it on each of fifteen implementations supported by ASDF
1255is more than we can document.
1256As for the second issue, mind that the limitation is notably enforced on SBCL,
1257and that you therefore can't portably violate the limitations
1258but must instead define some encoding of your own and add individual mappings
1259to name physical pathnames that do not fit the restrictions.
1260This can notably be a problem when your Lisp files are part of a larger project
1261in which it is common to name files or directories in a way that
1262includes the version numbers of supported protocols,
1263or in which files are shared with software written
1264in different programming languages where conventions include the use of
1265underscores, dots or CamelCase in pathnames.
1266
1267
1268@subsection Serial dependencies
1269@cindex serial dependencies
1270
1271If the @code{:serial t} option is specified for a module,
1272ASDF will add dependencies for each child component,
1273on all the children textually preceding it.
1274This is done as if by @code{:depends-on}.
1275
1276@lisp
1277:serial t
1278:components ((:file "a") (:file "b") (:file "c"))
1279@end lisp
1280
1281is equivalent to
1282
1283@lisp
1284:components ((:file "a")
1285             (:file "b" :depends-on ("a"))
1286             (:file "c" :depends-on ("a" "b")))
1287@end lisp
1288
1289
1290@subsection Source location
1291
1292The @code{:pathname} option is optional in all cases for systems
1293defined via @code{defsystem},
1294and in the usual case the user is recommended not to supply it.
1295
1296Instead, ASDF follows a hairy set of rules that are designed so that
1297@enumerate
1298@item
1299@code{find-system}
1300will load a system from disk
1301and have its pathname default to the right place.
1302
1303@item
1304This pathname information will not be overwritten with
1305@code{*default-pathname-defaults*}
1306(which could be somewhere else altogether)
1307if the user loads up the @file{.asd} file into his editor
1308and interactively re-evaluates that form.
1309@end enumerate
1310
1311If a system is being loaded for the first time,
1312its top-level pathname will be set to:
1313
1314@itemize
1315@item
1316The host/device/directory parts of @code{*load-truename*},
1317if it is bound.
1318@item
1319@code{*default-pathname-defaults*}, otherwise.
1320@end itemize
1321
1322If a system is being redefined, the top-level pathname will be
1323
1324@itemize
1325@item
1326changed, if explicitly supplied or obtained from @code{*load-truename*}
1327(so that an updated source location is reflected in the system definition)
1328
1329@item
1330changed if it had previously been set from @code{*default-pathname-defaults*}
1331
1332@item
1333left as before, if it had previously been set from @code{*load-truename*}
1334and @code{*load-truename*} is currently unbound
1335(so that a developer can evaluate a @code{defsystem} form
1336from within an editor without clobbering its source location)
1337@end itemize
1338
1339@subsection if-feature option
1340This option allows you to specify a feature expression to be evaluated
1341as if by @code{#+} to conditionally include a component in your build.
1342If the expression is false, the component is dropped
1343as well as any dependency pointing to it.
1344As compared to using @code{#+} which is expanded at read-time,
1345this allows you to have an object in your component hierarchy
1346that can be used for manipulations beside building your project.
1347This option was added in ASDF 3.
1348
1349@subsection if-component-dep-fails option
1350This option was removed in ASDF 3.
1351Its semantics was limited in purpose and dubious to explain,
1352and its implementation was breaking a hole into the ASDF object model.
1353Please use the @code{if-feature} option instead.
1354
1355@node Other code in .asd files, The package-system extension, The defsystem grammar, Defining systems with defsystem
1356@section Other code in .asd files
1357
1358Files containing @code{defsystem} forms
1359are regular Lisp files that are executed by @code{load}.
1360Consequently, you can put whatever Lisp code you like into these files.
1361However, it is recommended to keep such forms to a minimal,
1362and to instead define @code{defsystem} extensions
1363that you use with @code{:defsystem-depends-on}.
1364
1365If however, you might insist on including code in the @code{.asd} file itself,
1366e.g., to examine and adjust the compile-time environment,
1367possibly adding appropriate features to @code{*features*}.
1368If so, here are some conventions we recommend you follow,
1369so that users can control certain details of execution
1370of the Lisp in @file{.asd} files:
1371
1372@itemize
1373@item
1374Any informative output
1375(other than warnings and errors,
1376which are the condition system's to dispose of)
1377should be sent to the standard CL stream @code{*standard-output*},
1378so that users can easily control the disposition
1379of output from ASDF operations.
1380@end itemize
1381
1382
1383@node The package-system extension,  , Other code in .asd files, Defining systems with defsystem
1384@section The package-system extension
1385
1386Starting with ASDF 3.0.3,
1387ASDF supports a one-package-per-file style of programming,
1388whereby each file is its own system,
1389and dependencies are deduced from the @code{defpackage} form.
1390
1391In this style, packages referring to a same-named system (downcased);
1392and if a system is defined with @code{:class package-system},
1393then system names that start with that name
1394(using the slash @code{/} separator)
1395refer to files under the filesystem hierarchy where the system is defined.
1396For instance, if system @code{my-lib} is defined in
1397@file{/foo/bar/my-lib/my-lib.asd}, then system @code{my-lib/src/utility}
1398will be found in file @file{/foo/bar/my-lib/src/utility.lisp}.
1399
1400This style was made popular by @code{faslpath} and @code{quick-build} before,
1401and at the cost of a stricter package discipline,
1402seems to make for more maintainable code.
1403It is used by ASDF itself (starting with ASDF 3) and by @code{lisp-interface-library}.
1404
1405To use this style, choose a toplevel system name, e.g. @code{my-lib},
1406and create a file @file{my-lib.asd}
1407with the @code{:class :package-system} option in its @code{defsystem}.
1408For instance:
1409@example
1410#-asdf (error "my-lib requires ASDF 3")
1411(defsystem my-lib
1412  :class :package-system
1413  :defsystem-depends-on (:asdf-package-system)
1414  :depends-on (:my-lib/src/all)
1415  :in-order-to ((test-op (load-op :my-lib/test/all)))
1416  :perform (test-op (o c) (symbol-call :my-lib/test/all :test-suite)))
1417(register-system-packages :closer-mop
1418 '(:c2mop :closer-common-lisp :c2cl :closer-common-lisp-user :c2cl-user))
1419@end example
1420
1421In the code above, the
1422@code{:defsystem-depends-on (:asdf-package-system)} is
1423for compatibility with older versions of ASDF 3 (ASDF 2 not supported),
1424and requires the @code{asdf-package-system} library to be present
1425(it is implicitly provided by ASDF starting with ASDF 3.0.3).
1426
1427The function @code{register-system-packages} has to be called to register
1428packages used or provided by your system and its components
1429where the name of the system that provides the package
1430is not the downcase of the package name.
1431
1432File @file{my-lib/src/utility.lisp} might start with:
1433
1434@example
1435(defpackage :my-lib/src/utility
1436  (:use :closer-common-lisp :my-lib/src/macros :my-lib/src/variables)
1437  (:import-from :cl-ppcre #:register-groups-bind)
1438  (:export #:foo #:bar))
1439@end example
1440
1441And from the @code{:use} and @code{:import-from} clauses,
1442ASDF could tell that you depend on systems @code{closer-mop} (registered above),
1443@code{cl-ppcre} (package and system names match), and
1444@code{my-lib/src/macros} and @code{my-lib/src/variables}
1445(package and system names match, and they will be looked up hierarchically).
1446
1447The form @code{uiop:define-package} is supported as well as @code{defpackage},
1448and has many options that prove useful in this context,
1449such as @code{:use-reexport} and @code{:mix-reexport}
1450that allow for ``inheritance'' of symbols being exported.
1451
1452@node The object model of ASDF, Controlling where ASDF searches for systems, Defining systems with defsystem, Top
1453@comment  node-name,  next,  previous,  up
1454@chapter The object model of ASDF
1455
1456ASDF is designed in an object-oriented way from the ground up.
1457Both a system's structure and the operations that can be performed on systems
1458follow a extensible protocol.
1459
1460This allows the addition of behaviours:
1461for example, @code{cffi} adds support of special FFI description files
1462to interface with C libraries and of wrapper files to embed C code in Lisp;
1463@code{abcl-jar} supports creating Java JAR archives in ABCL;
1464and @code{poiu} supports for compiling code in parallel using background processes.
1465
1466This chapter deals with @code{component}s and @code{operation}s.
1467
1468A @code{component} represents an individual source file or a group of source files,
1469and the things that get transformed into.
1470A @code{system} is a component at the top level of the component hierarchy.
1471A @code{source-file} is a component representing a single source-file
1472and the successive output files into which it is transformed.
1473A @code{module} is an intermediate component itself grouping several other components,
1474themselves source-files or further modules.
1475
1476An @code{Operation} represents a transformation that can be performed on a component,
1477turning them from source files to intermediate results to final outputs.
1478
1479A pair of an @code{operation} and a @code{component} is called an @code{action}.
1480An @code{action} represents a particular build step to be @code{perform}ed,
1481after all its dependencies have been fulfilled.
1482In the ASDF model, actions depend on other actions.
1483The term @emph{action} itself was used by Kent Pitman in his old article,
1484but was only used by ASDF hackers starting with the ASDF 2;
1485but the concept is ubiquitous since the very beginning of ASDF 1,
1486though previously implicit.
1487
1488Then, there are many @emph{functions} available
1489to users, extenders and implementers of ASDF
1490to use, define or implement the activities
1491that are part of building your software.
1492Though they manipulate @code{action}s,
1493most of these functions do not take as an argument
1494a reified pair (a @code{cons} cell) of an operation and a component;
1495instead, they usually take two separate arguments,
1496which allows to take advantage of the power CLOS-style multiple dispatch
1497for fun and profit.
1498
1499There are many @emph{hooks} in which to add functionality,
1500by customizing the behavior of existing @emph{functions}.
1501
1502Last but not least is the notion of @emph{dependency} between two actions.
1503The structure of dependencies between actions is
1504a directed @emph{dependency graph}.
1505ASDF is invoked by being told to @emph{operate}
1506with some @emph{operation} on some toplevel @emph{system};
1507it will then @emph{traverse} the graph and build a @emph{plan}
1508that follows its structure.
1509To be successfully buildable, this graph of actions but be acyclic.
1510If, as a user, extender or implementer of ASDF, you fail
1511to keep the dependency graph without cycles,
1512ASDF will fail loudly as it eventually finds one.
1513To clearly distinguish the direction of dependencies,
1514ASDF 3 uses the words @emph{requiring} and @emph{required}
1515as applied to an action depending on the other:
1516the requiring action @code{depends-on} the completion of all required actions
1517before it may itself be @code{perform}ed.
1518
1519Using the @code{defsystem} syntax, users may easily express
1520direct dependencies along the graph of the object hierarchy:
1521between a component and its parent, its children, and its siblings.
1522By defining custom CLOS methods, you can express more elaborate dependencies as you wish.
1523Most common operations, such as @code{load-op}, @code{compile-op} or @code{load-source-op}
1524are automatically propagate ``downward'' the component hierarchy and are ``covariant'' with it:
1525to act the operation on the parent module, you must first act it on all the children components,
1526with the action on the parent being parent of the action on each child.
1527Other operations, such as @code{prepare-op} and @code{prepare-source-op}
1528(introduced in ASDF 3) are automatically propagated ``upward'' the component hierarchy
1529and are ``contravariant'' with it:
1530to perform the operation of preparing for compilation of a child component,
1531you must perform the operation of preparing for compilation of its parent component, and so on,
1532ensuring that all the parent's dependencies are (compiled and) loaded
1533before the child component may be compiled and loaded.
1534Yet other operations, such as @code{test-op} or @code{load-fasl-op}
1535remain at the system level, and are not propagated along the hierarchy,
1536but instead do something global on the system.
1537
1538@menu
1539* Operations::
1540* Components::
1541* Functions::
1542@end menu
1543
1544@node  Operations, Components, The object model of ASDF, The object model of ASDF
1545@comment  node-name,  next,  previous,  up
1546@section Operations
1547@cindex operation
1548
1549An @dfn{operation} object of the appropriate type is instantiated
1550whenever the user wants to do something with a system like
1551
1552@itemize
1553@item compile all its files
1554@item load the files into a running lisp environment
1555@item copy its source files somewhere else
1556@end itemize
1557
1558Operations can be invoked directly, or examined
1559to see what their effects would be without performing them.
1560There are a bunch of methods specialised on operation and component type
1561that actually do the grunt work.
1562
1563The operation object contains whatever state is relevant for this purpose
1564(perhaps a list of visited nodes, for example)
1565but primarily is a nice thing to specialise operation methods on
1566and easier than having them all be @code{EQL} methods.
1567
1568Operations are invoked on systems via @code{operate}.
1569@anchor{operate}
1570@deffn {Generic function} @code{operate} @var{operation} @var{system} @Arest @var{initargs} @Akey @code{force} @code{force-not} @code{verbose} @AallowOtherKeys
1571@deffnx {Generic function} @code{oos} @var{operation} @var{system} @Arest @var{initargs} @Akey @AallowOtherKeys
1572@code{operate} invokes @var{operation} on @var{system}.
1573@code{oos} is a synonym for @code{operate}.
1574
1575@var{operation} is a symbol that is passed, along with the supplied
1576@var{initargs}, to @code{make-instance} to create the operation object.
1577@var{system} is a system designator.
1578
1579The @var{initargs} are passed to the @code{make-instance} call
1580when creating the operation object.
1581Note that dependencies may cause the operation
1582to invoke other operations on the system or its components:
1583the new operations will be created
1584with the same @var{initargs} as the original one.
1585
1586If @var{force} is @code{:all}, then all systems
1587are forced to be recompiled even if not modified since last compilation.
1588If @var{force} is @code{t}, then only the system being loaded
1589is forced to be recompiled even if not modified since last compilation,
1590but other systems are not affected.
1591If @var{force} is a list, then it specifies a list of systems that
1592are forced to be recompiled even if not modified since last compilation.
1593If @var{force-not} is @code{:all}, then all systems
1594are forced not to be recompiled even if modified since last compilation.
1595If @var{force-not} is @code{t}, then only the system being loaded
1596is forced not to be recompiled even if modified since last compilation,
1597but other systems are not affected.
1598If @var{force-not} is a list, then it specifies a list of systems that
1599are forced not to be recompiled even if modified since last compilation.
1600@var{force} takes precedences over @var{force-not};
1601both of them apply to systems that are dependencies and were already compiled.
1602
1603To see what @code{operate} would do, you can use:
1604@example
1605(asdf:traverse operation-class system-name)
1606@end example
1607
1608@end deffn
1609
1610@menu
1611* Predefined operations of ASDF::
1612* Creating new operations::
1613@end menu
1614
1615@node Predefined operations of ASDF, Creating new operations, Operations, Operations
1616@comment  node-name,  next,  previous,  up
1617@subsection Predefined operations of ASDF
1618
1619All the operations described in this section are in the @code{asdf} package.
1620They are invoked via the @code{operate} generic function.
1621
1622@lisp
1623(asdf:operate 'asdf:@var{operation-name} :@var{system-name} @{@var{operation-options ...}@})
1624@end lisp
1625
1626@deffn Operation @code{compile-op}
1627
1628This operation compiles the specified component.
1629A @code{cl-source-file} will be @code{compile-file}'d.
1630All the children and dependencies of a system or module
1631will be recursively compiled by @code{compile-op}.
1632
1633@code{compile-op} depends on @code{prepare-op} which
1634itself depends on a @code{load-op} of all of a component's dependencies,
1635as well as of its parent's dependencies.
1636When @code{operate} is called on @code{compile-op},
1637all these dependencies will be loaded as well as compiled;
1638yet, some parts of the system main remain unloaded,
1639because nothing depends on them.
1640Use @code{load-op} to load a system.
1641@end deffn
1642
1643@deffn Operation @code{load-op}
1644
1645This operation loads the compiled code for a specified component.
1646A @code{cl-source-file} will have its compiled fasl @code{load}ed,
1647which fasl is the output of @code{compile-op} that @code{load-op} depends on.
1648All the children and dependencies of a system or module
1649will be recursively loaded by @code{load-op}.
1650
1651@code{load-op} depends on @code{prepare-op} which
1652itself depends on a @code{load-op} of all of a component's dependencies,
1653as well as of its parent's dependencies.
1654@end deffn
1655
1656@deffn Operation @code{prepare-op}
1657
1658This operation ensures that the dependencies of a component
1659and its recursive parents are loaded (as per @code{load-op}),
1660as a prerequisite before @code{compile-op} and @code{load-op} operations
1661may be performed on a given component.
1662@end deffn
1663
1664@deffn Operation @code{load-source-op}, @code{prepare-source-op}
1665
1666@code{load-source-op} will load the source for the files in a module
1667rather than they compiled fasl output.
1668It has a @code{prepare-source-op} analog to @code{prepare-op},
1669that ensures the dependencies are themselves loaded via @code{load-source-op}.
1670
1671There is no provision in ASDF for ensuring that
1672some components are always loaded as source, while others are always compiled.
1673While this idea often comes up in discussions,
1674it actually doesn't play well with either the linking model of ECL
1675or with various bundle operations (see below), and is eventually not workable;
1676also the dependency model of ASDF would have to be modified incompatibly
1677to allow for such trick.
1678If your code doesn't compile cleanly, fix it.
1679If compilation makes it slow, use @code{declaim} or @code{eval-when}
1680to adjust your compiler settings,
1681or eschew compilation by @code{eval}uating a quoted source form at load-time.
1682@end deffn
1683
1684@anchor{test-op}
1685@deffn Operation @code{test-op}
1686
1687This operation will perform some tests on the module.
1688The default method will do nothing.
1689The default dependency is to require
1690@code{load-op} to be performed on the module first.
1691The default @code{operation-done-p} is that the operation is @emph{never} done
1692---
1693we assume that if you invoke the @code{test-op},
1694you want to test the system, even if you have already done so.
1695
1696The results of this operation are not defined by ASDF.
1697It has proven difficult to define how the test operation
1698should signal its results to the user
1699in a way that is compatible with all of the various test libraries
1700and test techniques in use in the community.
1701
1702People typically define @code{test-op} methods like thus:
1703@example
1704(defmethod perform ((o asdf:test-op)
1705                    (s (eql (asdf:find-system @var{:my-system}))))
1706  (asdf:load-system @var{:my-system-test})
1707  (funcall (read-from-string "my-system-test:test-suite")))
1708@end example
1709
1710Using @code{load-system} in the perform method
1711rather than an @code{:in-order-to} dependency,
1712is sometimes necessary for backward compatibility with ASDF 2 and older,
1713to avoid circular dependencies that could arise
1714because of the way these old versions propagate dependencies.
1715
1716If you don't care for compatibility with ASDF 2,
1717you could use the following options in your @code{defsystem} form:
1718@example
1719  :in-order-to ((test-op (load-op :my-system-test)))
1720  :perform (test-op (o c) (symbol-call :my-system-test :test-suite))
1721@end example
1722@end deffn
1723
1724@deffn Operation @code{fasl-op}, @code{monolithic-fasl-op}, @code{load-fasl-op}, @code{binary-op}, @code{monolithic-binary-op}, @code{lib-op}, @code{monolithic-lib-op}, @code{dll-op}, @code{monolithic-dll-op}, @code{program-op}
1725
1726These are ``bundle'' operations, that can create a single-file ``bundle''
1727for all the contents of each system in an application,
1728or for the entire application.
1729
1730@code{fasl-op} will create a single fasl file for each of the systems needed,
1731grouping all its many fasls in one,
1732so you can deliver each system as a single fasl.
1733@code{monolithic-fasl-op} will create a single fasl file for target system
1734and all its dependencies,
1735so you can deliver your entire application as a single fasl.
1736@code{load-fasl-op} will load the output of @code{fasl-op}
1737(though if it the output is not up-to-date,
1738it will load the intermediate fasls indeed as part of building it);
1739this matters a lot on ECL, where the dynamic linking involved in loading
1740tens of individual fasls can be noticeably more expensive
1741than loading a single one.
1742
1743Once you have created a fasl with @code{fasl-op},
1744you can use @code{precompiled-system} to deliver it in a way
1745that is compatible with clients having dependencies on your system,
1746whether it is distributed as source or as a single binary;
1747the @file{.asd} file to be delivered with the fasl will look like this:
1748@example
1749(defsystem :mysystem :class :precompiled-system
1750    :fasl (some expression that will evaluate to a pathname))
1751@end example
1752Or you can use @code{binary-op} to let ASDF create such a system for you
1753as well as the @code{fasl-op} output, or @code{monolithic-binary-op}.
1754This allows you to deliver code for your systems or applications
1755as a single file.
1756Of course, if you want to test the result in the current image,
1757@emph{before} you try to use any newly created @file{.asd} files,
1758you should not forget to @code{(asdf:clear-configuration)}
1759or at least @code{(asdf:clear-source-registry)},
1760so it re-populates the source-registry from the filesystem.
1761
1762The @code{program-op} operation will create an executable program
1763from the specified system and its dependencies.
1764You can use UIOP for its pre-image-dump hooks, its post-image-restore hooks,
1765and its access to command-line arguments.
1766And you can specify an entry point @code{my-app:main}
1767by specifying in your @code{defsystem}
1768the option @code{:entry-point "my-app:main"}.
1769Depending on your implementation,
1770running @code{(asdf:operate 'asdf:program-op :my-app)}
1771may quit the current Lisp image upon completion.
1772See the example in
1773@file{test/hello-world-example.asd} and @file{test/hello.lisp},
1774as built and tested by
1775@file{test/test-program.script} and @file{test/make-hello-world.lisp}.
1776
1777There is also @code{lib-op}
1778for building a linkable @file{.a} file (Windows: @file{.lib})
1779from all linkable object dependencies (FFI files, and on ECL, Lisp files too),
1780and its monolithic equivalent @code{monolithic-lib-op}.
1781And there is also @code{dll-op}
1782(respectively its monolithic equivalent @code{monolithic-lib-op})
1783for building a linkable @file{.so} file
1784(Windows: @file{.dll}, MacOS X: @file{.dynlib})
1785to create a single dynamic library
1786for all the extra FFI code to be linked into each of your systems
1787(respectively your entire application).
1788
1789All these ``bundle'' operations are available since ASDF 3
1790on all actively supported Lisp implementations,
1791but may be unavailable on unmaintained legacy implementations.
1792This functionality was previously available for select implementations,
1793as part of a separate system @code{asdf-bundle},
1794itself descended from the ECL-only @code{asdf-ecl}.
1795
1796The pathname of the output of bundle operations
1797is subject to output-translation as usual,
1798unless the operation is equal to
1799the @code{:build-operation} argument to @code{defsystem}.
1800This behavior is not very satisfactory and may change in the future.
1801Maybe you have suggestions on how to better configure it?
1802@end deffn
1803
1804@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}
1805
1806These operation, as their respective names indicate,
1807consist in concatenating all @code{cl-source-file} source files in a system
1808(or in a system and all its dependencies, if monolithic),
1809in the order defined by dependencies,
1810then loading the result, or compiling then loading the result.
1811
1812These operations are useful to deliver a system or application
1813as a single source file,
1814and for testing that said file loads properly, or compiles then loads properly.
1815
1816ASDF itself is notably delivered as a single source file this way
1817using @code{monolithic-concatenate-source-op},
1818transcluding a prelude and the @code{uiop} library
1819before the @code{asdf/defsystem} system itself.
1820@end deffn
1821
1822
1823@node  Creating new operations,  , Predefined operations of ASDF, Operations
1824@comment  node-name,  next,  previous,  up
1825@subsection Creating new operations
1826
1827ASDF was designed to be extensible in an object-oriented fashion.
1828To teach ASDF new tricks, a programmer can implement the behaviour he wants
1829by creating a subclass of @code{operation}.
1830
1831ASDF's pre-defined operations are in no way ``privileged'',
1832but it is requested that developers never use the @code{asdf} package
1833for operations they develop themselves.
1834The rationale for this rule is that we don't want to establish a
1835``global asdf operation name registry'',
1836but also want to avoid name clashes.
1837
1838Your operation @emph{must} usually provide methods
1839for one or more of the following generic functions:
1840
1841@itemize
1842
1843@item @code{perform}
1844Unless your operation, like @code{prepare-op},
1845is for dependency propagation only,
1846the most important function for which to define a method
1847is usually @code{perform},
1848which will be called to perform the operation on a specified component,
1849after all dependencies have been performed.
1850
1851The @code{perform} method must call @code{output-files} (see below)
1852to find out where to put its files,
1853because the user is allowed to override the method
1854or tweak the output-translation mechanism.
1855Perform should only use the primary value returned by @code{output-files}.
1856If one and only one output file is expected,
1857it can call @code{output-file} that checks that this is the case
1858and returns the first and only list element.
1859
1860@item @code{output-files}
1861If your perform method has any output,
1862you must define a method for this function.
1863for ASDF to determine where the outputs of performing operation lie.
1864
1865Your method may return two values, a list of pathnames, and a boolean.
1866If the boolean is @code{nil} (or you fail to return multiple values),
1867then enclosing @code{:around} methods may translate these pathnames,
1868e.g. to ensure object files are somehow stored
1869in some implementation-dependent cache.
1870If the boolean is @code{t} then the pathnames are marked
1871not be translated by the enclosing @code{:around} method.
1872
1873@item @code{component-depends-on}
1874If the action of performing the operation on a component has dependencies,
1875you must define a method on @code{component-depends-on}.
1876
1877Your method will take as specialized arguments
1878an operation and a component which together identify an action,
1879and return a list of entries describing actions that this action depends on.
1880The format of entries is described below.
1881
1882It is @emph{strongly} advised that
1883you should always append the results of @code{(call-next-method)}
1884to the results of your method,
1885or ``interesting'' failures will likely occur,
1886unless you're a true specialist of ASDF internals.
1887It is unhappily too late to compatibly use the @code{append} method combination,
1888but conceptually that's the protocol that is being manually implemented.
1889
1890Each entry returned by @code{component-depends-on} is itself a list.
1891
1892The first element of an entry is an operation designator:
1893either an operation object designating itself, or
1894a symbol that names an operation class
1895(that ASDF will instantiate using @code{make-operation}).
1896For instance, @code{load-op}, @code{compile-op} and @code{prepare-op}
1897are common such names, denoting the respective operations.
1898
1899The rest of each entry is a list of component designators:
1900either a component object designating itself,
1901or an identifier to be used with @code{find-component}.
1902@code{find-component} will be called with the current component's parent as parent,
1903and the identifier as second argument.
1904The identifier is typically a string,
1905a symbol (to be downcased as per @code{coerce-name}),
1906or a list of strings or symbols.
1907In particular, the empty list @code{nil} denotes the parent itself.
1908
1909@end itemize
1910
1911An operation @emph{may} provide methods for the following generic functions:
1912
1913@itemize
1914
1915@item @code{input-files}
1916A method for this function is often not needed,
1917since ASDF has a pretty clever default @code{input-files} mechanism.
1918You only need create a method if there are multiple ultimate input files,
1919and/or the bottom one doesn't depend
1920on the @code{component-pathname} of the component.
1921
1922@item @code{operation-done-p}
1923You only need to define a method on that function
1924if you can detect conditions that invalidate previous runs of the operation,
1925even though no filesystem timestamp has changed,
1926in which case you return @code{nil} (the default is @code{t}).
1927
1928For instance, the method for @code{test-op} always returns @code{nil},
1929so that tests are always run afresh.
1930Of course, the @code{test-op} for your system could depend
1931on a deterministically repeatable @code{test-report-op},
1932and just read the results from the report files,
1933in which case you could have this method return @code{t}.
1934
1935@end itemize
1936
1937Operations that print output should send that output to the standard
1938CL stream @code{*standard-output*}, as the Lisp compiler and loader do.
1939
1940@node Components, Functions, Operations, The object model of ASDF
1941@comment  node-name,  next,  previous,  up
1942@section Components
1943@cindex component
1944@cindex system
1945@cindex system designator
1946@cindex component designator
1947@vindex *system-definition-search-functions*
1948
1949A @dfn{component} represents a source file or
1950(recursively) a collection of components.
1951A @dfn{system} is (roughly speaking) a top-level component
1952that can be found via @code{find-system}.
1953
1954A @dfn{system designator} is a system itself,
1955or a string or symbol that behaves just like any other component name
1956(including with regard to the case conversion rules for component names).
1957
1958A @dfn{component designator}, relative to a base component,
1959is either a component itself,
1960or a string or symbol,
1961or a list of designators.
1962
1963@defun find-system system-designator @Aoptional (error-p t)
1964
1965Given a system designator, @code{find-system} finds and returns a system.
1966If no system is found, an error of type
1967@code{missing-component} is thrown,
1968or @code{nil} is returned if @code{error-p} is false.
1969
1970To find and update systems, @code{find-system} funcalls each element
1971in the @code{*system-definition-search-functions*} list,
1972expecting a pathname to be returned, or a system object,
1973from which a pathname may be extracted, and that will be registered.
1974The resulting pathname (if any) is loaded
1975if one of the following conditions is true:
1976
1977@itemize
1978@item
1979there is no system of that name in memory
1980@item
1981the pathname is different from that which was previously loaded
1982@item
1983the file's @code{last-modified} time exceeds the @code{last-modified} time
1984of the system in memory
1985@end itemize
1986
1987When system definitions are loaded from @file{.asd} files,
1988a new scratch package is created for them to load into,
1989so that different systems do not overwrite each others operations.
1990The user may also wish to (and is recommended to)
1991include @code{defpackage} and @code{in-package} forms
1992in his system definition files, however,
1993so that they can be loaded manually if need be.
1994
1995The default value of @code{*system-definition-search-functions*}
1996is a list of two functions.
1997The first function looks in each of the directories given
1998by evaluating members of @code{*central-registry*}
1999for a file whose name is the name of the system and whose type is @file{asd}.
2000The first such file is returned,
2001whether or not it turns out to actually define the appropriate system.
2002The second function does something similar,
2003for the directories specified in the @code{source-registry}.
2004Hence, it is strongly advised to define a system
2005@var{foo} in the corresponding file @var{foo.asd}.
2006@end defun
2007
2008@defun find-component base path
2009
2010Given a @var{base} component (or designator for such),
2011and a @var{path}, find the component designated by the @var{path}
2012starting from the @var{base}.
2013
2014If @var{path} is a component object, it designates itself,
2015independently from the base.
2016
2017If @var{path} is a string, or symbol denoting a string via @code{coerce-name},
2018then @var{base} is resolved to a component object,
2019which must be a system or module,
2020and the designated component is the child named by the @var{path}.
2021
2022If @var{path} is a @code{cons} cell,
2023@code{find-component} with the base and the @code{car} of the @var{path},
2024and the resulting object is used as the base for a tail call
2025to @code{find-component} with the @code{car} of the @var{path}.
2026
2027If @var{base} is a component object, it designates itself.
2028
2029If @var{base} is null, then @var{path} is used as the base, with @code{nil} as the path.
2030
2031If @var{base} is a string, or symbol denoting a string via @code{coerce-name},
2032it designates a system as per @code{find-system}.
2033
2034If @var{base} is a @code{cons} cell, it designates the component found by
2035@code{find-component} with its @code{car} as base and @code{cdr} as path.
2036@end defun
2037
2038
2039@menu
2040* Common attributes of components::
2041* Pre-defined subclasses of component::
2042* Creating new component types::
2043@end menu
2044
2045@node  Common attributes of components, Pre-defined subclasses of component, Components, Components
2046@comment  node-name,  next,  previous,  up
2047@subsection Common attributes of components
2048
2049All components, regardless of type, have the following attributes.
2050All attributes except @code{name} are optional.
2051
2052@subsubsection Name
2053
2054A component name is a string or a symbol.
2055If a symbol, its name is taken and lowercased.
2056
2057Unless overridden by a @code{:pathname} attribute,
2058the name will be interpreted as a pathname specifier according
2059to a Unix-style syntax.
2060@xref{The defsystem grammar,,Pathname specifiers}.
2061
2062@subsubsection Version identifier
2063@findex version-satisfies
2064@cindex :version
2065
2066This optional attribute specifies a version for the current component.
2067The version should typically be a string of integers separated by dots,
2068for example @samp{1.0.11}.
2069For more information on version specifiers, see @ref{The defsystem grammar}.
2070
2071A version may then be queried by the generic function @code{version-satisfies},
2072to see if @code{:version} dependencies are satisfied,
2073and when specifying dependencies, a constraint of minimal version to satisfy
2074can be specified using e.g. @code{(:version "mydepname" "1.0.11")}.
2075
2076Note that in the wild, we typically see version numbering
2077only on components of type @code{system}.
2078Presumably it is much less useful within a given system,
2079wherein the library author is responsible to keep the various files in synch.
2080
2081@subsubsection Required features
2082
2083Traditionally defsystem users have used @code{#+} reader conditionals
2084to include or exclude specific per-implementation files.
2085This means that any single implementation cannot read the entire system,
2086which becomes a problem if it doesn't wish to compile it,
2087but instead for example to create an archive file containing all the sources,
2088as it will omit to process the system-dependent sources for other systems.
2089
2090Each component in an asdf system may therefore specify using @code{:if-feature}
2091a feature expression using the same syntax as @code{#+} does,
2092such that any reference to the component will be ignored
2093during compilation, loading and/or linking if the expression evaluates to false.
2094Since the expression is read by the normal reader,
2095you must explicitly prefix your symbols with @code{:} so they be read as keywords;
2096this is as contrasted with the @code{#+} syntax
2097that implicitly reads symbols in the keyword package by default.
2098
2099For instance, @code{:if-feature (:and :x86 (:or :sbcl :cmu :scl))} specifies that
2100the given component is only to be compiled and loaded
2101when the implementation is SBCL, CMUCL or Scieneer CL on an x86 machine.
2102You can not write it as @code{:if-feature (and x86 (or sbcl cmu scl))}
2103since the symbols would presumably fail to be read as keywords.
2104
2105@subsubsection Dependencies
2106
2107This attribute specifies dependencies of the component on its siblings.
2108It is optional but often necessary.
2109
2110There is an excitingly complicated relationship between the initarg
2111and the method that you use to ask about dependencies
2112
2113Dependencies are between (operation component) pairs.
2114In your initargs for the component, you can say
2115
2116@lisp
2117:in-order-to ((compile-op (load-op "a" "b") (compile-op "c"))
2118              (load-op (load-op "foo")))
2119@end lisp
2120
2121This means the following things:
2122@itemize
2123@item
2124before performing compile-op on this component, we must perform
2125load-op on @var{a} and @var{b}, and compile-op on @var{c},
2126@item
2127before performing @code{load-op}, we have to load @var{foo}
2128@end itemize
2129
2130The syntax is approximately
2131
2132@verbatim
2133(this-op @{(other-op required-components)@}+)
2134
2135simple-component-name := string
2136                      |  symbol
2137
2138required-components := simple-component-name
2139                     | (required-components required-components)
2140
2141component-name := simple-component-name
2142                | (:version simple-component-name minimum-version-object)
2143@end verbatim
2144
2145Side note:
2146
2147This is on a par with what ACL defsystem does.
2148mk-defsystem is less general: it has an implied dependency
2149
2150@verbatim
2151  for all source file x, (load x) depends on (compile x)
2152@end verbatim
2153
2154and using a @code{:depends-on} argument to say that @var{b} depends on
2155@var{a} @emph{actually} means that
2156
2157@verbatim
2158  (compile b) depends on (load a)
2159@end verbatim
2160
2161This is insufficient for e.g. the McCLIM system, which requires that
2162all the files are loaded before any of them can be compiled ]
2163
2164End side note
2165
2166In ASDF, the dependency information for a given component and operation
2167can be queried using @code{(component-depends-on operation component)},
2168which returns a list
2169
2170@lisp
2171((load-op "a") (load-op "b") (compile-op "c") ...)
2172@end lisp
2173
2174@code{component-depends-on} can be subclassed for more specific
2175component/operation types: these need to @code{(call-next-method)}
2176and append the answer to their dependency, unless
2177they have a good reason for completely overriding the default dependencies.
2178
2179If it weren't for CLISP, we'd be using @code{LIST} method
2180combination to do this transparently.
2181But, we need to support CLISP.
2182If you have the time for some CLISP hacking,
2183I'm sure they'd welcome your fixes.
2184@c Doesn't CLISP now support LIST method combination?
2185
2186A minimal version can be specified for a component you depend on
2187(typically another system), by specifying @code{(:version "other-system" "1.2.3")}
2188instead of simply @code{"other-system"} as the dependency.
2189See the discussion of the semantics of @code{:version}
2190in the defsystem grammar.
2191
2192@c FIXME: Should have cross-reference to "Version specifiers" in the
2193@c defsystem grammar, but the cross-referencing is so broken by
2194@c insufficient node breakdown that I have not put one in.
2195
2196
2197@subsubsection pathname
2198
2199This attribute is optional and if absent (which is the usual case),
2200the component name will be used.
2201
2202@xref{The defsystem grammar,,Pathname specifiers},
2203for an explanation of how this attribute is interpreted.
2204
2205Note that the @code{defsystem} macro (used to create a ``top-level'' system)
2206does additional processing to set the filesystem location of
2207the top component in that system.
2208This is detailed elsewhere. @xref{Defining systems with defsystem}.
2209
2210
2211@subsubsection properties
2212
2213This attribute is optional.
2214
2215Packaging systems often require information about files or systems
2216in addition to that specified by ASDF's pre-defined component attributes.
2217Programs that create vendor packages out of ASDF systems therefore
2218have to create ``placeholder'' information to satisfy these systems.
2219Sometimes the creator of an ASDF system may know the additional
2220information and wish to provide it directly.
2221
2222@code{(component-property component property-name)} and
2223associated @code{setf} method will allow
2224the programmatic update of this information.
2225Property names are compared as if by @code{EQL},
2226so use symbols or keywords or something.
2227
2228@menu
2229* Pre-defined subclasses of component::
2230* Creating new component types::
2231@end menu
2232
2233@node Pre-defined subclasses of component, Creating new component types, Common attributes of components, Components
2234@comment  node-name,  next,  previous,  up
2235@subsection Pre-defined subclasses of component
2236
2237@deffn Component source-file
2238
2239A source file is any file that the system does not know how to
2240generate from other components of the system.
2241
2242Note that this is not necessarily the same thing as
2243``a file containing data that is typically fed to a compiler''.
2244If a file is generated by some pre-processor stage
2245(e.g. a @file{.h} file from @file{.h.in} by autoconf)
2246then it is not, by this definition, a source file.
2247Conversely, we might have a graphic file
2248that cannot be automatically regenerated,
2249or a proprietary shared library that we received as a binary:
2250these do count as source files for our purposes.
2251
2252Subclasses of source-file exist for various languages.
2253@emph{FIXME: describe these.}
2254@end deffn
2255
2256@deffn Component module
2257
2258A module is a collection of sub-components.
2259
2260A module component has the following extra initargs:
2261
2262@itemize
2263@item
2264@code{:components} the components contained in this module
2265
2266@item
2267@code{:default-component-class}
2268All children components which don't specify their class explicitly
2269are inferred to be of this type.
2270
2271@item
2272@code{:if-component-dep-fails}
2273This attribute was removed in ASDF 3. Do not use it.
2274Use @code{:if-feature} instead.
2275
2276@item
2277@code{:serial} When this attribute is set,
2278each subcomponent of this component is assumed to depend on all subcomponents
2279before it in the list given to @code{:components}, i.e.
2280all of them are loaded before a compile or load operation is performed on it.
2281
2282@end itemize
2283
2284The default operation knows how to traverse a module, so
2285most operations will not need to provide methods specialised on modules.
2286
2287@code{module} may be subclassed to represent components such as
2288foreign-language linked libraries or archive files.
2289@end deffn
2290
2291@deffn Component system
2292
2293@code{system} is a subclass of @code{module}.
2294
2295A system is a module with a few extra attributes for documentation
2296purposes; these are given elsewhere.
2297@xref{The defsystem grammar}.
2298
2299Users can create new classes for their systems:
2300the default @code{defsystem} macro takes a @code{:class} keyword argument.
2301@end deffn
2302
2303@node  Creating new component types,  , Pre-defined subclasses of component, Components
2304@comment  node-name,  next,  previous,  up
2305@subsection Creating new component types
2306
2307New component types are defined by subclassing one of the existing
2308component classes and specializing methods on the new component class.
2309
2310@emph{FIXME: this should perhaps be explained more throughly,
2311not only by example ...}
2312
2313As an example, suppose we have some implementation-dependent
2314functionality that we want to isolate
2315in one subdirectory per Lisp implementation our system supports.
2316We create a subclass of
2317@code{cl-source-file}:
2318
2319@lisp
2320(defclass unportable-cl-source-file (cl-source-file)
2321  ())
2322@end lisp
2323
2324Function @code{asdf:implementation-type} (exported since 2.014.14)
2325gives us the name of the subdirectory.
2326All that's left is to define how to calculate the pathname
2327of an @code{unportable-cl-source-file}.
2328
2329@lisp
2330(defmethod component-pathname ((component unportable-cl-source-file))
2331  (merge-pathnames*
2332   (parse-unix-namestring (format nil "~(~A~)/" (asdf:implementation-type)))
2333   (call-next-method)))
2334@end lisp
2335
2336The new component type is used in a @code{defsystem} form in this way:
2337
2338@lisp
2339(defsystem :foo
2340    :components
2341    ((:file "packages")
2342     ...
2343     (:unportable-cl-source-file "threads"
2344      :depends-on ("packages" ...))
2345     ...
2346    )
2347@end lisp
2348
2349@node Functions,  , Components, The object model of ASDF
2350@comment  node-name,  next,  previous,  up
2351@section Functions
2352@findex version-satisfies
2353
2354@deffn version-satisfies @var{version} @var{version-spec}
2355Does @var{version} satisfy the @var{version-spec}.  A generic function.
2356ASDF provides built-in methods for @var{version} being a @code{component} or @code{string}.
2357@var{version-spec} should be a string.
2358If it's a component, its version is extracted as a string before further processing.
2359
2360A version string satisfies the version-spec if after parsing,
2361the former is no older than the latter.
2362Therefore @code{"1.9.1"}, @code{"1.9.2"} and @code{"1.10"} all satisfy @code{"1.9.1"},
2363but @code{"1.8.4"} or @code{"1.9"} do not.
2364For more information about how @code{version-satisfies} parses and interprets
2365version strings and specifications,
2366@pxref{The defsystem grammar} (version specifiers) and
2367@ref{Common attributes of components}.
2368
2369Note that in versions of ASDF prior to 3.0.1,
2370including the entire ASDF 1 and ASDF 2 series,
2371@code{version-satisfies} would also require that the version and the version-spec
2372have the same major version number (the first integer in the list);
2373if the major version differed, the version would be considered as not matching the spec.
2374But that feature was not documented, therefore presumably not relied upon,
2375whereas it was a nuisance to several users.
2376Starting with ASDF 3.0.1,
2377@code{version-satisfies} does not treat the major version number specially,
2378and returns T simply if the first argument designates a version that isn't older
2379than the one specified as a second argument.
2380If needs be, the @code{(:version ...)} syntax for specifying dependencies
2381could be in the future extended to specify an exclusive upper bound for compatible versions
2382as well as an inclusive lower bound.
2383@end deffn
2384
2385@node Controlling where ASDF searches for systems, Controlling where ASDF saves compiled files, The object model of ASDF, Top
2386@comment  node-name,  next,  previous,  up
2387@chapter Controlling where ASDF searches for systems
2388
2389@section Configurations
2390
2391Configurations specify paths where to find system files.
2392
2393@enumerate
2394
2395@item
2396The search registry may use some hardcoded wrapping registry specification.
2397This allows some implementations (notably SBCL) to specify where to find
2398some special implementation-provided systems that
2399need to precisely match the version of the implementation itself.
2400
2401@item
2402An application may explicitly initialize the source-registry configuration
2403using the configuration API
2404(@pxref{Controlling where ASDF searches for systems,Configuration API,Configuration API}, below)
2405in which case this takes precedence.
2406It may itself compute this configuration from the command-line,
2407from a script, from its own configuration file, etc.
2408
2409@item
2410The source registry will be configured from
2411the environment variable @code{CL_SOURCE_REGISTRY} if it exists.
2412
2413@item
2414The source registry will be configured from
2415user configuration file
2416@file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf}
2417(which defaults to
2418@file{~/.config/common-lisp/source-registry.conf})
2419if it exists.
2420
2421@item
2422The source registry will be configured from
2423user configuration directory
2424@file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf.d/}
2425(which defaults to
2426@file{~/.config/common-lisp/source-registry.conf.d/})
2427if it exists.
2428
2429@item
2430The source registry will be configured from
2431system configuration file
2432@file{/etc/common-lisp/source-registry.conf}
2433if it exists/
2434
2435@item
2436The source registry will be configured from
2437system configuration directory
2438@file{/etc/common-lisp/source-registry.conf.d/}
2439if it exists.
2440
2441@item
2442The source registry will be configured from a default configuration.
2443This configuration may allow for implementation-specific systems
2444to be found, for systems to be found the current directory
2445(at the time that the configuration is initialized) as well as
2446@code{:directory} entries for @file{$XDG_DATA_DIRS/common-lisp/systems/} and
2447@code{:tree} entries for @file{$XDG_DATA_DIRS/common-lisp/source/}.
2448For instance, SBCL will include directories for its contribs
2449when it can find them; it will look for them where SBCL was installed,
2450or at the location specified by the @code{SBCL_HOME} environment variable.
2451
2452@end enumerate
2453
2454Each of these configurations is specified as an s-expression
2455in a trivial domain-specific language (defined below).
2456Additionally, a more shell-friendly syntax is available
2457for the environment variable (defined yet below).
2458
2459Each of these configurations is only used if the previous
2460configuration explicitly or implicitly specifies that it
2461includes its inherited configuration.
2462
2463Additionally, some implementation-specific directories
2464may be automatically prepended to whatever directories are specified
2465in configuration files, no matter if the last one inherits or not.
2466
2467
2468@section Truenames and other dangers
2469
2470One great innovation of the original ASDF was its ability to leverage
2471@code{CL:TRUENAME} to locate where your source code was and where to build it,
2472allowing for symlink farms as a simple but effective configuration mechanism
2473that is easy to control programmatically.
2474ASDF 3 still supports this configuration style, and it is enabled by default;
2475however we recommend you instead use
2476our source-registry configuration mechanism described below,
2477because it is easier to setup in a portable way across users and implementations.
2478
2479Addtionally, some people dislike truename,
2480either because it is very slow on their system, or
2481because they are using content-addressed storage where the truename of a file
2482is related to a digest of its individual contents,
2483and not to other files in the same intended project.
2484For these people, ASDF 3 allows to eschew the @code{TRUENAME} mechanism,
2485by setting the variable @var{asdf:*resolve-symlinks*} to @code{nil}.
2486
2487PS: Yes, if you haven't read Vernor Vinge's short but great classic
2488``True Names... and Other Dangers'' then you're in for a treat.
2489
2490
2491@section XDG base directory
2492
2493Note that we purport to respect the XDG base directory specification
2494as to where configuration files are located,
2495where data files are located,
2496where output file caches are located.
2497Mentions of XDG variables refer to that document.
2498
2499@url{http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html}
2500
2501This specification allows the user to specify some environment variables
2502to customize how applications behave to his preferences.
2503
2504On Windows platforms, when not using Cygwin,
2505instead of the XDG base directory specification,
2506we try to use folder configuration from the registry regarding
2507@code{Common AppData} and similar directories.
2508Since support for querying the Windows registry
2509is not possible to do in reasonable amounts of portable Common Lisp code,
2510ASDF 3 relies on the environment variables that Windows usually exports.
2511
2512@section Backward Compatibility
2513
2514For backward compatibility as well as to provide a practical backdoor for hackers,
2515ASDF will first search for @code{.asd} files in the directories specified in
2516@code{asdf:*central-registry*}
2517before it searches in the source registry above.
2518
2519@xref{Configuring ASDF,,Configuring ASDF to find your systems --- old style}.
2520
2521By default, @code{asdf:*central-registry*} will be empty.
2522
2523This old mechanism will therefore not affect you if you don't use it,
2524but will take precedence over the new mechanism if you do use it.
2525
2526@section Configuration DSL
2527
2528Here is the grammar of the s-expression (SEXP) DSL for source-registry
2529configuration:
2530
2531@c FIXME: This is too wide for happy compilation into pdf.
2532
2533@example
2534;; A configuration is a single SEXP starting with keyword :source-registry
2535;; followed by a list of directives.
2536CONFIGURATION := (:source-registry DIRECTIVE ...)
2537
2538;; A directive is one of the following:
2539DIRECTIVE :=
2540    ;; INHERITANCE DIRECTIVE:
2541    ;; Your configuration expression MUST contain
2542    ;; exactly one of either of these:
2543    :inherit-configuration | ; splices inherited configuration (often specified last)
2544    :ignore-inherited-configuration | ; drop inherited configuration (specified anywhere)
2545
2546    ;; forward compatibility directive (since ASDF 2.011.4), useful when
2547    ;; you want to use new configuration features but have to bootstrap a
2548    ;; the newer required ASDF from an older release that doesn't sport said features:
2549    :ignore-invalid-entries | ; drops subsequent invalid entries instead of erroring out
2550
2551    ;; add a single directory to be scanned (no recursion)
2552    (:directory DIRECTORY-PATHNAME-DESIGNATOR) |
2553
2554    ;; add a directory hierarchy, recursing but excluding specified patterns
2555    (:tree DIRECTORY-PATHNAME-DESIGNATOR) |
2556
2557    ;; override the defaults for exclusion patterns
2558    (:exclude EXCLUSION-PATTERN ...) |
2559    ;; augment the defaults for exclusion patterns
2560    (:also-exclude EXCLUSION-PATTERN ...) |
2561    ;; Note that the scope of a an exclude pattern specification is
2562    ;; the rest of the current configuration expression or file.
2563
2564    ;; splice the parsed contents of another config file
2565    (:include REGULAR-FILE-PATHNAME-DESIGNATOR) |
2566
2567    ;; This directive specifies that some default must be spliced.
2568    :default-registry
2569
2570REGULAR-FILE-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a file
2571DIRECTORY-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a directory name
2572
2573PATHNAME-DESIGNATOR :=
2574    NIL | ;; Special: skip this entry.
2575    ABSOLUTE-COMPONENT-DESIGNATOR ;; see pathname DSL
2576
2577EXCLUSION-PATTERN := a string without wildcards, that will be matched exactly
2578  against the name of a any subdirectory in the directory component
2579        of a path. e.g. @code{"_darcs"} will match @file{#p"/foo/bar/_darcs/src/bar.asd"}
2580@end example
2581
2582Pathnames are designated using another DSL,
2583shared with the output-translations configuration DSL below.
2584The DSL is resolved by the function @code{asdf::resolve-location},
2585to be documented and exported at some point in the future.
2586
2587@example
2588ABSOLUTE-COMPONENT-DESIGNATOR :=
2589    (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...) |
2590    STRING | ;; namestring (better be absolute or bust, directory assumed where applicable).
2591             ;; In output-translations, directory is assumed and **/*.*.* added if it's last.
2592             ;; On MCL, a MacOSX-style POSIX namestring (for MacOS9 style, use #p"...");
2593             ;; Note that none of the above applies to strings used in *central-registry*,
2594             ;; which doesn't use this DSL: they are processed as normal namestrings.
2595             ;; however, you can compute what you put in the *central-registry*
2596             ;; based on the results of say (asdf::resolve-location "/Users/fare/cl/cl-foo/")
2597    PATHNAME | ;; pathname (better be an absolute path, or bust)
2598               ;; In output-translations, unless followed by relative components,
2599               ;; it better have appropriate wildcards, as in **/*.*.*
2600    :HOME | ;; designates the user-homedir-pathname ~/
2601    :USER-CACHE | ;; designates the default location for the user cache
2602    :HERE | ;; designates the location of the configuration file
2603            ;; (or *default-pathname-defaults*, if invoked interactively)
2604    :ROOT ;; magic, for output-translations source only: paths that are relative
2605          ;; to the root of the source host and device
2606    ;; Not valid anymore: :SYSTEM-CACHE (was a security hazard)
2607
2608RELATIVE-COMPONENT-DESIGNATOR :=
2609    (RELATIVE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...) |
2610    STRING | ;; relative directory pathname as interpreted by parse-unix-namestring.
2611             ;; In output translations, if last component, **/*.*.* is added
2612    PATHNAME | ;; pathname; unless last component, directory is assumed.
2613    :IMPLEMENTATION | ;; directory based on implementation, e.g. sbcl-1.0.45-linux-x64
2614    :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl
2615    :DEFAULT-DIRECTORY | ;; a relativized version of the default directory
2616    :*/ | ;; any direct subdirectory (since ASDF 2.011.4)
2617    :**/ | ;; any recursively inferior subdirectory (since ASDF 2.011.4)
2618    :*.*.* | ;; any file (since ASDF 2.011.4)
2619    ;; Not supported (anymore): :UID and :USERNAME
2620@end example
2621
2622For instance, as a simple case, my @file{~/.config/common-lisp/source-registry.conf},
2623which is the default place ASDF looks for this configuration, once contained:
2624@example
2625(:source-registry
2626  (:tree (:home "cl")) ;; will expand to e.g. "/home/joeluser/cl/"
2627  :inherit-configuration)
2628@end example
2629
2630@section Configuration Directories
2631
2632Configuration directories consist in files each containing
2633a list of directives without any enclosing @code{(:source-registry ...)} form.
2634The files will be sorted by namestring as if by @code{string<} and
2635the lists of directives of these files with be concatenated in order.
2636An implicit @code{:inherit-configuration} will be included
2637at the @emph{end} of the list.
2638
2639This allows for packaging software that has file granularity
2640(e.g. Debian's @code{dpkg} or some future version of @code{clbuild})
2641to easily include configuration information about distributed software.
2642
2643The convention is that, for sorting purposes,
2644the names of files in such a directory begin with two digits
2645that determine the order in which these entries will be read.
2646Also, the type of these files is conventionally @code{"conf"}
2647and as a limitation to some implementations (e.g. GNU clisp),
2648the type cannot be @code{nil}.
2649
2650Directories may be included by specifying a directory pathname
2651or namestring in an @code{:include} directive, e.g.:
2652
2653@example
2654  (:include "/foo/bar/")
2655@end example
2656
2657Hence, to achieve the same effect as
2658my example @file{~/.config/common-lisp/source-registry.conf} above,
2659I could simply create a file
2660@file{~/.config/common-lisp/source-registry.conf.d/33-home-fare-cl.conf}
2661alone in its directory with the following contents:
2662@example
2663(:tree "/home/fare/cl/")
2664@end example
2665
2666@subsection The :here directive
2667
2668The @code{:here} directive is an absolute pathname designator that
2669refers to the directory containing the configuration file currently
2670being processed.
2671
2672The @code{:here} directive is intended to simplify the delivery of
2673complex CL systems, and for easy configuration of projects shared through
2674revision control systems, in accordance with our design principle that
2675each participant should be able to provide all and only the information
2676available to him or her.
2677
2678Consider a person X who has set up the source code repository for a
2679complex project with a master directory @file{dir/}.  Ordinarily, one
2680might simply have the user add a directive that would look something
2681like this:
2682@example
2683   (:tree  "path/to/dir")
2684@end example
2685But what if X knows that there are very large subtrees
2686under dir that are filled with, e.g., Java source code, image files for
2687icons, etc.?  All of the asdf system definitions are contained in the
2688subdirectories @file{dir/src/lisp/} and @file{dir/extlib/lisp/}, and
2689these are the only directories that should be searched.
2690
2691In this case, X can put into @file{dir/} a file @file{asdf.conf} that
2692contains the following:
2693@example
2694(:source-registry
2695   (:tree (:here "src/lisp/"))
2696   (:tree (:here "extlib/lisp"))
2697   (:directory (:here "outlier/")))
2698@end example
2699
2700Then when someone else (call her Y) checks out a copy of this
2701repository, she need only add
2702@example
2703(:include "/path/to/my/checkout/directory/asdf.conf")
2704@end example
2705to one of her previously-existing asdf source location configuration
2706files, or invoke @code{initialize-source-registry} with a configuration
2707form containing that s-expression.  ASDF will find the .conf file that X
2708has provided, and then set up source locations within the working
2709directory according to X's (relative) instructions.
2710
2711@section Shell-friendly syntax for configuration
2712
2713When considering environment variable @code{CL_SOURCE_REGISTRY}
2714ASDF will skip to next configuration if it's an empty string.
2715It will @code{READ} the string as a SEXP in the DSL
2716if it begins with a paren @code{(}
2717and it will be interpreted much like @code{TEXINPUTS}
2718list of paths, where
2719
2720  * paths are separated
2721   by a @code{:} (colon) on Unix platforms (including cygwin),
2722   by a @code{;} (semicolon) on other platforms (mainly, Windows).
2723
2724  * each entry is a directory to add to the search path.
2725
2726  * if the entry ends with a double slash @code{//}
2727    then it instead indicates a tree in the subdirectories
2728    of which to recurse.
2729
2730  * if the entry is the empty string (which may only appear once),
2731    then it indicates that the inherited configuration should be
2732    spliced there.
2733
2734
2735@section Search Algorithm
2736@vindex *default-source-registry-exclusions*
2737
2738In case that isn't clear, the semantics of the configuration is that
2739when searching for a system of a given name,
2740directives are processed in order.
2741
2742When looking in a directory, if the system is found, the search succeeds,
2743otherwise it continues.
2744
2745When looking in a tree, if one system is found, the search succeeds.
2746If multiple systems are found, the consequences are unspecified:
2747the search may succeed with any of the found systems,
2748or an error may be raised.
2749ASDF currently returns the first system found,
2750XCVB currently raised an error.
2751If none is found, the search continues.
2752
2753Exclude statements specify patterns of subdirectories
2754the systems from which to ignore.
2755Typically you don't want to use copies of files kept by such
2756version control systems as Darcs.
2757Exclude statements are not propagated to further included or inherited
2758configuration files or expressions;
2759instead the defaults are reset around every configuration statement
2760to the default defaults from @code{asdf::*default-source-registry-exclusions*}.
2761
2762Include statements cause the search to recurse with the path specifications
2763from the file specified.
2764
2765An inherit-configuration statement cause the search to recurse with the path
2766specifications from the next configuration
2767(@pxref{Controlling where ASDF searches for systems,,Configurations} above).
2768
2769
2770@section Caching Results
2771
2772The implementation is allowed to either eagerly compute the information
2773from the configurations and file system, or to lazily re-compute it
2774every time, or to cache any part of it as it goes.
2775To explicitly flush any information cached by the system, use the API below.
2776
2777
2778@section Configuration API
2779
2780The specified functions are exported from your build system's package.
2781Thus for ASDF the corresponding functions are in package ASDF,
2782and for XCVB the corresponding functions are in package XCVB.
2783
2784@defun initialize-source-registry @Aoptional PARAMETER
2785   will read the configuration and initialize all internal variables.
2786   You may extend or override configuration
2787   from the environment and configuration files
2788   with the given @var{PARAMETER}, which can be
2789   @code{nil} (no configuration override),
2790   or a SEXP (in the SEXP DSL),
2791   a string (as in the string DSL),
2792   a pathname (of a file or directory with configuration),
2793   or a symbol (fbound to function that when called returns one of the above).
2794@end defun
2795
2796@defun clear-source-registry
2797   undoes any source registry configuration
2798   and clears any cache for the search algorithm.
2799   You might want to call this function
2800   (or better, @code{clear-configuration})
2801   before you dump an image that would be resumed
2802   with a different configuration,
2803   and return an empty configuration.
2804   Note that this does not include clearing information about
2805   systems defined in the current image, only about
2806   where to look for systems not yet defined.
2807@end defun
2808
2809@defun ensure-source-registry @Aoptional PARAMETER
2810   checks whether a source registry has been initialized.
2811   If not, initialize it with the given @var{PARAMETER}.
2812@end defun
2813
2814Every time you use ASDF's @code{find-system}, or
2815anything that uses it (such as @code{operate}, @code{load-system}, etc.),
2816@code{ensure-source-registry} is called with parameter @code{nil},
2817which the first time around causes your configuration to be read.
2818If you change a configuration file,
2819you need to explicitly @code{initialize-source-registry} again,
2820or maybe simply to @code{clear-source-registry} (or @code{clear-configuration})
2821which will cause the initialization to happen next time around.
2822
2823
2824@section Status
2825
2826This mechanism is vastly successful, and we have declared
2827that @code{asdf:*central-registry*} is not recommended anymore,
2828though we will continue to support it.
2829All hooks into implementation-specific search mechanisms
2830have been integrated in the @code{wrapping-source-registry}
2831that everyone uses implicitly.
2832
2833
2834@section Rejected ideas
2835
2836Alternatives I considered and rejected included:
2837
2838@enumerate
2839@item Keep @code{asdf:*central-registry*} as the master with its current semantics,
2840   and somehow the configuration parser expands the new configuration
2841   language into a expanded series of directories of subdirectories to
2842   lookup, pre-recursing through specified hierarchies. This is kludgy,
2843   and leaves little space of future cleanups and extensions.
2844
2845@item Keep @code{asdf:*central-registry*} remains the master but extend its semantics
2846   in completely new ways, so that new kinds of entries may be implemented
2847   as a recursive search, etc. This seems somewhat backwards.
2848
2849@item Completely remove @code{asdf:*central-registry*}
2850   and break backwards compatibility.
2851   Hopefully this will happen in a few years after everyone migrate to
2852   a better ASDF and/or to XCVB, but it would be very bad to do it now.
2853
2854@item Replace @code{asdf:*central-registry*} by a symbol-macro with appropriate magic
2855   when you dereference it or setf it. Only the new variable with new
2856   semantics is handled by the new search procedure.
2857   Complex and still introduces subtle semantic issues.
2858@end enumerate
2859
2860
2861I've been suggested the below features, but have rejected them,
2862for the sake of keeping ASDF no more complex than strictly necessary.
2863
2864@itemize
2865@item
2866  More syntactic sugar: synonyms for the configuration directives, such as
2867  @code{(:add-directory X)} for @code{(:directory X)}, or @code{(:add-directory-hierarchy X)}
2868  or @code{(:add-directory X :recurse t)} for @code{(:tree X)}.
2869
2870@item
2871   The possibility to register individual files instead of directories.
2872
2873@item
2874  Integrate Xach Beane's tilde expander into the parser,
2875  or something similar that is shell-friendly or shell-compatible.
2876  I'd rather keep ASDF minimal. But maybe this precisely keeps it
2877  minimal by removing the need for evaluated entries that ASDF has?
2878  i.e. uses of @code{USER-HOMEDIR-PATHNAME} and @code{$SBCL_HOME}
2879  Hopefully, these are already superseded by the @code{:default-registry}
2880
2881@item
2882  Using the shell-unfriendly syntax @code{/**} instead of @code{//} to specify recursion
2883  down a filesystem tree in the environment variable.
2884  It isn't that Lisp friendly either.
2885@end itemize
2886
2887@section TODO
2888
2889@itemize
2890@item Add examples
2891@end itemize
2892
2893
2894@section Credits for the source-registry
2895
2896Thanks a lot to Stelian Ionescu for the initial idea.
2897
2898Thanks to Rommel Martinez for the initial implementation attempt.
2899
2900All bad design ideas and implementation bugs are to mine, not theirs.
2901But so are good design ideas and elegant implementation tricks.
2902
2903 --- Francois-Rene Rideau @email{fare@@tunes.org}, Mon, 22 Feb 2010 00:07:33 -0500
2904
2905
2906
2907@node Controlling where ASDF saves compiled files, Error handling, Controlling where ASDF searches for systems, Top
2908@comment  node-name,  next,  previous,  up
2909@chapter Controlling where ASDF saves compiled files
2910@cindex asdf-output-translations
2911@vindex ASDF_OUTPUT_TRANSLATIONS
2912
2913Each Common Lisp implementation has its own format
2914for compiled files (fasls for short, short for ``fast loading'').
2915If you use multiple implementations
2916(or multiple versions of the same implementation),
2917you'll soon find your source directories
2918littered with various @file{fasl}s, @file{dfsl}s, @file{cfsl}s and so on.
2919Worse yet, some implementations use the same file extension
2920while changing formats from version to version (or platform to platform)
2921which means that you'll have to recompile binaries
2922as you switch from one implementation to the next.
2923
2924Since ASDF 2, ASDF includes the @code{asdf-output-translations} facility
2925to mitigate the problem.
2926
2927@section Configurations
2928
2929Configurations specify mappings from input locations to output locations.
2930Once again we rely on the XDG base directory specification for configuration.
2931@xref{Controlling where ASDF searches for systems,,XDG base directory}.
2932
2933@enumerate
2934
2935@item
2936Some hardcoded wrapping output translations configuration may be used.
2937This allows special output translations (or usually, invariant directories)
2938to be specified corresponding to the similar special entries in the source registry.
2939
2940@item
2941An application may explicitly initialize the output-translations
2942configuration using the Configuration API
2943in which case this takes precedence.
2944(@pxref{Controlling where ASDF saves compiled files,,Configuration API}.)
2945It may itself compute this configuration from the command-line,
2946from a script, from its own configuration file, etc.
2947
2948@item
2949The source registry will be configured from
2950the environment variable @code{ASDF_OUTPUT_TRANSLATIONS} if it exists.
2951
2952@item
2953The source registry will be configured from
2954user configuration file
2955@file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf}
2956(which defaults to
2957@file{~/.config/common-lisp/asdf-output-translations.conf})
2958if it exists.
2959
2960@item
2961The source registry will be configured from
2962user configuration directory
2963@file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf.d/}
2964(which defaults to
2965@file{~/.config/common-lisp/asdf-output-translations.conf.d/})
2966if it exists.
2967
2968@item
2969The source registry will be configured from
2970system configuration file
2971@file{/etc/common-lisp/asdf-output-translations.conf}
2972if it exists.
2973
2974@item
2975The source registry will be configured from
2976system configuration directory
2977@file{/etc/common-lisp/asdf-output-translations.conf.d/}
2978if it exists.
2979
2980@end enumerate
2981
2982Each of these configurations is specified as a SEXP
2983in a trival domain-specific language (defined below).
2984Additionally, a more shell-friendly syntax is available
2985for the environment variable (defined yet below).
2986
2987Each of these configurations is only used if the previous
2988configuration explicitly or implicitly specifies that it
2989includes its inherited configuration.
2990
2991Note that by default, a per-user cache is used for output files.
2992This allows the seamless use of shared installations of software
2993between several users, and takes files out of the way of the developers
2994when they browse source code,
2995at the expense of taking a small toll when developers have to clean up
2996output files and find they need to get familiar with output-translations first.
2997
2998
2999@section Backward Compatibility
3000@cindex ASDF-BINARY-LOCATIONS compatibility
3001
3002
3003We purposefully do NOT provide backward compatibility with earlier versions of
3004@code{ASDF-Binary-Locations} (8 Sept 2009),
3005@code{common-lisp-controller} (7.0) or
3006@code{cl-launch} (2.35),
3007each of which had similar general capabilities.
3008The previous APIs of these programs were not designed
3009for configuration by the end-user
3010in an easy way with configuration files.
3011Recent versions of same packages use
3012the new @code{asdf-output-translations} API as defined below:
3013@code{common-lisp-controller} (7.2) and @code{cl-launch} (3.000).
3014@code{ASDF-Binary-Locations} is fully superseded and not to be used anymore.
3015
3016This incompatibility shouldn't inconvenience many people.
3017Indeed, few people use and customize these packages;
3018these few people are experts who can trivially adapt to the new configuration.
3019Most people are not experts, could not properly configure these features
3020(except inasmuch as the default configuration of
3021@code{common-lisp-controller} and/or @code{cl-launch}
3022might have been doing the right thing for some users),
3023and yet will experience software that ``just works'',
3024as configured by the system distributor, or by default.
3025
3026Nevertheless, if you are a fan of @code{ASDF-Binary-Locations},
3027we provide a limited emulation mode:
3028
3029@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
3030This function will initialize the new @code{asdf-output-translations} facility in a way
3031that emulates the behavior of the old @code{ASDF-Binary-Locations} facility.
3032Where you would previously set global variables
3033@var{*centralize-lisp-binaries*},
3034@var{*default-toplevel-directory*},
3035@var{*include-per-user-information*},
3036@var{*map-all-source-files*} or @var{*source-to-target-mappings*}
3037you will now have to pass the same values as keyword arguments to this function.
3038Note however that as an extension the @code{:source-to-target-mappings} keyword argument
3039will accept any valid pathname designator for @code{asdf-output-translations}
3040instead of just strings and pathnames.
3041@end defun
3042
3043If you insist, you can also keep using the old @code{ASDF-Binary-Locations}
3044(the one available as an extension to load of top of ASDF,
3045not the one built into a few old versions of ASDF),
3046but first you must disable @code{asdf-output-translations}
3047with @code{(asdf:disable-output-translations)},
3048or you might experience ``interesting'' issues.
3049
3050Also, note that output translation is enabled by default.
3051To disable it, use @code{(asdf:disable-output-translations)}.
3052
3053
3054@section Configuration DSL
3055
3056Here is the grammar of the SEXP DSL
3057for @code{asdf-output-translations} configuration:
3058
3059@verbatim
3060;; A configuration is single SEXP starting with keyword :source-registry
3061;; followed by a list of directives.
3062CONFIGURATION := (:output-translations DIRECTIVE ...)
3063
3064;; A directive is one of the following:
3065DIRECTIVE :=
3066    ;; INHERITANCE DIRECTIVE:
3067    ;; Your configuration expression MUST contain
3068    ;; exactly one of either of these:
3069    :inherit-configuration | ; splices inherited configuration (often specified last)
3070    :ignore-inherited-configuration | ; drop inherited configuration (specified anywhere)
3071
3072    ;; forward compatibility directive (since ASDF 2.011.4), useful when
3073    ;; you want to use new configuration features but have to bootstrap a
3074    ;; the newer required ASDF from an older release that doesn't sport said features:
3075    :ignore-invalid-entries | ; drops subsequent invalid entries instead of erroring out
3076
3077    ;; include a configuration file or directory
3078    (:include PATHNAME-DESIGNATOR) |
3079
3080    ;; enable global cache in ~/.common-lisp/cache/sbcl-1.0.45-linux-amd64/ or something.
3081    :enable-user-cache |
3082    ;; Disable global cache. Map / to /
3083    :disable-cache |
3084
3085    ;; add a single directory to be scanned (no recursion)
3086    (DIRECTORY-DESIGNATOR DIRECTORY-DESIGNATOR)
3087
3088    ;; use a function to return the translation of a directory designator
3089    (DIRECTORY-DESIGNATOR (:function TRANSLATION-FUNCTION))
3090
3091DIRECTORY-DESIGNATOR :=
3092    NIL | ;; As source: skip this entry. As destination: same as source
3093    T | ;; as source matches anything, as destination leaves pathname unmapped.
3094    ABSOLUTE-COMPONENT-DESIGNATOR ;; same as in the source-registry language
3095
3096TRANSLATION-FUNCTION :=
3097    SYMBOL | ;; symbol of a function that takes two arguments,
3098             ;; the pathname to be translated and the matching DIRECTORY-DESIGNATOR
3099    LAMBDA   ;; A form which evalutates to a function taking two arguments consisting of
3100             ;; the pathname to be translated and the matching DIRECTORY-DESIGNATOR
3101
3102@end verbatim
3103
3104Relative components better be either relative
3105or subdirectories of the path before them, or bust.
3106
3107The last component, if not a pathname, is notionally completed by @file{/**/*.*}.
3108You can specify more fine-grained patterns
3109by using a pathname object as the last component
3110e.g. @file{#p"some/path/**/foo*/bar-*.fasl"}
3111
3112You may use @code{#+features} to customize the configuration file.
3113
3114The second designator of a mapping may be @code{nil}, indicating that files are not mapped
3115to anything but themselves (same as if the second designator was the same as the first).
3116
3117When the first designator is @code{t},
3118the mapping always matches.
3119When the first designator starts with @code{:root},
3120the mapping matches any host and device.
3121In either of these cases, if the second designator
3122isn't @code{t} and doesn't start with @code{:root},
3123then strings indicating the host and pathname are somehow copied
3124in the beginning of the directory component of the source pathname
3125before it is translated.
3126
3127When the second designator is @code{t}, the mapping is the identity.
3128When the second designator starts with @code{:root},
3129the mapping preserves the host and device of the original pathname.
3130Notably, this allows you to map files
3131to a subdirectory of the whichever directory the file is in.
3132Though the syntax is not quite as easy to use as we'd like,
3133you can have an (source destination) mapping entry such as follows
3134in your configuration file,
3135or you may use @code{enable-asdf-binary-locations-compatibility}
3136with @code{:centralize-lisp-binaries nil}
3137which will do the same thing internally for you:
3138@verbatim
3139  #.(let ((wild-subdir (make-pathname :directory '(:relative :wild-inferiors)))
3140          (wild-file (make-pathname :name :wild :version :wild :type :wild)))
3141     `((:root ,wild-subdir ,wild-file) ;; Or using the implicit wildcard, just :root
3142       (:root ,wild-subdir :implementation ,wild-file)))
3143@end verbatim
3144Starting with ASDF 2.011.4, you can use the simpler:
3145  @code{`(:root (:root :**/ :implementation :*.*.*))}
3146
3147
3148
3149@code{:include} statements cause the search to recurse with the path specifications
3150from the file specified.
3151
3152If the @code{translate-pathname} mechanism cannot achieve a desired
3153translation, the user may provide a function which provides the
3154required algorithim.  Such a translation function is specified by
3155supplying a list as the second @code{directory-designator}
3156the first element of which is the keyword @code{:function},
3157and the second element of which is
3158either a symbol which designates a function or a lambda expression.
3159The function designated by the second argument must take two arguments,
3160the first being the pathname of the source file,
3161the second being the wildcard that was matched.
3162The result of the function invocation should be the translated pathname.
3163
3164An @code{:inherit-configuration} statement cause the search to recurse with the path
3165specifications from the next configuration.
3166@xref{Controlling where ASDF saves compiled files,,Configurations}, above.
3167
3168@itemize
3169@item
3170@code{:enable-user-cache} is the same as @code{(t :user-cache)}.
3171@item
3172@code{:disable-cache} is the same as @code{(t t)}.
3173@item
3174@code{:user-cache} uses the contents of variable @code{asdf::*user-cache*}
3175which by default is the same as using
3176@code{(:home ".cache" "common-lisp" :implementation)}.
3177@item
3178@code{:system-cache} uses the contents of variable @code{asdf::*system-cache*}
3179which by default is the same as using
3180@code{("/var/cache/common-lisp" :uid :implementation-type)}
3181(on Unix and cygwin), or something semi-sensible on Windows.
3182@end itemize
3183
3184
3185@section Configuration Directories
3186
3187Configuration directories consist in files each contains
3188a list of directives without any enclosing
3189@code{(:output-translations ...)} form.
3190The files will be sorted by namestring as if by @code{string<} and
3191the lists of directives of these files with be concatenated in order.
3192An implicit @code{:inherit-configuration} will be included
3193at the @emph{end} of the list.
3194
3195This allows for packaging software that has file granularity
3196(e.g. Debian's @command{dpkg} or some future version of @command{clbuild})
3197to easily include configuration information about software being distributed.
3198
3199The convention is that, for sorting purposes,
3200the names of files in such a directory begin with two digits
3201that determine the order in which these entries will be read.
3202Also, the type of these files is conventionally @code{"conf"}
3203and as a limitation of some implementations, the type cannot be @code{nil}.
3204
3205Directories may be included by specifying a directory pathname
3206or namestring in an @code{:include} directive, e.g.:
3207@verbatim
3208  (:include "/foo/bar/")
3209@end verbatim
3210
3211@section Shell-friendly syntax for configuration
3212
3213When considering environment variable @code{ASDF_OUTPUT_TRANSLATIONS}
3214ASDF will skip to next configuration if it's an empty string.
3215It will @code{READ} the string as an SEXP in the DSL
3216if it begins with a paren @code{(}
3217and it will be interpreted as a list of directories.
3218Directories should come by pairs, indicating a mapping directive.
3219Entries are separated
3220by a @code{:} (colon) on Unix platforms (including cygwin),
3221by a @code{;} (semicolon) on other platforms (mainly, Windows).
3222
3223The magic empty entry,
3224if it comes in what would otherwise be the first entry in a pair,
3225indicates the splicing of inherited configuration.
3226If it comes as the second entry in a pair,
3227it indicates that the directory specified first is to be left untranslated
3228(which has the same effect as if the directory had been repeated).
3229
3230
3231@section Semantics of Output Translations
3232
3233From the specified configuration,
3234a list of mappings is extracted in a straightforward way:
3235mappings are collected in order, recursing through
3236included or inherited configuration as specified.
3237To this list is prepended some implementation-specific mappings,
3238and is appended a global default.
3239
3240The list is then compiled to a mapping table as follows:
3241for each entry, in order, resolve the first designated directory
3242into an actual directory pathname for source locations.
3243If no mapping was specified yet for that location,
3244resolve the second designated directory to an output location directory
3245add a mapping to the table mapping the source location to the output location,
3246and add another mapping from the output location to itself
3247(unless a mapping already exists for the output location).
3248
3249Based on the table, a mapping function is defined,
3250mapping source pathnames to output pathnames:
3251given a source pathname, locate the longest matching prefix
3252in the source column of the mapping table.
3253Replace that prefix by the corresponding output column
3254in the same row of the table, and return the result.
3255If no match is found, return the source pathname.
3256(A global default mapping the filesystem root to itself
3257may ensure that there will always be a match,
3258with same fall-through semantics).
3259
3260@section Caching Results
3261
3262The implementation is allowed to either eagerly compute the information
3263from the configurations and file system, or to lazily re-compute it
3264every time, or to cache any part of it as it goes.
3265To explicitly flush any information cached by the system, use the API below.
3266
3267
3268@section Output location API
3269
3270The specified functions are exported from package ASDF.
3271
3272@defun initialize-output-translations @Aoptional PARAMETER
3273   will read the configuration and initialize all internal variables.
3274   You may extend or override configuration
3275   from the environment and configuration files
3276   with the given @var{PARAMETER}, which can be
3277   @code{nil} (no configuration override),
3278   or a SEXP (in the SEXP DSL),
3279   a string (as in the string DSL),
3280   a pathname (of a file or directory with configuration),
3281   or a symbol (fbound to function that when called returns one of the above).
3282@end defun
3283
3284@defun disable-output-translations
3285   will initialize output translations in a way
3286   that maps every pathname to itself,
3287   effectively disabling the output translation facility.
3288@end defun
3289
3290@defun clear-output-translations
3291   undoes any output translation configuration
3292   and clears any cache for the mapping algorithm.
3293   You might want to call this function
3294   (or better, @code{clear-configuration})
3295   before you dump an image that would be resumed
3296   with a different configuration,
3297   and return an empty configuration.
3298   Note that this does not include clearing information about
3299   systems defined in the current image, only about
3300   where to look for systems not yet defined.
3301@end defun
3302
3303@defun ensure-output-translations @Aoptional PARAMETER
3304   checks whether output translations have been initialized.
3305   If not, initialize them with the given @var{PARAMETER}.
3306   This function will be called before any attempt to operate on a system.
3307@end defun
3308
3309@defun apply-output-translations PATHNAME
3310   Applies the configured output location translations to @var{PATHNAME}
3311   (calls @code{ensure-output-translations} for the translations).
3312@end defun
3313
3314Every time you use ASDF's @code{output-files}, or
3315anything that uses it (that may compile, such as @code{operate}, @code{perform}, etc.),
3316@code{ensure-output-translations} is called with parameter @code{nil},
3317which the first time around causes your configuration to be read.
3318If you change a configuration file,
3319you need to explicitly @code{initialize-output-translations} again,
3320or maybe @code{clear-output-translations} (or @code{clear-configuration}),
3321which will cause the initialization to happen next time around.
3322
3323
3324@section Credits for output translations
3325
3326Thanks a lot to Bjorn Lindberg and Gary King for @code{ASDF-Binary-Locations},
3327and to Peter van Eynde for @code{Common Lisp Controller}.
3328
3329All bad design ideas and implementation bugs are to mine, not theirs.
3330But so are good design ideas and elegant implementation tricks.
3331
3332 --- Francois-Rene Rideau @email{fare@@tunes.org}
3333
3334@c @section Default locations
3335@c @findex output-files-for-system-and-operation
3336
3337@c The default binary location for each Lisp implementation
3338@c is a subdirectory of each source directory.
3339@c To account for different Lisps, Operating Systems, Implementation versions,
3340@c and so on, ASDF borrows code from SLIME
3341@c to create reasonable custom directory names.
3342@c Here are some examples:
3343
3344@c @itemize
3345@c @item
3346@c SBCL, version 1.0.45 on Mac OS X for Intel: @code{sbcl-1.0.45-darwin-x86}
3347
3348@c @item
3349@c Franz Allegro, version 8.0, ANSI Common Lisp: @code{allegro-8.0a-macosx-x86}
3350
3351@c @item
3352@c Franz Allegro, version 8.1, Modern (case sensitive) Common Lisp: @code{allegro-8.1m-macosx-x86}
3353@c @end itemize
3354
3355@c By default, all output file pathnames will be relocated
3356@c to some thus-named subdirectory of @file{~/.cache/common-lisp/}.
3357
3358@c See the document @file{README.asdf-output-translations}
3359@c for a full specification on how to configure @code{asdf-output-translations}.
3360
3361@node  Error handling, Miscellaneous additional functionality, Controlling where ASDF saves compiled files, Top
3362@comment  node-name,  next,  previous,  up
3363@chapter Error handling
3364@findex SYSTEM-DEFINITION-ERROR
3365@findex OPERATION-ERROR
3366
3367@section ASDF errors
3368
3369If ASDF detects an incorrect system definition, it will signal a generalised instance of
3370@code{SYSTEM-DEFINITION-ERROR}.
3371
3372Operations may go wrong (for example when source files contain errors).
3373These are signalled using generalised instances of
3374@code{OPERATION-ERROR}.
3375
3376@section Compilation error and warning handling
3377@vindex *compile-file-warnings-behaviour*
3378@vindex *compile-file-errors-behavior*
3379
3380ASDF checks for warnings and errors when a file is compiled.
3381The variables @var{*compile-file-warnings-behaviour*} and
3382@var{*compile-file-errors-behavior*}
3383control the handling of any such events.
3384The valid values for these variables are
3385@code{:error}, @code{:warn}, and @code{:ignore}.
3386
3387@node  Miscellaneous additional functionality, Getting the latest version, Error handling, Top
3388@comment  node-name,  next,  previous,  up
3389@chapter Miscellaneous additional functionality
3390
3391ASDF includes several additional features that are generally
3392useful for system definition and development.
3393
3394@section Controlling file compilation
3395@cindex :around-compile
3396@cindex around-compile keyword
3397@cindex compile-check keyword
3398@cindex :compile-check
3399@findex compile-file*
3400
3401When declaring a component (system, module, file),
3402you can specify a keyword argument @code{:around-compile function}.
3403If left unspecified (and therefore unbound),
3404the value will be inherited from the parent component if any,
3405or with a default of @code{nil}
3406if no value is specified in any transitive parent.
3407
3408The argument must be a either @code{nil}, a fbound symbol,
3409a lambda-expression (e.g. @code{(lambda (thunk) ...(funcall thunk ...) ...)})
3410a function object (e.g. using @code{#.#'} but that's discouraged
3411because it prevents the introspection done by e.g. asdf-dependency-grovel),
3412or a string that when @code{read} yields a symbol or a lambda-expression.
3413@code{nil} means the normal compile-file function will be called.
3414A non-nil value designates a function of one argument
3415that will be called with a function that will
3416invoke @code{compile-file*} with various arguments;
3417the around-compile hook may supply additional keyword arguments
3418to pass to that call to @code{compile-file*}.
3419
3420One notable argument that is heeded by @code{compile-file*} is
3421@code{:compile-check},
3422a function called when the compilation was otherwise a success,
3423with the same arguments as @code{compile-file};
3424the function shall return true if the compilation
3425and its resulting compiled file respected all system-specific invariants,
3426and false (@code{nil}) if it broke any of those invariants;
3427it may issue warnings or errors before it returns @code{nil}.
3428(NB: The ability to pass such extra flags
3429is only available starting with ASDF 2.22.3.)
3430This feature is notably exercised by asdf-finalizers.
3431
3432By using a string, you may reference
3433a function, symbol and/or package
3434that will only be created later during the build, but
3435isn't yet present at the time the defsystem form is evaluated.
3436However, if your entire system is using such a hook, you may have to
3437explicitly override the hook with @code{nil} for all the modules and files
3438that are compiled before the hook is defined.
3439
3440Using this hook, you may achieve such effects as:
3441locally renaming packages,
3442binding @var{*readtables*} and other syntax-controlling variables,
3443handling warnings and other conditions,
3444proclaiming consistent optimization settings,
3445saving code coverage information,
3446maintaining meta-data about compilation timings,
3447setting gensym counters and PRNG seeds and other sources of non-determinism,
3448overriding the source-location and/or timestamping systems,
3449checking that some compile-time side-effects were properly balanced,
3450etc.
3451
3452Note that there is no around-load hook. This is on purpose.
3453Some implementations such as ECL, GCL or MKCL link object files,
3454which allows for no such hook.
3455Other implementations allow for concatenating FASL files,
3456which doesn't allow for such a hook either.
3457We aim to discourage something that's not portable,
3458and has some dubious impact on performance and semantics
3459even when it is possible.
3460Things you might want to do with an around-load hook
3461are better done around-compile,
3462though it may at times require some creativity
3463(see e.g. the @code{package-renaming} system).
3464
3465
3466@section Controlling source file character encoding
3467
3468Starting with ASDF 2.21, components accept a @code{:encoding} option
3469so authors may specify which character encoding should be used
3470to read and evaluate their source code.
3471When left unspecified, the encoding is inherited
3472from the parent module or system;
3473if no encoding is specified at any point,
3474the default @code{:autodetect} is assumed.
3475By default, only @code{:default}, @code{:utf-8}
3476and @code{:autodetect} are accepted.
3477@code{:autodetect}, the default, calls
3478@code{*encoding-detection-hook*} which by default always returns
3479@code{*default-encoding*} which itself defaults to @code{:default}.
3480
3481In other words, there now are plenty of extension hooks, but
3482by default ASDF follows the backwards compatible behavior
3483of using whichever @code{:default} encoding your implementation uses,
3484which itself may or may not vary based on environment variables
3485and other locale settings.
3486In practice this means that only source code that only uses ASCII
3487is guaranteed to be read the same on all implementations
3488independently from any user setting.
3489
3490Additionally, for backward-compatibility with older versions of ASDF
3491and/or with implementations that do not support unicode and its many encodings,
3492you may want to use
3493the reader conditionals @code{#+asdf-unicode #+asdf-unicode}
3494to protect any @code{:encoding @emph{encoding}} statement
3495as @code{:asdf-unicode} will be present in @code{*features*}
3496only if you're using a recent ASDF
3497on an implementation that supports unicode.
3498We recommend that you avoid using unprotected @code{:encoding} specifications
3499until after ASDF 2.21 or later becomes widespread, hopefully by the end of 2012.
3500
3501While it offers plenty of hooks for extension,
3502and one such extension is being developed (see below),
3503ASDF itself only recognizes one encoding beside @code{:default},
3504and that is @code{:utf-8}, which is the @emph{de facto} standard,
3505already used by the vast majority of libraries that use more than ASCII.
3506On implementations that do not support unicode,
3507the feature @code{:asdf-unicode} is absent, and
3508the @code{:default} external-format is used
3509to read even source files declared as @code{:utf-8}.
3510On these implementations, non-ASCII characters
3511intended to be read as one CL character
3512may thus end up being read as multiple CL characters.
3513In most cases, this shouldn't affect the software's semantics:
3514comments will be skipped just the same, strings with be read and printed
3515with slightly different lengths, symbol names will be accordingly longer,
3516but none of it should matter.
3517But a few systems that actually depend on unicode characters
3518may fail to work properly, or may work in a subtly different way.
3519See for instance @code{lambda-reader}.
3520
3521We invite you to embrace UTF-8
3522as the encoding for non-ASCII characters starting today,
3523even without any explicit specification in your @code{.asd} files.
3524Indeed, on some implementations and configurations,
3525UTF-8 is already the @code{:default},
3526and loading your code may cause errors if it is encoded in anything but UTF-8.
3527Therefore, even with the legacy behavior,
3528non-UTF-8 is guaranteed to break for some users,
3529whereas UTF-8 is pretty much guaranteed not to break anywhere
3530(provided you do @emph{not} use a BOM),
3531although it might be read incorrectly on some implementations.
3532In the future, we intend to make @code{:utf-8}
3533the default value of @code{*default-encoding*},
3534to be enforced everywhere, so at least the code is guaranteed
3535to be read correctly everywhere it can be.
3536
3537If you need non-standard character encodings for your source code,
3538use the extension system @code{asdf-encodings}, by specifying
3539@code{:defsystem-depends-on (:asdf-encodings)} in your @code{defsystem}.
3540This extension system will register support for more encodings using the
3541@code{*encoding-external-format-hook*} facility,
3542so you can explicitly specify @code{:encoding :latin1}
3543in your @code{.asd} file.
3544Using the @code{*encoding-detection-hook*} it will also
3545eventually implement some autodetection of a file's encoding
3546from an emacs-style @code{-*- mode: lisp ; coding: latin1 -*-} declaration,
3547or otherwise based on an analysis of octet patterns in the file.
3548At this point, asdf-encoding only supports the encodings
3549that are supported as part of your implementation.
3550Since the list varies depending on implementations,
3551we once again recommend you use @code{:utf-8} everywhere,
3552which is the most portable (next is @code{:latin1}).
3553
3554If you're not using a version of Quicklisp that has it,
3555you may get the source for @code{asdf-encodings} using git:
3556@kbd{git clone git://common-lisp.net/projects/asdf/asdf-encodings.git}
3557or
3558@kbd{git clone ssh://common-lisp.net/project/asdf/git/asdf-encodings.git}.
3559You can also browse the repository on
3560@url{http://common-lisp.net/gitweb?p=projects/asdf/asdf-encodings.git}.
3561
3562In the future, we intend to change the default @code{*default-encoding*}
3563to @code{:utf-8}, which is already the de facto standard
3564for most libraries that use non-ASCII characters:
3565utf-8 works everywhere and was backhandedly enforced by
3566a lot of people using SBCL and utf-8 and sending reports to authors
3567so they make their packages compatible.
3568A survey showed only about a handful few libraries
3569are incompatible with non-UTF-8, and then, only in comments,
3570and we believe that authors will adopt UTF-8 when prompted.
3571See the April 2012 discussion on the asdf-devel mailing-list.
3572For backwards compatibility with users who insist on a non-UTF-8 encoding,
3573but cannot immediately transition to using @code{asdf-encodings}
3574(maybe because it isn't ready), it will still be possible to use
3575the @code{:encoding :default} option in your @code{defsystem} form
3576to restore the behavior of ASDF 2.20 and earlier.
3577This shouldn't be required in libraries,
3578because user pressure as mentioned above will already have pushed
3579library authors towards using UTF-8;
3580but authors of end-user programs might care.
3581
3582When you use @code{asdf-encodings}, any further loaded @code{.asd} file
3583will use the autodetection algorithm to determine its encoding;
3584yet if you depend on this detection happening,
3585you may want to explicitly load @code{asdf-encodings} early in your build,
3586for by the time you can use @code{:defsystem-depends-on},
3587it is already too late to load it.
3588In practice, this means that the @code{*default-encoding*}
3589is usually used for @code{.asd} files.
3590Currently, this defaults to @code{:default} for backwards compatibility,
3591and that means that you shouldn't rely on non-ASCII characters in a .asd file.
3592Since component (path)names are the only real data in these files,
3593and non-ASCII characters are not very portable for file names,
3594this isn't too much of an issue.
3595We still encourage you to use either plain ASCII or UTF-8
3596in @code{.asd} files,
3597as we intend to make @code{:utf-8} the default encoding in the future.
3598This might matter, for instance, in meta-data about author's names.
3599
3600
3601@section Miscellaneous Functions
3602
3603These functions are exported by ASDF for your convenience.
3604
3605@defun system-relative-pathname system name @Akey type
3606
3607It's often handy to locate a file relative to some system.
3608The @code{system-relative-pathname} function meets this need.
3609
3610It takes two mandatory arguments @var{system} and @var{name}
3611and a keyword argument @var{type}:
3612@var{system} is name of a system, whereas @var{name} and optionally @var{type}
3613specify a relative pathname, interpreted like a component pathname specifier
3614by @code{coerce-pathname}. @xref{The defsystem grammar,,Pathname specifiers}.
3615
3616It returns a pathname built from the location of the system's
3617source directory and the relative pathname. For example:
3618
3619@lisp
3620> (asdf:system-relative-pathname 'cl-ppcre "regex.data")
3621#P"/repository/other/cl-ppcre/regex.data"
3622@end lisp
3623
3624@end defun
3625
3626@defun system-source-directory system-designator
3627
3628ASDF does not provide a turnkey solution for locating
3629data (or other miscellaneous) files
3630that are distributed together with the source code of a system.
3631Programmers can use @code{system-source-directory} to find such files.
3632Returns a pathname object.
3633The @var{system-designator} may be a string, symbol, or ASDF system object.
3634@end defun
3635
3636@defun clear-system system-designator
3637
3638It is sometimes useful to force recompilation of a previously loaded system.
3639In these cases, it may be useful to @code{(asdf:clear-system :foo)}
3640to remove the system from the table of currently loaded systems;
3641the next time the system @code{foo} or one that depends on it is re-loaded,
3642@code{foo} will then be loaded again.
3643Alternatively, you could touch @code{foo.asd} or
3644remove the corresponding fasls from the output file cache.
3645(It was once conceived that one should provide
3646a list of systems the recompilation of which to force
3647as the @code{:force} keyword argument to @code{load-system};
3648but this has never worked, and though the feature was fixed in ASDF 2.000,
3649it remains @code{cerror}'ed out as nobody ever used it.)
3650
3651Note that this does not and cannot by itself undo the previous loading
3652of the system. Common Lisp has no provision for such an operation,
3653and its reliance on irreversible side-effects to global datastructures
3654makes such a thing impossible in the general case.
3655If the software being re-loaded is not conceived with hot upgrade in mind,
3656this re-loading may cause many errors, warnings or subtle silent problems,
3657as packages, generic function signatures, structures, types, macros, constants, etc.
3658are being redefined incompatibly.
3659It is up to the user to make sure that reloading is possible and has the desired effect.
3660In some cases, extreme measures such as recursively deleting packages,
3661unregistering symbols, defining methods on @code{update-instance-for-redefined-class}
3662and much more are necessary for reloading to happen smoothly.
3663ASDF itself goes through notable pains to make such a hot upgrade possible
3664with respect to its own code, and what it does is ridiculously complex;
3665look at the beginning of @file{asdf.lisp} to see what it does.
3666@end defun
3667
3668@defun register-preloaded-system name @Arest keys
3669A system with name @var{name},
3670created by @code{make-instance} with extra keys @var{keys}
3671(e.g. @code{:version}),
3672is registered as @emph{preloaded}.
3673That is, its code has already been loaded into the current image,
3674and if at some point some other system @code{:depends-on} it yet no source code is found,
3675it is considered as already provided,
3676and ASDF will not raise a @code{missing-component} error.
3677
3678This function is particularly useful if you distribute your code
3679as fasls with either @code{fasl-op} or @code{monolithic-fasl-op},
3680and want to register systems so that dependencies will work uniformly
3681whether you're using your software from source or from fasl.
3682@end defun
3683
3684@defun run-shell-command control-string @Arest args
3685
3686This function is obsolete and present only for the sake of backwards-compatibility:
3687``If it's not backwards, it's not compatible''. We @emph{strongly} discourage its use.
3688Its current behavior is only well-defined on Unix platforms
3689(which include MacOS X and cygwin). On Windows, anything goes.
3690The following documentation is only for the purpose of your migrating away from it
3691in a way that preserves semantics.
3692
3693Instead we recommend the use @code{run-program}, described in the next section, and
3694available as part of ASDF since ASDF 3.
3695
3696@code{run-shell-command} takes as arguments a format @code{control-string}
3697and arguments to be passed to @code{format} after this control-string
3698to produce a string.
3699This string is a command that will be evaluated with a POSIX shell if possible;
3700yet, on Windows, some implementations will use CMD.EXE,
3701while others (like SBCL) will make an attempt at invoking a POSIX shell
3702(and fail if it is not present).
3703@end defun
3704
3705@section Some Utility Functions
3706
3707The below functions are not exported by ASDF itself, but by UIOP, available since ASDF 3.
3708Some of them have precursors in ASDF 2, but we recommend
3709you rely on ASDF 3 for active developments.
3710UIOP provides many, many more utility functions, and we recommend
3711you read its README and sources for more information.
3712
3713
3714@defun parse-unix-namestring name @Akey type defaults dot-dot ensure-directory @AallowOtherKeys
3715Coerce NAME into a PATHNAME using standard Unix syntax.
3716
3717Unix syntax is used whether or not the underlying system is Unix;
3718on such non-Unix systems it is only usable but for relative pathnames;
3719but especially to manipulate relative pathnames portably, it is of crucial
3720to possess a portable pathname syntax independent of the underlying OS.
3721This is what @code{parse-unix-namestring} provides, and why we use it in ASDF.
3722
3723When given a @code{pathname} object, just return it untouched.
3724When given @code{nil}, just return @code{nil}.
3725When given a non-null @code{symbol}, first downcase its name and treat it as a string.
3726When given a @code{string}, portably decompose it into a pathname as below.
3727
3728@code{#\/} separates directory components.
3729
3730The last @code{#\/}-separated substring is interpreted as follows:
37311- If @var{type} is @code{:directory} or @var{ensure-directory} is true,
3732 the string is made the last directory component, and its @code{name} and @code{type} are @code{nil}.
3733 if the string is empty, it's the empty pathname with all slots @code{nil}.
37342- If @var{type} is @code{nil}, the substring is a file-namestring,
3735 and its @code{name} and @code{type} are separated by @code{split-name-type}.
37363- If @var{type} is a string, it is the given @code{type}, and the whole string is the @code{name}.
3737
3738Directory components with an empty name the name @code{.} are removed.
3739Any directory named @code{..} is read as @var{dot-dot},
3740which must be one of @code{:back} or @code{:up} and defaults to @code{:back}.
3741
3742@code{host}, @code{device} and @code{version} components are taken from @var{defaults},
3743which itself defaults to @code{*nil-pathname*}, also used if @var{defaults} is @code{nil}.
3744No host or device can be specified in the string itself,
3745which makes it unsuitable for absolute pathnames outside Unix.
3746
3747For relative pathnames, these components (and hence the defaults) won't matter
3748if you use @code{merge-pathnames*} but will matter if you use @code{merge-pathnames},
3749which is an important reason to always use @code{merge-pathnames*}.
3750
3751Arbitrary keys are accepted, and the parse result is passed to @code{ensure-pathname}
3752with those keys, removing @var{type}, @var{defaults} and @var{dot-dot}.
3753When you're manipulating pathnames that are supposed to make sense portably
3754even though the OS may not be Unixish, we recommend you use @code{:want-relative t}
3755to throw an error if the pathname is absolute
3756@end defun
3757
3758@defun merge-pathnames* specified @Aoptional defaults
3759
3760This function is a replacement for @code{merge-pathnames} that uses the host and device
3761from the @var{defaults} rather than the @var{specified} pathname when the latter
3762is a relative pathname. This allows ASDF and its users to create and use relative pathnames
3763without having to know beforehand what are the host and device
3764of the absolute pathnames they are relative to.
3765
3766@end defun
3767
3768@defun subpathname pathname subpath @Akey type
3769
3770This function takes a @var{pathname} and a @var{subpath} and a @var{type}.
3771If @var{subpath} is already a @code{pathname} object (not namestring),
3772and is an absolute pathname at that, it is returned unchanged;
3773otherwise, @var{subpath} is turned into a relative pathname with given @var{type}
3774as per @code{parse-unix-namestring} with @code{:want-relative t :type }@var{type},
3775then it is merged with the @code{pathname-directory-pathname} of @var{pathname},
3776as per @code{merge-pathnames*}.
3777
3778We strongly encourage the use of this function
3779for portably resolving relative pathnames in your code base.
3780@end defun
3781
3782@defun subpathname* pathname subpath @Akey type
3783
3784This function returns @code{nil} if the base @var{pathname} is @code{nil},
3785otherwise acts like @code{subpathname}.
3786@end defun
3787
3788@defun run-program command @Akey ignore-error-status force-shell input output error-output
3789  if-input-does-not-exist if-output-exists if-error-output-exists
3790  element-type external-format @AallowOtherKeys
3791
3792@code{run-program} takes a @var{command} argument that is either
3793a list of a program name or path and its arguments,
3794or a string to be executed by a shell.
3795It spawns the command, waits for it to return,
3796verifies that it exited cleanly (unless told not too below),
3797and optionally captures and processes its output.
3798It accepts many keyword arguments to configure its behavior.
3799
3800@code{run-program} returns three values: the first for the output,
3801the second for the error-output, and the third for the return value.
3802(Beware that before ASDF 3.0.2.11, it didn't handle input or error-output,
3803and returned only one value,
3804the one for the output if any handler was specified, or else the exit code;
3805please upgrade ASDF, or at least UIOP, to rely on the new enhanced behavior.)
3806
3807@var{output} is its most important argument;
3808it specifies how the output is captured and processed.
3809If it is @code{nil}, then the output is redirected to the null device,
3810that will discard it.
3811If it is @code{:interactive}, then it is inherited from the current process
3812(beware: this may be different from your @var{*standard-output*},
3813and under SLIME will be on your @code{*inferior-lisp*} buffer).
3814If it is @code{t}, output goes to your current @var{*standard-output*} stream.
3815Otherwise, @var{output} should be a value that is a suitable first argument to
3816@code{slurp-input-stream} (see below), or
3817a list of such a value and keyword arguments.
3818In this case, @code{run-program} will
3819create a temporary stream for the program output;
3820the program output, in that stream,
3821will be processed by a call to @code{slurp-input-stream},
3822using @var{output} as the first argument
3823(or if it's a list the first element of @var{output} and the rest as keywords).
3824The primary value resulting from that call
3825(or @code{nil} if no call was needed)
3826will be the first value returned by @code{run-program}.
3827E.g., using @code{:output :string}
3828will have it return the entire output stream as a string.
3829And using @code{:output '(:string :stripped t)}
3830will have it return the same string stripped of any ending newline.
3831
3832@var{error-output} is similar to @var{output}, except that
3833the resulting value is returned as the second value of @code{run-program}.
3834@code{t} designates the @var{*error-output*}.
3835Also @code{:output} means redirecting the error output to the output stream,
3836in which case @code{nil} is returned.
3837
3838@var{input} is similar to @var{output}, except that
3839@code{vomit-output-stream} is used, no value is returned,
3840and @code{t} designates the @var{*standard-input*}.
3841
3842@code{element-type} and @code{external-format} are passed on
3843to your Lisp implementation, when applicable, for creation of the output stream.
3844
3845One and only one of the stream slurping or vomiting may or may not happen
3846in parallel in parallel with the subprocess,
3847depending on options and implementation,
3848and with priority being given to output processing.
3849Other streams are completely produced or consumed
3850before or after the subprocess is spawned, using temporary files.
3851
3852@code{force-shell} forces evaluation of the command through a shell,
3853even if it was passed as a list rather than a string.
3854If a shell is used, it is @file{/bin/sh} on Unix or @file{CMD.EXE} on Windows,
3855except on implementations that (erroneously, IMNSHO)
3856insist on consulting @code{$SHELL} like clisp.
3857
3858@code{ignore-error-status} causes @code{run-program}
3859to not raise an error if the spawned program exits in error.
3860Following POSIX convention, an error is anything but
3861a normal exit with status code zero.
3862By default, an error of type @code{subprocess-error} is raised in this case.
3863
3864@code{run-program} works on all platforms supported by ASDF, except Genera.
3865See the source code for more documentation.
3866
3867@end defun
3868
3869@defun slurp-input-stream processor input-stream @Akey
3870
3871It's a generic function of two arguments, a target object and an input stream,
3872and accepting keyword arguments.
3873Predefined methods based on the target object are as follow:
3874
3875If the object is a function, the function is called with the stream as argument.
3876
3877If the object is a cons, its first element is applied to its rest appended by
3878a list of the input stream.
3879
3880If the object is an output stream, the contents of the input stream are copied to it.
3881If the @var{linewise} keyword argument is provided, copying happens line by line,
3882and an optional @var{prefix} is printed before each line.
3883Otherwise, copying happen based on a buffer of size @var{buffer-size},
3884using the specified @var{element-type}.
3885
3886If the object is @code{'string} or @code{:string}, the content is captured into a string.
3887Accepted keywords include the @var{element-type} and a flag @var{stripped},
3888which when true causes any single line ending to be removed as per @code{uiop:stripln}.
3889
3890If the object is @code{:lines}, the content is captured as a list of strings,
3891one per line, without line ending. If the @var{count} keyword argument is provided,
3892it is a maximum count of lines to be read.
3893
3894If the object is @code{:line}, the content is capture as with @code{:lines} above,
3895and then its sub-object is extracted with the @var{at} argument,
3896which defaults to @code{0}, extracting the first line.
3897A number will extract the corresponding line.
3898See the documentation for @code{uiop:access-at}.
3899
3900If the object is @code{:forms}, the content is captured as a list of S-expressions,
3901as read by the Lisp reader.
3902If the @var{count} argument is provided,
3903it is a maximum count of lines to be read.
3904We recommend you control the syntax with such macro as
3905@code{uiop:with-safe-io-syntax}.
3906
3907If the object is @code{:form}, the content is capture as with @code{:forms} above,
3908and then its sub-object is extracted with the @var{at} argument,
3909which defaults to @code{0}, extracting the first form.
3910A number will extract the corresponding form.
3911See the documentation for @code{uiop:access-at}.
3912We recommend you control the syntax with such macro as
3913@code{uiop:with-safe-io-syntax}.
3914
3915@end defun
3916
3917
3918@node Getting the latest version, FAQ, Miscellaneous additional functionality, Top
3919@comment  node-name,  next,  previous,  up
3920@chapter Getting the latest version
3921
3922Decide which version you want.
3923The @code{master} branch is where development happens;
3924its @code{HEAD} is usually OK, including the latest fixes and portability tweaks,
3925but an occasional regression may happen despite our (limited) test suite.
3926
3927The @code{release} branch is what cautious people should be using;
3928it has usually been tested more, and releases are cut at a point
3929where there isn't any known unresolved issue.
3930
3931You may get the ASDF source repository using git:
3932@kbd{git clone git://common-lisp.net/projects/asdf/asdf.git}
3933
3934You will find the above referenced tags in this repository.
3935You can also browse the repository on
3936@url{http://common-lisp.net/gitweb?p=projects/asdf/asdf.git}.
3937
3938Discussion of ASDF development is conducted on the
3939mailing list
3940@kbd{asdf-devel@@common-lisp.net}.
3941@url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel}
3942
3943
3944@node FAQ, TODO list, Getting the latest version, Top
3945@comment  node-name,  next,  previous,  up
3946@chapter FAQ
3947
3948@section  ``Where do I report a bug?''
3949
3950ASDF bugs are tracked on launchpad: @url{https://launchpad.net/asdf}.
3951
3952If you're unsure about whether something is a bug, or for general discussion,
3953use the @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
3954
3955
3956@section ``What has changed between ASDF 1 and ASDF 2?''
3957
3958@subsection What are ASDF 1 and ASDF 2?
3959
3960On May 31st 2010, we have released ASDF 2.
3961ASDF 2 refers to release 2.000 and later.
3962(Releases between 1.656 and 1.728 were development releases for ASDF 2.)
3963ASDF 1 to any release earlier than 1.369 or so.
3964If your ASDF doesn't sport a version, it's an old ASDF 1.
3965
3966ASDF 2 and its release candidates push
3967@code{:asdf2} onto @code{*features*} so that if you are writing
3968ASDF-dependent code you may check for this feature
3969to see if the new API is present.
3970@emph{All} versions of ASDF should have the @code{:asdf} feature.
3971
3972Additionally, all versions of ASDF 2
3973define a function @code{(asdf:asdf-version)} you may use to query the version;
3974and the source code of recent versions of ASDF 2 features the version number
3975prominently on the second line of its source code.
3976
3977If you are experiencing problems or limitations of any sort with ASDF 1,
3978we recommend that you should upgrade to ASDF 2,
3979or whatever is the latest release.
3980
3981
3982@subsection ASDF can portably name files in subdirectories
3983
3984Common Lisp namestrings are not portable,
3985except maybe for logical pathnamestrings,
3986that themselves have various limitations and require a lot of setup
3987that is itself ultimately non-portable.
3988
3989In ASDF 1, the only portable ways to refer to pathnames inside systems and components
3990were very awkward, using @code{#.(make-pathname ...)} and
3991@code{#.(merge-pathnames ...)}.
3992Even the above were themselves were inadequate in the general case
3993due to host and device issues, unless horribly complex patterns were used.
3994Plenty of simple cases that looked portable actually weren't,
3995leading to much confusion and greavance.
3996
3997ASDF 2 implements its own portable syntax for strings as pathname specifiers.
3998Naming files within a system definition becomes easy and portable again.
3999@xref{Miscellaneous additional functionality,asdf:system-relative-pathname},
4000@code{merge-pathnames*},
4001@code{coerce-pathname}.
4002
4003On the other hand, there are places where systems used to accept namestrings
4004where you must now use an explicit pathname object:
4005@code{(defsystem ... :pathname "LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
4006must now be written with the @code{#p} syntax:
4007@code{(defsystem ... :pathname #p"LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
4008
4009@xref{The defsystem grammar,,Pathname specifiers}.
4010
4011
4012@subsection Output translations
4013
4014A popular feature added to ASDF was output pathname translation:
4015@code{asdf-binary-locations}, @code{common-lisp-controller},
4016@code{cl-launch} and other hacks were all implementing it in ways
4017both mutually incompatible and difficult to configure.
4018
4019Output pathname translation is essential to share
4020source directories of portable systems across multiple implementations
4021or variants thereof,
4022or source directories of shared installations of systems across multiple users,
4023or combinations of the above.
4024
4025In ASDF 2, a standard mechanism is provided for that,
4026@code{asdf-output-translations},
4027with sensible defaults, adequate configuration languages,
4028a coherent set of configuration files and hooks,
4029and support for non-Unix platforms.
4030
4031@xref{Controlling where ASDF saves compiled files}.
4032
4033@subsection Source Registry Configuration
4034
4035Configuring ASDF used to require special magic
4036to be applied just at the right moment,
4037between the moment ASDF is loaded and the moment it is used,
4038in a way that is specific to the user,
4039the implementation he is using and the application he is building.
4040
4041This made for awkward configuration files and startup scripts
4042that could not be shared between users, managed by administrators
4043or packaged by distributions.
4044
4045ASDF 2 provides a well-documented way to configure ASDF,
4046with sensible defaults, adequate configuration languages,
4047and a coherent set of configuration files and hooks.
4048
4049We believe it's a vast improvement because it decouples
4050application distribution from library distribution.
4051The application writer can avoid thinking where the libraries are,
4052and the library distributor (dpkg, clbuild, advanced user, etc.)
4053can configure them once and for every application.
4054Yet settings can be easily overridden where needed,
4055so whoever needs control has exactly as much as required.
4056
4057At the same time, ASDF 2 remains compatible
4058with the old magic you may have in your build scripts
4059(using @code{*central-registry*} and
4060@code{*system-definition-search-functions*})
4061to tailor the ASDF configuration to your build automation needs,
4062and also allows for new magic, simpler and more powerful magic.
4063
4064@xref{Controlling where ASDF searches for systems}.
4065
4066
4067@subsection Usual operations are made easier to the user
4068
4069In ASDF 1, you had to use the awkward syntax
4070@code{(asdf:oos 'asdf:load-op :foo)}
4071to load a system,
4072and similarly for @code{compile-op}, @code{test-op}.
4073
4074In ASDF 2, you can use shortcuts for the usual operations:
4075@code{(asdf:load-system :foo)}, and
4076similarly for @code{compile-system}, @code{test-system}.
4077
4078
4079@subsection Many bugs have been fixed
4080
4081The following issues and many others have been fixed:
4082
4083@itemize
4084@item
4085The infamous TRAVERSE function has been revamped completely
4086between ASDF 1 and ASDF 2, with many bugs squashed.
4087In particular, dependencies were not correctly propagated
4088across modules but now are.
4089It has been completely rewritten many times over
4090between ASDF 2.000 and ASDF 3,
4091with fundamental issues in the original model being fixed.
4092Timestamps were not propagated at all, and now are.
4093The internal model of how actions depend on each other
4094is now both consistent and complete.
4095The :version and
4096the :force (system1 .. systemN) feature have been fixed.
4097
4098@item
4099Performance has been notably improved for large systems
4100(say with thousands of components) by using
4101hash-tables instead of linear search,
4102and linear-time list accumulation
4103instead of quadratic-time recursive appends.
4104
4105@item
4106Many features used to not be portable,
4107especially where pathnames were involved.
4108Windows support was notably quirky because of such non-portability.
4109
4110@item
4111The internal test suite used to massively fail on many implementations.
4112While still incomplete, it now fully passes
4113on all implementations supported by the test suite,
4114except for GCL (due to GCL bugs).
4115
4116@item
4117Support was lacking for some implementations.
4118ABCL and GCL were notably wholly broken.
4119ECL extensions were not integrated with ASDF release.
4120
4121@item
4122The documentation was grossly out of date.
4123
4124@end itemize
4125
4126
4127@subsection ASDF itself is versioned
4128
4129Between new features, old bugs fixed, and new bugs introduced,
4130there were various releases of ASDF in the wild,
4131and no simple way to check which release had which feature set.
4132People using or writing systems had to either make worst-case assumptions
4133as to what features were available and worked,
4134or take great pains to have the correct version of ASDF installed.
4135
4136With ASDF 2, we provide a new stable set of working features
4137that everyone can rely on from now on.
4138Use @code{#+asdf2} to detect presence of ASDF 2,
4139@code{(asdf:version-satisfies (asdf:asdf-version) "2.345.67")}
4140to check the availability of a version no earlier than required.
4141
4142
4143@subsection ASDF can be upgraded
4144
4145When an old version of ASDF was loaded,
4146it was very hard to upgrade ASDF in your current image
4147without breaking everything.
4148Instead you had to exit the Lisp process and
4149somehow arrange to start a new one from a simpler image.
4150Something that can't be done from within Lisp,
4151making automation of it difficult,
4152which compounded with difficulty in configuration,
4153made the task quite hard.
4154Yet as we saw before, the task would have been required
4155to not have to live with the worst case or non-portable
4156subset of ASDF features.
4157
4158With ASDF 2, it is easy to upgrade
4159from ASDF 2 to later versions from within Lisp,
4160and not too hard to upgrade from ASDF 1 to ASDF 2 from within Lisp.
4161We support hot upgrade of ASDF and any breakage is a bug
4162that we will do our best to fix.
4163There are still limitations on upgrade, though,
4164most notably the fact that after you upgrade ASDF,
4165you must also reload or upgrade all ASDF extensions.
4166
4167@subsection Decoupled release cycle
4168
4169When vendors were releasing their Lisp implementations with ASDF,
4170they had to basically never change version
4171because neither upgrade nor downgrade was possible
4172without breaking something for someone,
4173and no obvious upgrade path was visible and recommendable.
4174
4175With ASDF 2, upgrade is possible, easy and can be recommended.
4176This means that vendors can safely ship a recent version of ASDF,
4177confident that if a user isn't fully satisfied,
4178he can easily upgrade ASDF and deal
4179with a supported recent version of it.
4180This means that release cycles will be causally decoupled,
4181the practical consequence of which will mean faster convergence
4182towards the latest version for everyone.
4183
4184
4185@subsection Pitfalls of the transition to ASDF 2
4186
4187The main pitfalls in upgrading to ASDF 2 seem to be related
4188to the output translation mechanism.
4189
4190@itemize
4191
4192@item
4193Output translations is enabled by default. This may surprise some users,
4194most of them in pleasant way (we hope), a few of them in an unpleasant way.
4195It is trivial to disable output translations.
4196@xref{FAQ,,``How can I wholly disable the compiler output cache?''}.
4197
4198@item
4199Some systems in the large have been known
4200not to play well with output translations.
4201They were relatively easy to fix.
4202Once again, it is also easy to disable output translations,
4203or to override its configuration.
4204
4205@item
4206The new ASDF output translations are incompatible with ASDF-Binary-Locations.
4207They replace A-B-L, and there is compatibility mode to emulate
4208your previous A-B-L configuration.
4209See @code{enable-asdf-binary-locations-compatibility} in
4210@pxref{Controlling where ASDF saves compiled files,,Backward Compatibility}.
4211But thou shalt not load ABL on top of ASDF 2.
4212
4213@end itemize
4214
4215Other issues include the following:
4216
4217@itemize
4218
4219@item
4220ASDF pathname designators are now specified
4221in places where they were unspecified,
4222and a few small adjustments have to be made to some non-portable defsystems.
4223Notably, in the @code{:pathname} argument
4224to a @code{defsystem} and its components,
4225a logical pathname (or implementation-dependent hierarchical pathname)
4226must now be specified with @code{#p} syntax
4227where the namestring might have previously sufficed;
4228moreover when evaluation is desired @code{#.} must be used,
4229where it wasn't necessary in the toplevel @code{:pathname} argument
4230(but necessary in other @code{:pathname} arguments).
4231
4232@item
4233There is a slight performance bug, notably on SBCL,
4234when initially searching for @file{asd} files,
4235the implicit @code{(directory "/configured/path/**/*.asd")}
4236for every configured path @code{(:tree "/configured/path/")}
4237in your @code{source-registry} configuration can cause a slight pause.
4238Try to @code{(time (asdf:initialize-source-registry))}
4239to see how bad it is or isn't on your system.
4240If you insist on not having this pause,
4241you can avoid the pause by overriding the default source-registry configuration
4242and not use any deep @code{:tree} entry but only @code{:directory} entries
4243or shallow @code{:tree} entries.
4244Or you can fix your implementation to not be quite that slow
4245when recursing through directories.
4246@emph{Update}: This performance bug fixed the hard way in 2.010.
4247
4248@item
4249On Windows, only LispWorks supports proper default configuration pathnames
4250based on the Windows registry.
4251Other implementations make do with environment variables,
4252that you may have to define yourself
4253if you're using an older version of Windows.
4254Windows support is somewhat less tested than Unix support.
4255Please help report and fix bugs.
4256@emph{Update}: As of ASDF 2.21, all implementations
4257should now use the same proper default configuration pathnames
4258and they should actually work, though they haven't all been tested.
4259
4260@item
4261The mechanism by which one customizes a system so that Lisp files
4262may use a different extension from the default @file{.lisp} has changed.
4263Previously, the pathname for a component
4264was lazily computed when operating on a system,
4265and you would
4266@code{(defmethod source-file-type ((component cl-source-file) (system (eql (find-system 'foo))))
4267  (declare (ignorable component system)) "lis")}.
4268Now, the pathname for a component is eagerly computed when defining the system,
4269and instead you will @code{(defclass cl-source-file.lis (cl-source-file) ((type :initform "lis")))}
4270and use @code{:default-component-class cl-source-file.lis}
4271as argument to @code{defsystem},
4272as detailed in a @pxref{FAQ,How do I create a system definition where all the source files have a .cl extension?} below.
4273
4274@findex source-file-type
4275
4276
4277@end itemize
4278
4279
4280@section Issues with installing the proper version of ASDF
4281
4282@subsection ``My Common Lisp implementation comes with an outdated version of ASDF. What to do?''
4283
4284We recommend you upgrade ASDF.
4285@xref{Loading ASDF,,Upgrading ASDF}.
4286
4287If this does not work, it is a bug, and you should report it.
4288@xref{FAQ, report-bugs, Where do I report a bug}.
4289In the meantime, you can load @file{asdf.lisp} directly.
4290@xref{Loading ASDF,Loading an otherwise installed ASDF}.
4291
4292
4293@subsection ``I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?''
4294
4295Since ASDF 2,
4296it should always be a good time to upgrade to a recent version of ASDF.
4297You may consult with the maintainer for which specific version they recommend,
4298but the latest @code{release} should be correct.
4299Though we do try to test ASDF releases against all implementations that we can,
4300we may not be testing against all variants of your implementation,
4301and we may not be running enough tetst;
4302we trust you to thoroughly test it with your own implementation
4303before you release it.
4304If there are any issues with the current release,
4305it's a bug that you should report upstream and that we will fix ASAP.
4306
4307As to how to include ASDF, we recommend the following:
4308
4309@itemize
4310@item
4311If ASDF isn't loaded yet, then @code{(require "asdf")}
4312should load the version of ASDF that is bundled with your system.
4313If possible so should @code{(require "ASDF")}.
4314You may have it load some other version configured by the user,
4315if you allow such configuration.
4316
4317@item
4318If your system provides a mechanism to hook into @code{CL:REQUIRE},
4319then it would be nice to add ASDF to this hook the same way that
4320ABCL, CCL, CLISP, CMUCL, ECL, SBCL and SCL do it.
4321Please send us appropriate code to this end.
4322
4323@item
4324You may, like SBCL, have ASDF be implicitly used to require systems
4325that are bundled with your Lisp distribution.
4326If you do have a few magic systems that come with your implementation
4327in a precompiled way such that one should only use the binary version
4328that goes with your distribution, like SBCL does,
4329then you should add them in the beginning of @code{wrapping-source-registry}.
4330
4331@item
4332If you have magic systems as above, like SBCL does,
4333then we explicitly ask you to @emph{NOT} distribute
4334@file{asdf.asd} as part of those magic systems.
4335You should still include the file @file{asdf.lisp} in your source distribution
4336and precompile it in your binary distribution,
4337but @file{asdf.asd} if included at all,
4338should be secluded from the magic systems,
4339in a separate file hierarchy.
4340Alternatively, you may provide the system
4341after renaming it and its @file{.asd} file to e.g.
4342@code{asdf-ecl} and @file{asdf-ecl.asd}, or
4343@code{sb-asdf} and @file{sb-asdf.asd}.
4344Indeed, if you made @file{asdf.asd} a magic system,
4345then users would no longer be able to upgrade ASDF using ASDF itself
4346to some version of their preference that
4347they maintain independently from your Lisp distribution.
4348
4349@item
4350If you do not have any such magic systems, or have other non-magic systems
4351that you want to bundle with your implementation,
4352then you may add them to the @code{wrapping-source-registry},
4353and you are welcome to include @file{asdf.asd} amongst them.
4354Non-magic systems should be at the back of the @code{wrapping-source-registry}
4355while magic systems are at the front.
4356
4357@item
4358Since ASDF 3, the library UIOP comes transcluded in ASDF.
4359But for extra brownies, you may package UIOP separately,
4360so that one may @code{(require "uiop")} and not pull ASDF,
4361or one may @code{(require "asdf")}
4362and that would implicitly require the former.
4363
4364@item
4365Please send us upstream any patches you make to ASDF itself,
4366so we can merge them back in for the benefit of your users
4367when they upgrade to the upstream version.
4368
4369@end itemize
4370
4371
4372
4373@section Issues with configuring ASDF
4374
4375@subsection ``How can I customize where fasl files are stored?''
4376
4377@xref{Controlling where ASDF saves compiled files}.
4378
4379Note that in the past there was an add-on to ASDF called
4380@code{ASDF-binary-locations}, developed by Gary King.
4381That add-on has been merged into ASDF proper,
4382then superseded by the @code{asdf-output-translations} facility.
4383
4384Note that use of @code{asdf-output-translations}
4385can interfere with one aspect of your systems
4386--- if your system uses @code{*load-truename*} to find files
4387(e.g., if you have some data files stored with your program),
4388then the relocation that this ASDF customization performs
4389is likely to interfere.
4390Use @code{asdf:system-relative-pathname} to locate a file
4391in the source directory of some system, and
4392use @code{asdf:apply-output-translations} to locate a file
4393whose pathname has been translated by the facility.
4394
4395@subsection ``How can I wholly disable the compiler output cache?''
4396
4397To permanently disable the compiler output cache
4398for all future runs of ASDF, you can:
4399
4400@example
4401mkdir -p ~/.config/common-lisp/asdf-output-translations.conf.d/
4402echo ':disable-cache' > ~/.config/common-lisp/asdf-output-translations.conf.d/99-disable-cache.conf
4403@end example
4404
4405This assumes that you didn't otherwise configure the ASDF files
4406(if you did, edit them again),
4407and don't somehow override the configuration at runtime
4408with a shell variable (see below) or some other runtime command
4409(e.g. some call to @code{asdf:initialize-output-translations}).
4410
4411To disable the compiler output cache in Lisp processes
4412run by your current shell, try (assuming @code{bash} or @code{zsh})
4413(on Unix and cygwin only):
4414
4415@example
4416export ASDF_OUTPUT_TRANSLATIONS=/:
4417@end example
4418
4419To disable the compiler output cache just in the current Lisp process,
4420use (after loading ASDF but before using it):
4421
4422@example
4423(asdf:disable-output-translations)
4424@end example
4425
4426@section Issues with using and extending ASDF to define systems
4427
4428@subsection ``How can I cater for unit-testing in my system?''
4429
4430ASDF provides a predefined test operation, @code{test-op}.
4431@xref{Predefined operations of ASDF, test-op}.
4432The test operation, however, is largely left to the system definer to specify.
4433@code{test-op} has been
4434a topic of considerable discussion on the
4435@url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list},
4436and on the
4437@url{https://launchpad.net/asdf,launchpad bug-tracker}.
4438
4439Here are some guidelines:
4440
4441@itemize
4442@item
4443For a given system, @var{foo}, you will want to define a corresponding
4444test system, such as @var{foo-test}.  The reason that you will want this
4445separate system is that ASDF does not out of the box supply components
4446that are conditionally loaded.  So if you want to have source files
4447(with the test definitions) that will not be loaded except when testing,
4448they should be put elsewhere.
4449
4450@item
4451The @var{foo-test} system can be defined in an asd file of its own or
4452together with @var{foo}.  An aesthetic preference against cluttering up
4453the filesystem with extra asd files should be balanced against the
4454question of whether one might want to directly load @var{foo-test}.
4455Typically one would not want to do this except in early stages of
4456debugging.
4457
4458@item
4459Record that testing is implemented by @var{foo-test}.  For example:
4460@example
4461(defsystem @var{foo}
4462   :in-order-to ((test-op (test-op @var{foo-test})))
4463   ....)
4464
4465(defsystem @var{foo-test}
4466   :depends-on (@var{foo} @var{my-test-library} ...)
4467   ....)
4468@end example
4469@end itemize
4470
4471This procedure will allow you to support users who do not wish to
4472install your test framework.
4473
4474One oddity of ASDF is that @code{operate} (@pxref{Operations,operate})
4475does not return a value.  So in current versions of ASDF there is no
4476reliable programmatic means of determining whether or not a set of tests
4477has passed, or which tests have failed.  The user must simply read the
4478console output.  This limitation has been the subject of much
4479discussion.
4480
4481@subsection ``How can I cater for documentation generation in my system?''
4482
4483The ASDF developers are currently working to add a @code{doc-op}
4484to the set of predefined ASDF operations.
4485@xref{Predefined operations of ASDF}.
4486See also @url{https://bugs.launchpad.net/asdf/+bug/479470}.
4487
4488
4489
4490@subsection ``How can I maintain non-Lisp (e.g. C) source files?''
4491
4492See @code{cffi}'s @code{cffi-grovel}.
4493
4494@anchor{report-bugs}
4495
4496
4497@subsection ``I want to put my module's files at the top level.  How do I do this?''
4498
4499By default, the files contained in an asdf module go
4500in a subdirectory with the same name as the module.
4501However, this can be overridden by adding a @code{:pathname ""} argument
4502to the module description.
4503For example, here is how it could be done
4504in the spatial-trees ASDF system definition for ASDF 2:
4505
4506@example
4507(asdf:defsystem :spatial-trees
4508  :components
4509  ((:module base
4510            :pathname ""
4511            :components
4512            ((:file "package")
4513             (:file "basedefs" :depends-on ("package"))
4514             (:file "rectangles" :depends-on ("package"))))
4515   (:module tree-impls
4516            :depends-on (base)
4517            :pathname ""
4518            :components
4519            ((:file "r-trees")
4520             (:file "greene-trees" :depends-on ("r-trees"))
4521             (:file "rstar-trees" :depends-on ("r-trees"))
4522             (:file "rplus-trees" :depends-on ("r-trees"))
4523             (:file "x-trees" :depends-on ("r-trees" "rstar-trees"))))
4524   (:module viz
4525            :depends-on (base)
4526            :pathname ""
4527            :components
4528            ((:static-file "spatial-tree-viz.lisp")))
4529   (:module tests
4530            :depends-on (base)
4531            :pathname ""
4532            :components
4533            ((:static-file "spatial-tree-test.lisp")))
4534   (:static-file "LICENCE")
4535   (:static-file "TODO")))
4536@end example
4537
4538All of the files in the @code{tree-impls} module are at the top level,
4539instead of in a @file{tree-impls/} subdirectory.
4540
4541Note that the argument to @code{:pathname} can be either a pathname object or a string.
4542A pathname object can be constructed with the @file{#p"foo/bar/"} syntax,
4543but this is discouraged because the results of parsing a namestring are not portable.
4544A pathname can only be portably constructed with such syntax as
4545@code{#.(make-pathname :directory '(:relative "foo" "bar"))},
4546and similarly the current directory can only be portably specified as
4547@code{#.(make-pathname :directory '(:relative))}.
4548However, as of ASDF 2, you can portably use a string to denote a pathname.
4549The string will be parsed as a @code{/}-separated path from the current directory,
4550such that the empty string @code{""} denotes the current directory, and
4551@code{"foo/bar"} (no trailing @code{/} required in the case of modules)
4552portably denotes the same subdirectory as above.
4553When files are specified, the last @code{/}-separated component is interpreted
4554either as the name component of a pathname
4555(if the component class specifies a pathname type),
4556or as a name component plus optional dot-separated type component
4557(if the component class doesn't specifies a pathname type).
4558
4559@subsection How do I create a system definition where all the source files have a .cl extension?
4560
4561Starting with ASDF 2.014.14, you may just pass
4562the builtin class @code{cl-source-file.cl} as
4563the @code{:default-component-class} argument to @code{defsystem}:
4564
4565@lisp
4566(defsystem my-cl-system
4567  :default-component-class cl-source-file.cl
4568  ...)
4569@end lisp
4570
4571Another builtin class @code{cl-source-file.lsp} is offered
4572for files ending in @file{.lsp}.
4573
4574If you want to use a different extension
4575for which ASDF doesn't provide builtin support,
4576or want to support versions of ASDF
4577earlier than 2.014.14 (but later than 2.000),
4578you can define a class as follows:
4579
4580@lisp
4581;; Prologue: make sure we're using a sane package.
4582(defpackage :my-asdf-extension
4583   (:use :asdf :common-lisp)
4584   (:export #:cl-source-file.lis))
4585(in-package :my-asdf-extension)
4586
4587(defclass cl-source-file.lis (cl-source-file)
4588  ((type :initform "lis")))
4589@end lisp
4590
4591Then you can use it as follows:
4592@lisp
4593(defsystem my-cl-system
4594  :default-component-class my-asdf-extension:cl-source-file.lis
4595  ...)
4596@end lisp
4597
4598Of course, if you're in the same package, e.g. in the same file,
4599you won't need to use the package qualifier before @code{cl-source-file.lis}.
4600Actually, if all you're doing is defining this class
4601and using it in the same file without other fancy definitions,
4602you might skip package complications:
4603
4604@lisp
4605(in-package :asdf)
4606(defclass cl-source-file.lis (cl-source-file)
4607   ((type :initform "lis")))
4608(defsystem my-cl-system
4609  :default-component-class cl-source-file.lis
4610  ...)
4611@end lisp
4612
4613It is possible to achieve the same effect
4614in a way that supports both ASDF 1 and ASDF 2,
4615but really, friends don't let friends use ASDF 1.
4616Please upgrade to ASDF 3.
4617In short, though: do same as above, but
4618@emph{before} you use the class in a @code{defsystem},
4619you also define the following method:
4620
4621@lisp
4622(defmethod source-file-type ((f cl-source-file.lis) (s system))
4623  (declare (ignorable f s))
4624  "lis")
4625@end lisp
4626
4627@comment FIXME: Add a FAQ about how to use a new system class...
4628
4629
4630@node  TODO list, Inspiration, FAQ, Top
4631@comment  node-name,  next,  previous,  up
4632@chapter TODO list
4633
4634Here is an old list of things to do,
4635in addition to the bugs that are now tracked on launchpad:
4636@url{https://launchpad.net/asdf}.
4637
4638@section Outstanding spec questions, things to add
4639
4640** packaging systems
4641
4642*** manual page component?
4643
4644** style guide for .asd files
4645
4646You should either use keywords or be careful
4647with the package that you evaluate defsystem forms in.
4648Otherwise @code{(defsystem partition ...)}
4649being read in the @code{cl-user} package
4650will intern a @code{cl-user:partition} symbol,
4651which will then collide with the @code{partition:partition} symbol.
4652
4653Actually there's a hairier packages problem to think about too.
4654@code{in-order-to} is not a keyword:
4655if you read @code{defsystem} forms in a package that doesn't use ASDF,
4656odd things might happen.
4657
4658
4659** extending defsystem with new options
4660
4661You might not want to write a whole parser,
4662but just to add options to the existing syntax.
4663Reinstate @code{parse-option} or something akin.
4664
4665
4666** Diagnostics
4667
4668A ``dry run'' of an operation can be made with the following form:
4669
4670@lisp
4671(let ((asdf::*verbose-out* *standard-output*))
4672  (loop :for (op . comp) :in
4673    (asdf::traverse (make-instance '<operation-name> :force t)
4674                    (asdf:find-system <system-name>))
4675    :do (asdf:explain op comp)))
4676@end lisp
4677
4678This uses unexported symbols.
4679What would be a nice interface for this functionality?
4680
4681@section Missing bits in implementation
4682
4683** reuse the same scratch package whenever a system is reloaded from disk
4684
4685Have a package ASDF-USER instead of all these temporary packages?
4686
4687** proclamations probably aren't
4688
4689** A revert function
4690
4691Other possible interface: have a ``revert'' function akin to @code{make clean}.
4692
4693@lisp
4694(asdf:revert 'asdf:compile-op 'araneida)
4695@end lisp
4696
4697would delete any files produced by @code{(compile-system :araneida)}.
4698Of course, it wouldn't be able to do much about stuff in the image itself.
4699
4700How would this work?
4701
4702@code{traverse}
4703
4704There's a difference between a module's dependencies (peers)
4705and its components (children).
4706Perhaps there's a similar difference in operations?
4707For example, @code{(load "use") depends-on (load "macros")} is a peer,
4708whereas @code{(load "use") depends-on (compile "use")}
4709is more of a ``subservient'' relationship.
4710
4711@node  Inspiration, Concept Index, TODO list, Top
4712@comment  node-name,  next,  previous,  up
4713@chapter Inspiration
4714
4715@section mk-defsystem (defsystem-3.x)
4716
4717We aim to solve basically the same problems as @code{mk-defsystem} does.
4718However, our architecture for extensibility
4719better exploits CL language features (and is documented),
4720and we intend to be portable rather than just widely-ported.
4721No slight on the @code{mk-defsystem} authors and maintainers is intended here;
4722that implementation has the unenviable task
4723of supporting pre-ANSI implementations, which is no longer necessary.
4724
4725The surface defsystem syntax of asdf is more-or-less compatible with
4726@code{mk-defsystem}, except that we do not support
4727the @code{source-foo} and @code{binary-foo} prefixes
4728for separating source and binary files, and
4729we advise the removal of all options to specify pathnames.
4730
4731The @code{mk-defsystem} code for topologically sorting
4732a module's dependency list was very useful.
4733
4734@section defsystem-4 proposal
4735
4736Marco and Peter's proposal for defsystem 4 served as the driver for
4737many of the features in here.  Notable differences are:
4738
4739@itemize
4740@item
4741We don't specify output files or output file extensions
4742as part of the system.
4743
4744If you want to find out what files an operation would create,
4745ask the operation.
4746
4747@item
4748We don't deal with CL packages
4749
4750If you want to compile in a particular package, use an @code{in-package} form
4751in that file (ilisp / SLIME will like you more if you do this anyway)
4752
4753@item
4754There is no proposal here that @code{defsystem} does version control.
4755
4756A system has a given version which can be used to check dependencies,
4757but that's all.
4758@end itemize
4759
4760The defsystem 4 proposal tends to look more at the external features,
4761whereas this one centres on a protocol for system introspection.
4762
4763@section kmp's ``The Description of Large Systems'', MIT AI Memo 801
4764
4765Available in updated-for-CL form on the web at
4766@url{http://nhplace.com/kent/Papers/Large-Systems.html}
4767
4768In our implementation we borrow kmp's overall @code{PROCESS-OPTIONS}
4769and concept to deal with creating component trees
4770from @code{defsystem} surface syntax.
4771[ this is not true right now, though it used to be and
4772probably will be again soon ]
4773
4774
4775@c -------------------
4776
4777
4778@node Concept Index, Function and Class Index, Inspiration, Top
4779@unnumbered Concept Index
4780
4781@printindex cp
4782
4783@node Function and Class Index, Variable Index, Concept Index, Top
4784@unnumbered Function and Class Index
4785
4786@printindex fn
4787
4788@node Variable Index,  , Function and Class Index, Top
4789@unnumbered Variable Index
4790
4791@printindex vr
4792
4793@bye
Note: See TracBrowser for help on using the repository browser.