1.0.48.30: adjust DOCUMENTATION and SB-INTROSPECT
[sbcl.git] / contrib / asdf / asdf.texinfo
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 &allow-other-keys
10 &allow-other-keys
11 @end macro
12 @macro &optional
13 &optional
14 @end macro
15 @macro &rest
16 &rest
17 @end macro
18 @macro &key
19 &key
20 @end macro
21 @macro &body
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
32 This manual describes ASDF, a system definition facility
33 for Common Lisp programs and libraries.
34
35 You can find the latest version of this manual at
36 @url{http://common-lisp.net/project/asdf/asdf.html}.
37
38 ASDF Copyright @copyright{} 2001-2011 Daniel Barlow and contributors.
39
40 This manual Copyright @copyright{} 2001-2011 Daniel Barlow and contributors.
41
42 This manual revised @copyright{} 2009-2011 Robert P. Goldman and Francois-Rene Rideau.
43
44 Permission is hereby granted, free of charge, to any person obtaining
45 a copy of this software and associated documentation files (the
46 ``Software''), to deal in the Software without restriction, including
47 without limitation the rights to use, copy, modify, merge, publish,
48 distribute, sublicense, and/or sell copies of the Software, and to
49 permit persons to whom the Software is furnished to do so, subject to
50 the following conditions:
51
52 The above copyright notice and this permission notice shall be
53 included in all copies or substantial portions of the Software.
54
55 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
56 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
59 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
60 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
61 WITH 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
122 @c Operations
123
124 @c * Predefined operations of ASDF::
125 @c * Creating new operations::
126
127 @c Components
128
129 @c * Common attributes of components::
130 @c * Pre-defined subclasses of component::
131 @c * Creating new component types::
132
133 @c properties
134
135 @c * Pre-defined subclasses of component::
136 @c * Creating new component types::
137
138 @c @end detailmenu
139 @end menu
140
141 @end ifnottex
142
143 @c -------------------
144
145 @node Introduction, Loading ASDF, Top, Top
146 @comment  node-name,  next,  previous,  up
147 @chapter Introduction
148 @cindex ASDF-related features
149 @vindex *features*
150 @cindex Testing for ASDF
151 @cindex ASDF versions
152 @cindex :asdf
153 @cindex :asdf2
154
155 ASDF is Another System Definition Facility:
156 a tool for specifying how systems of Common Lisp software
157 are comprised of components (sub-systems and files),
158 and how to operate on these components in the right order
159 so that they can be compiled, loaded, tested, etc.
160
161 ASDF presents three faces:
162 one for users of Common Lisp software who want to reuse other people's code,
163 one for writers of Common Lisp software who want to specify how to build their systems,
164 one for implementers of Common Lisp extensions who want to extend the build system.
165 @xref{Using ASDF,,Loading a system},
166 to learn how to use ASDF to load a system.
167 @xref{Defining systems with defsystem},
168 to learn how to define a system of your own.
169 @xref{The object model of ASDF}, for a description of
170 the ASDF internals and how to extend ASDF.
171
172 @emph{Nota Bene}:
173 We have released ASDF 2.000 on May 31st 2010.
174 Subsequent releases of ASDF 2 have since then been included
175 in all actively maintained CL implementations that bundle ASDF,
176 and made to work with all actively used CL implementations and a few more.
177 @xref{FAQ,,``What has changed between ASDF 1 and ASDF 2?''}.
178 Furthermore, it is possible to upgrade from ASDF 1 to ASDF 2 on the fly.
179 For this reason, we have stopped supporting ASDF 1;
180 if you are using ASDF 1 and are experiencing any kind of issues or limitations,
181 we recommend you upgrade to ASDF 2
182 --- and we explain how to do it. @xref{Loading ASDF}.
183
184
185 @node Loading ASDF, Configuring ASDF, Introduction, Top
186 @comment  node-name,  next,  previous,  up
187 @chapter Loading ASDF
188 @vindex *central-registry*
189 @cindex link farm
190 @findex load-system
191 @findex compile-system
192 @findex test-system
193 @cindex system directory designator
194 @findex operate
195 @findex oos
196
197 @c @menu
198 @c * Installing ASDF::
199 @c @end menu
200
201
202 @section Loading a pre-installed ASDF
203
204 Many Lisp implementations include a copy of ASDF.
205 You can usually load this copy using Common Lisp's @code{require} function:
206
207 @lisp
208 (require :asdf)
209 @end lisp
210
211 As of the writing of this manual,
212 the following implementations provide ASDF 2 this way:
213 abcl allegro ccl clisp cmucl ecl sbcl xcl.
214 The following implementations don't provide it yet but might in a future release:
215 lispworks scl.
216 The following implementations are obsolete and most probably will never bundle it:
217 cormancl gcl genera mcl.
218
219 If the implementation you are using doesn't provide ASDF 2,
220 see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below.
221 If that implementation is still actively maintained,
222 you may also send a bug report to your Lisp vendor and complain
223 about their failing to provide ASDF.
224
225
226 @section Checking whether ASDF is loaded
227
228 To check whether ASDF is properly loaded in your current Lisp image,
229 you can run this form:
230
231 @lisp
232 (asdf:asdf-version)
233 @end lisp
234
235 If it returns a string,
236 that is the version of ASDF that is currently installed.
237
238 If it raises an error,
239 then either ASDF is not loaded, or
240 you are using an old version of ASDF.
241
242 You can check whether an old version is loaded
243 by checking if the ASDF package is present.
244 The form below will allow you to programmatically determine
245 whether a recent version is loaded, an old version is loaded,
246 or none at all:
247
248 @lisp
249 (or #+asdf2 (asdf:asdf-version) #+asdf :old)
250 @end lisp
251
252 If it returns a version number, that's the version of ASDF installed.
253 If it returns the keyword @code{:OLD},
254 then you're using an old version of ASDF (from before 1.635).
255 If it returns @code{NIL} then ASDF is not installed.
256
257 If you are experiencing problems with ASDF,
258 please try upgrading to the latest released version,
259 using the method below,
260 before you contact us and raise an issue.
261
262
263 @section Upgrading ASDF
264
265 If your implementation does provide ASDF 2 or later,
266 and you want to upgrade to a more recent version,
267 just install ASDF like any other package
268 (see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below),
269 configure ASDF as usual (see @pxref{Configuring ASDF} below),
270 and upgrade with:
271
272 @lisp
273 (require :asdf)
274 (asdf:load-system :asdf)
275 @end lisp
276
277 If on the other hand, your implementation only provides an old ASDF,
278 you will require a special configuration step and an old-style loading:
279
280 @lisp
281 (require :asdf)
282 (push #p"@var{/path/to/new/asdf/}" asdf:*central-registry*)
283 (asdf:oos 'asdf:load-op :asdf)
284 @end lisp
285
286 Don't forget the trailing @code{/} at the end of your pathname.
287
288 Also, note that older versions of ASDF won't redirect their output,
289 or at least won't do it according to your usual ASDF 2 configuration.
290 You therefore need write access on the directory
291 where you install the new ASDF,
292 and make sure you're not using it
293 for multiple mutually incompatible implementations.
294 At worst, you may have to have multiple copies of the new ASDF,
295 e.g. one per implementation installation, to avoid clashes.
296 Note that to our knowledge all implementations that provide ASDF
297 provide ASDF 2 in their latest release, so
298 you may want to upgrade your implementation rather than go through that hoop.
299
300 Finally, note that there are some limitations to upgrading ASDF:
301 @itemize
302 @item
303 Any ASDF extension becomes invalid, and will need to be reloaded.
304 This applies to e.g. CFFI-Grovel, or to hacks used by ironclad, etc.
305 Starting with ASDF 2.014.8, ASDF will actually invalidate
306 all previously loaded systems when it is loaded on top of
307 a different ASDF version.
308 @item
309 Until all implementations provide ASDF 2.015 or later,
310 it is safer if you upgrade ASDF and its extensions as a special step
311 at the very beginning of whatever script you are running,
312 before you start using ASDF to load anything else.
313 @item
314 Until all implementations provide ASDF 2.015 or later,
315 it is unsafe to upgrade ASDF as part of loading a system
316 that depends on a more recent version of ASDF,
317 since the new one might shadow the old one while the old one is running,
318 and the running old one will be confused
319 when extensions are loaded into the new one.
320 In the meantime, we recommend that your systems should @emph{not} specify
321 @code{:depends-on (:asdf)}, or @code{:depends-on ((:version :asdf "2.010"))},
322 but instead that they check that a recent enough ASDF is installed,
323 with such code as:
324 @example
325 (unless (or #+asdf2 (asdf:version-satisfies
326                      (asdf:asdf-version) *required-asdf-version*))
327   (error "FOO requires ASDF ~A or later." *required-asdf-version*))
328 @end example
329 @end itemize
330
331
332 @section Loading an otherwise installed ASDF
333
334 If your implementation doesn't include ASDF,
335 if for some reason the upgrade somehow fails,
336 does not or cannot apply to your case,
337 you will have to install the file @file{asdf.lisp}
338 somewhere and load it with:
339
340 @lisp
341 (load "/path/to/your/installed/asdf.lisp")
342 @end lisp
343
344 The single file @file{asdf.lisp} is all you normally need to use ASDF.
345
346 You can extract this file from latest release tarball on the
347 @url{http://common-lisp.net/project/asdf/,ASDF website}.
348 If you are daring and willing to report bugs, you can get
349 the latest and greatest version of ASDF from its git repository.
350 @xref{Getting the latest version}.
351
352 For maximum convenience you might want to have ASDF loaded
353 whenever you start your Lisp implementation,
354 for example by loading it from the startup script or dumping a custom core
355 --- check your Lisp implementation's manual for details.
356
357
358 @node Configuring ASDF, Using ASDF, Loading ASDF, Top
359 @comment  node-name,  next,  previous,  up
360
361 @chapter Configuring ASDF
362
363 @section Configuring ASDF to find your systems
364
365 So it may compile and load your systems, ASDF must be configured to find
366 the @file{.asd} files that contain system definitions.
367
368 Since ASDF 2, the preferred way to configure where ASDF finds your systems is
369 the @code{source-registry} facility,
370 fully described in its own chapter of this manual.
371 @xref{Controlling where ASDF searches for systems}.
372
373 The default location for a user to install Common Lisp software is under
374 @file{~/.local/share/common-lisp/source/}.
375 If you install software there, you don't need further configuration.
376 If you're installing software yourself at a location that isn't standard,
377 you have to tell ASDF where you installed it. See below.
378 If you're using some tool to install software,
379 the authors of that tool should already have configured ASDF.
380
381 The simplest way to add a path to your search path,
382 say @file{/home/luser/.asd-link-farm/}
383 is to create the directory
384 @file{~/.config/common-lisp/source-registry.conf.d/}
385 and there create a file with any name of your choice but the type @file{conf},
386 for instance @file{42-asd-link-farm.conf}
387 containing the line:
388
389 @kbd{(:directory "/home/luser/.asd-link-farm/")}
390
391 If you want all the subdirectories under @file{/home/luser/lisp/}
392 to be recursively scanned for @file{.asd} files, instead use:
393
394 @kbd{(:tree "/home/luser/lisp/")}
395
396 Note that your Operating System distribution or your system administrator
397 may already have configured system-managed libraries for you.
398
399 The required @file{.conf} extension allows you to have disabled files
400 or editor backups (ending in @file{~}), and works portably
401 (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
402 Excluded are files the name of which start with a @file{.} character.
403 It is customary to start the filename with two digits
404 that specify the order in which the directories will be scanned.
405
406 ASDF will automatically read your configuration
407 the first time you try to find a system.
408 You can reset the source-registry configuration with:
409
410 @lisp
411 (asdf:clear-source-registry)
412 @end lisp
413
414 And you probably should do so before you dump your Lisp image,
415 if the configuration may change
416 between the machine where you save it at the time you save it
417 and the machine you resume it at the time you resume it.
418
419
420 @section Configuring ASDF to find your systems -- old style
421
422 The old way to configure ASDF to find your systems is by
423 @code{push}ing directory pathnames onto the variable
424 @code{asdf:*central-registry*}.
425
426 You must configure this variable between the time you load ASDF
427 and the time you first try to use it.
428 Loading and configuring ASDF presumably happen
429 as part of some initialization script that builds or starts
430 your Common Lisp software system.
431 (For instance, some SBCL users used to put it in their @file{~/.sbclrc}.)
432
433 The @code{asdf:*central-registry*} is empty by default in ASDF 2,
434 but is still supported for compatibility with ASDF 1.
435 When used, it takes precedence over the above source-registry@footnote{
436 It is possible to further customize
437 the system definition file search.
438 That's considered advanced use, and covered later:
439 search forward for
440 @code{*system-definition-search-functions*}.
441 @xref{Defining systems with defsystem}.}.
442
443 For instance, if you wanted ASDF to find the @file{.asd} file
444 @file{/home/me/src/foo/foo.asd} your initialization script
445 could after it loads ASDF with @code{(require :asdf)}
446 configure it with:
447
448 @lisp
449 (push "/home/me/src/foo/" asdf:*central-registry*)
450 @end lisp
451
452 Note the trailing slash: when searching for a system,
453 ASDF will evaluate each entry of the central registry
454 and coerce the result to a pathname@footnote{
455 ASDF will indeed call @code{EVAL} on each entry.
456 It will also skip entries that evaluate to @code{NIL}.
457
458 Strings and pathname objects are self-evaluating,
459 in which case the @code{EVAL} step does nothing;
460 but you may push arbitrary SEXP onto the central registry,
461 that will be evaluated to compute e.g. things that depend
462 on the value of shell variables or the identity of the user.
463
464 The variable @code{asdf:*central-registry*} is thus a list of
465 ``system directory designators''.
466 A @dfn{system directory designator} is a form
467 which will be evaluated whenever a system is to be found,
468 and must evaluate to a directory to look in.
469 By ``directory'' here, we mean
470 ``designator for a pathname with a supplied DIRECTORY component''.
471 }
472 at which point the presence of the trailing directory name separator
473 is necessary to tell Lisp that you're discussing a directory
474 rather than a file.
475
476 Typically, however, there are a lot of @file{.asd} files, and
477 a common idiom was to have to put
478 a bunch of @emph{symbolic links} to @file{.asd} files
479 in a common directory
480 and push @emph{that} directory (the ``link farm'')
481 to the
482 @code{asdf:*central-registry*}
483 instead of pushing each of the many involved directories
484 to the @code{asdf:*central-registry*}.
485 ASDF knows how to follow such @emph{symlinks}
486 to the actual file location when resolving the paths of system components
487 (on Windows, you can use Windows shortcuts instead of POSIX symlinks).
488
489 For example, if @code{#p"/home/me/cl/systems/"} (note the trailing slash)
490 is a member of @code{*central-registry*}, you could set up the
491 system @var{foo} for loading with asdf with the following
492 commands at the shell:
493
494 @example
495 $ cd /home/me/cl/systems/
496 $ ln -s ~/src/foo/foo.asd .
497 @end example
498
499 This old style for configuring ASDF is not recommended for new users,
500 but it is supported for old users, and for users who want to programmatically
501 control what directories are added to the ASDF search path.
502
503
504 @section Configuring where ASDF stores object files
505 @findex clear-output-locations
506
507 ASDF lets you configure where object files will be stored.
508 Sensible defaults are provided and
509 you shouldn't normally have to worry about it.
510
511 This allows the same source code repository may be shared
512 between several versions of several Common Lisp implementations,
513 between several users using different compilation options
514 and without write privileges on shared source directories, etc.
515 This also allows to keep source directories uncluttered
516 by plenty of object files.
517
518 Starting with ASDF 2, the @code{asdf-output-translations} facility
519 was added to ASDF itself, that controls where object files will be stored.
520 This facility is fully described in a chapter of this manual,
521 @ref{Controlling where ASDF saves compiled files}.
522
523 The simplest way to add a translation to your search path,
524 say from @file{/foo/bar/baz/quux/}
525 to @file{/where/i/want/my/fasls/}
526 is to create the directory
527 @file{~/.config/common-lisp/asdf-output-translations.conf.d/}
528 and there create a file with any name of your choice and the type @file{conf},
529 for instance @file{42-bazquux.conf}
530 containing the line:
531
532 @kbd{("/foo/bar/baz/quux/" "/where/i/want/my/fasls/")}
533
534 To disable output translations for source under a given directory,
535 say @file{/toto/tata/}
536 you can create a file @file{40-disable-toto.conf}
537 with the line:
538
539 @kbd{("/toto/tata/")}
540
541 To wholly disable output translations for all directories,
542 you can create a file @file{00-disable.conf}
543 with the line:
544
545 @kbd{(t t)}
546
547 Note that your Operating System distribution or your system administrator
548 may already have configured translations for you.
549 In absence of any configuration, the default is to redirect everything
550 under an implementation-dependent subdirectory of @file{~/.cache/common-lisp/}.
551 @xref{Controlling where ASDF searches for systems}, for full details.
552
553 The required @file{.conf} extension allows you to have disabled files
554 or editor backups (ending in @file{~}), and works portably
555 (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
556 Excluded are files the name of which start with a @file{.} character.
557 It is customary to start the filename with two digits
558 that specify the order in which the directories will be scanned.
559
560 ASDF will automatically read your configuration
561 the first time you try to find a system.
562 You can reset the source-registry configuration with:
563
564 @lisp
565 (asdf:clear-output-translations)
566 @end lisp
567
568 And you probably should do so before you dump your Lisp image,
569 if the configuration may change
570 between the machine where you save it at the time you save it
571 and the machine you resume it at the time you resume it.
572
573 Finally note that before ASDF 2,
574 other ASDF add-ons offered the same functionality,
575 each in subtly different and incompatible ways:
576 ASDF-Binary-Locations, cl-launch, common-lisp-controller.
577 ASDF-Binary-Locations is now not needed anymore and should not be used.
578 cl-launch 3.000 and common-lisp-controller 7.2 have been updated
579 to just delegate this functionality to ASDF.
580
581 @node Using ASDF, Defining systems with defsystem, Configuring ASDF, Top
582 @comment  node-name,  next,  previous,  up
583
584 @chapter Using ASDF
585
586 @section Loading a system
587
588 The system @var{foo} is loaded (and compiled, if necessary)
589 by evaluating the following Lisp form:
590
591 @example
592 (asdf:load-system :@var{foo})
593 @end example
594
595 On some implementations (namely recent versions of
596 ABCL, Clozure CL, CLISP, CMUCL, ECL, SBCL and SCL),
597 ASDF hooks into the @code{CL:REQUIRE} facility
598 and you can just use:
599
600 @example
601 (require :@var{foo})
602 @end example
603
604 In older versions of ASDF, you needed to use
605 @code{(asdf:oos 'asdf:load-op :@var{foo})}.
606 If your ASDF is too old to provide @code{asdf:load-system} though
607 we recommend that you upgrade to ASDF 2.
608 @xref{Loading ASDF,,Loading an otherwise installed ASDF}.
609
610 Note the name of a system is specified as a string or a symbol,
611 typically a keyword.
612 If a symbol (including a keyword), its name is taken and lowercased.
613 The name must be a suitable value for the @code{:name} initarg
614 to @code{make-pathname} in whatever filesystem the system is to be found.
615 The lower-casing-symbols behaviour is unconventional,
616 but was selected after some consideration.
617 Observations suggest that the type of systems we want to support
618 either have lowercase as customary case (unix, mac, windows)
619 or silently convert lowercase to uppercase (lpns),
620 so this makes more sense than attempting to use @code{:case :common},
621 which is reported not to work on some implementations
622
623
624 @section Other Operations
625
626 ASDF provides three commands for the most common system operations:
627 @code{load-system}, @code{compile-system} or @code{test-system}.
628
629 Because ASDF is an extensible system
630 for defining @emph{operations} on @emph{components},
631 it also provides a generic function @code{operate}
632 (which is usually abbreviated by @code{oos}).
633 You'll use @code{oos} whenever you want to do something beyond
634 compiling, loading and testing.
635
636 Output from ASDF and ASDF extensions are supposed to be sent
637 to the CL stream @code{*standard-output*},
638 and so rebinding that stream around calls to @code{asdf:operate}
639 should redirect all output from ASDF operations.
640
641 Reminder: before ASDF can operate on a system, however,
642 it must be able to find and load that system's definition.
643 @xref{Configuring ASDF,,Configuring ASDF to find your systems}.
644
645
646 @section Summary
647
648 To use ASDF:
649
650 @itemize
651 @item
652 Load ASDF itself into your Lisp image, either through
653 @code{(require :asdf)} or else through
654 @code{(load "/path/to/asdf.lisp")}.
655
656 @item
657 Make sure ASDF can find system definitions
658 thanks to proper source-registry configuration.
659
660 @item
661 Load a system with @code{(load-system :my-system)}
662 or use some other operation on some system of your choice.
663
664 @end itemize
665
666 @section Moving on
667
668 That's all you need to know to use ASDF to load systems written by others.
669 The rest of this manual deals with writing system definitions
670 for Common Lisp software you write yourself,
671 including how to extend ASDF to define new operation and component types.
672
673
674 @node Defining systems with defsystem, The object model of ASDF, Using ASDF, Top
675 @comment  node-name,  next,  previous,  up
676 @chapter Defining systems with defsystem
677
678 This chapter describes how to use asdf to define systems and develop
679 software.
680
681
682 @menu
683 * The defsystem form::
684 * A more involved example::
685 * The defsystem grammar::
686 * Other code in .asd files::
687 @end menu
688
689 @node  The defsystem form, A more involved example, Defining systems with defsystem, Defining systems with defsystem
690 @comment  node-name,  next,  previous,  up
691 @section The defsystem form
692
693 Systems can be constructed programmatically
694 by instantiating components using @code{make-instance}.
695 Most of the time, however, it is much more practical to use
696 a static @code{defsystem} form.
697 This section begins with an example of a system definition,
698 then gives the full grammar of @code{defsystem}.
699
700 Let's look at a simple system.
701 This is a complete file that would
702 usually be saved as @file{hello-lisp.asd}:
703
704 @lisp
705 (in-package :asdf)
706
707 (defsystem "hello-lisp"
708   :description "hello-lisp: a sample Lisp system."
709   :version "0.2.1"
710   :author "Joe User <joe@@example.com>"
711   :licence "Public Domain"
712   :components ((:file "packages")
713                (:file "macros" :depends-on ("packages"))
714                (:file "hello" :depends-on ("macros"))))
715 @end lisp
716
717 Some notes about this example:
718
719 @itemize
720
721 @item
722 The file starts with an @code{in-package} form
723 to use package @code{asdf}.
724 You could instead start your definition by using
725 a qualified name @code{asdf:defsystem}.
726
727 @item
728 If in addition to simply using @code{defsystem},
729 you are going to define functions,
730 create ASDF extension, globally bind symbols, etc.,
731 it is recommended that to avoid namespace pollution between systems,
732 you should create your own package for that purpose,
733 for instance replacing the above @code{(in-package :asdf)} with:
734
735 @lisp
736 (defpackage :foo-system
737   (:use :cl :asdf))
738
739 (in-package :foo-system)
740 @end lisp
741
742 @item
743 The @code{defsystem} form defines a system named @code{hello-lisp}
744 that contains three source files:
745 @file{packages}, @file{macros} and @file{hello}.
746
747 @item
748 The file @file{macros} depends on @file{packages}
749 (presumably because the package it's in is defined in @file{packages}),
750 and the file @file{hello} depends on @file{macros}
751 (and hence, transitively on @file{packages}).
752 This means that ASDF will compile and load @file{packages} and @file{macros}
753 before starting the compilation of file @file{hello}.
754
755 @item
756 The files are located in the same directory
757 as the file with the system definition.
758 ASDF resolves symbolic links (or Windows shortcuts)
759 before loading the system definition file and
760 stores its location in the resulting system@footnote{
761 It is possible, though almost never necessary, to override this behaviour.}.
762 This is a good thing because the user can move the system sources
763 without having to edit the system definition.
764
765 @c FIXME: Should have cross-reference to "Version specifiers" in the
766 @c defsystem grammar, but the cross-referencing is so broken by
767 @c insufficient node breakdown that I have not put one in.
768 @item
769 Make sure you know how the @code{:version} numbers will be parsed!  They
770 are parsed as period-separated lists of integers.  I.e., in the example,
771 @code{0.2.1} is to be interpreted, roughly speaking, as @code{(0 2 1)}.
772 In particular, version @code{0.2.1} is interpreted the same as
773 @code{0.0002.1} and is strictly version-less-than version @code{0.20.1},
774 even though the two are the same when interpreted as decimal fractions.
775 @cindex version specifiers
776 @cindex :version
777
778 @end itemize
779
780 @node  A more involved example, The defsystem grammar, The defsystem form, Defining systems with defsystem
781 @comment  node-name,  next,  previous,  up
782 @section A more involved example
783
784 Let's illustrate some more involved uses of @code{defsystem} via a
785 slightly convoluted example:
786
787 @lisp
788 (defsystem "foo"
789   :version "1.0.0"
790   :components ((:module "mod"
791                             :components ((:file "bar")
792                                                   (:file"baz")
793                                                   (:file "quux"))
794                             :perform (compile-op :after (op c)
795                                                   (do-something c))
796                             :explain (compile-op :after (op c)
797                                             (explain-something c)))
798                          (:file "blah")))
799 @end lisp
800
801 The @code{:module} component named @code{"mod"} is a collection of three files,
802 which will be located in a subdirectory of the main code directory named
803 @file{mod} (this location can be overridden; see the discussion of the
804 @code{:pathname} option in @ref{The defsystem grammar}).
805
806 The method-form tokens provide a shorthand for defining methods on
807 particular components.  This part
808
809 @lisp
810                 :perform (compile-op :after (op c)
811                           (do-something c))
812                 :explain (compile-op :after (op c)
813                           (explain-something c))
814 @end lisp
815
816 has the effect of
817
818 @lisp
819 (defmethod perform :after ((op compile-op) (c (eql ...)))
820            (do-something c))
821 (defmethod explain :after ((op compile-op) (c (eql ...)))
822            (explain-something c))
823 @end lisp
824
825 where @code{...} is the component in question.
826 In this case @code{...} would expand to something like
827
828 @lisp
829 (find-component (find-system "foo") "mod")
830 @end lisp
831
832 For more details on the syntax of such forms, see @ref{The defsystem
833 grammar}.
834 For more details on what these methods do, @pxref{Operations} in
835 @ref{The object model of ASDF}.
836
837 @c The following plunge into the weeds is not appropriate in this
838 @c location. [2010/10/03:rpg]
839 @c note that although this also supports @code{:before} methods,
840 @c they may not do what you want them to ---
841 @c a @code{:before} method on perform @code{((op compile-op) (c (eql ...)))}
842 @c will run after all the dependencies and sub-components have been processed,
843 @c but before the component in question has been compiled.
844
845 @node  The defsystem grammar, Other code in .asd files, A more involved example, Defining systems with defsystem
846 @comment  node-name,  next,  previous,  up
847 @section The defsystem grammar
848
849 @c FIXME: @var typesetting not consistently used here.  We should either expand
850 @c its use to everywhere, or we should kill it everywhere.
851
852
853 @example
854 system-definition := ( defsystem system-designator @var{system-option}* )
855
856 system-option := :defsystem-depends-on system-list
857                  | module-option
858                  | option
859
860 module-option := :components component-list
861                  | :serial [ t | nil ]
862                  | :if-component-dep-fails component-dep-fail-option
863
864 option :=
865         | :pathname pathname-specifier
866         | :default-component-class class-name
867         | :perform method-form
868         | :explain method-form
869         | :output-files method-form
870         | :operation-done-p method-form
871         | :depends-on ( @var{dependency-def}* )
872         | :in-order-to ( @var{dependency}+ )
873
874
875 system-list := ( @var{simple-component-name}* )
876
877 component-list := ( @var{component-def}* )
878
879 component-def  := ( component-type simple-component-name @var{option}* )
880
881 component-type := :system | :module | :file | :static-file | other-component-type
882
883 other-component-type := symbol-by-name (@pxref{The defsystem grammar,,Component types})
884
885 dependency-def := simple-component-name
886                | ( :feature name )
887                | ( :version simple-component-name version-specifier)
888
889 dependency := (dependent-op @var{requirement}+)
890 requirement := (required-op @var{required-component}+)
891              | (feature feature-name)
892 dependent-op := operation-name
893 required-op := operation-name | feature
894
895 simple-component-name := string
896                       |  symbol
897
898 pathname-specifier := pathname | string | symbol
899
900 method-form := (operation-name qual lambda-list @&rest body)
901 qual := method qualifier
902
903 component-dep-fail-option := :fail | :try-next | :ignore
904 @end example
905
906
907 @subsection Component names
908
909 Component names (@code{simple-component-name})
910 may be either strings or symbols.
911
912 @subsection Component types
913
914 Component type names, even if expressed as keywords, will be looked up
915 by name in the current package and in the asdf package, if not found in
916 the current package.  So a component type @code{my-component-type}, in
917 the current package @code{my-system-asd} can be specified as
918 @code{:my-component-type}, or @code{my-component-type}.
919
920 @subsection Defsystem depends on
921
922 The @code{:defsystem-depends-on} option to @code{defsystem} allows the
923 programmer to specify another ASDF-defined system or set of systems that
924 must be loaded @emph{before} the system definition is processed.
925 Typically this is used to load an ASDF extension that is used in the
926 system definition.
927
928 @subsection Pathname specifiers
929 @cindex pathname specifiers
930
931 A pathname specifier (@code{pathname-specifier})
932 may be a pathname, a string or a symbol.
933 When no pathname specifier is given for a component,
934 which is the usual case, the component name itself is used.
935
936 If a string is given, which is the usual case,
937 the string will be interpreted as a Unix-style pathname
938 where @code{/} characters will be interpreted as directory separators.
939 Usually, Unix-style relative pathnames are used
940 (i.e. not starting with @code{/}, as opposed to absolute pathnames);
941 they are relative to the path of the parent component.
942 Finally, depending on the @code{component-type},
943 the pathname may be interpreted as either a file or a directory,
944 and if it's a file,
945 a file type may be added corresponding to the @code{component-type},
946 or else it will be extracted from the string itself (if applicable).
947
948 For instance, the @code{component-type} @code{:module}
949 wants a directory pathname, and so a string @code{"foo/bar"}
950 will be interpreted as the pathname @file{#p"foo/bar/"}.
951 On the other hand, the @code{component-type} @code{:file}
952 wants a file of type @code{lisp}, and so a string @code{"foo/bar"}
953 will be interpreted as the pathname @file{#p"foo/bar.lisp"},
954 and a string @code{"foo/bar.quux"}
955 will be interpreted as the pathname @file{#p"foo/bar.quux.lisp"}.
956 Finally, the @code{component-type} @code{:static-file}
957 wants a file without specifying a type, and so a string @code{"foo/bar"}
958 will be interpreted as the pathname @file{#p"foo/bar"},
959 and a string @code{"foo/bar.quux"}
960 will be interpreted as the pathname @file{#p"foo/bar.quux"}.
961
962 ASDF does not interpret the string @code{".."} to designate the parent
963 directory.  This string will be passed through to the underlying
964 operating system for interpretation.  We @emph{believe} that this will
965 work on all platforms where ASDF is deployed, but do not guarantee this
966 behavior.  A pathname object with a relative directory component of
967 @code{:up} or @code{:back} is the only guaranteed way to specify a
968 parent directory.
969
970 If a symbol is given, it will be translated into a string,
971 and downcased in the process.
972 The downcasing of symbols is unconventional,
973 but was selected after some consideration.
974 Observations suggest that the type of systems we want to support
975 either have lowercase as customary case (Unix, Mac, windows)
976 or silently convert lowercase to uppercase (lpns),
977 so this makes more sense than attempting to use @code{:case :common}
978 as argument to @code{make-pathname},
979 which is reported not to work on some implementations.
980
981 Pathname objects may be given to override the path for a component.
982 Such objects are typically specified using reader macros such as @code{#p}
983 or @code{#.(make-pathname ...)}.
984 Note however, that @code{#p...} is a shorthand for @code{#.(parse-namestring ...)}
985 and that the behavior of @code{parse-namestring} is completely non-portable,
986 unless you are using Common Lisp @code{logical-pathname}s
987 (@pxref{The defsystem grammar,,Warning about logical pathnames}, below).
988 Pathnames made with @code{#.(make-pathname ...)}
989 can usually be done more easily with the string syntax above.
990 The only case that you really need a pathname object is to override
991 the component-type default file type for a given component.
992 Therefore, pathname objects should only rarely be used.
993 Unhappily, ASDF 1 didn't properly support
994 parsing component names as strings specifying paths with directories,
995 and the cumbersome @code{#.(make-pathname ...)} syntax had to be used.
996
997 Note that when specifying pathname objects,
998 ASDF does not do any special interpretation of the pathname
999 influenced by the component type, unlike the procedure for
1000 pathname-specifying strings.
1001 On the one hand, you have to be careful to provide a pathname that correctly
1002 fulfills whatever constraints are required from that component type
1003 (e.g. naming a directory or a file with appropriate type);
1004 on the other hand, you can circumvent the file type that would otherwise
1005 be forced upon you if you were specifying a string.
1006
1007 @subsection Version specifiers
1008 @cindex version specifiers
1009 @cindex :version
1010
1011 Version specifiers are parsed as period-separated lists of integers.  I.e., in the example,
1012 @code{0.2.1} is to be interpreted, roughly speaking, as @code{(0 2 1)}.
1013 In particular, version @code{0.2.1} is interpreted the same as
1014 @code{0.0002.1} and is strictly version-less-than version @code{0.20.1},
1015 even though the two are the same when interpreted as decimal fractions.
1016
1017 System definers are encouraged to use version identifiers of the form
1018 @var{x}.@var{y}.@var{z} for major version, minor version (compatible
1019 API) and patch level.
1020
1021 @xref{Common attributes of components}.
1022
1023
1024 @subsection Warning about logical pathnames
1025 @cindex logical pathnames
1026
1027 We recommend that you not use logical pathnames
1028 in your asdf system definitions at this point,
1029 but logical pathnames @emph{are} supported.
1030
1031 To use logical pathnames,
1032 you will have to provide a pathname object as a @code{:pathname} specifier
1033 to components that use it, using such syntax as
1034 @code{#p"LOGICAL-HOST:absolute;path;to;component.lisp"}.
1035
1036 You only have to specify such logical pathname for your system or
1037 some top-level component.  Sub-components' relative pathnames, specified
1038 using the string syntax
1039 for names, will be properly merged with the pathnames of their parents.
1040 The specification of a logical pathname host however is @emph{not}
1041 otherwise directly supported in the ASDF syntax
1042 for pathname specifiers as strings.
1043
1044 The @code{asdf-output-translation} layer will
1045 avoid trying to resolve and translate logical-pathnames.
1046 The advantage of this is that you can define yourself what translations you want to use
1047 with the logical pathname facility.
1048 The disadvantage is that if you do not define such translations, any
1049 system that uses logical pathnames will behave differently under
1050 asdf-output-translations than other systems you use.
1051
1052 If you wish to use logical pathnames you will have to configure the
1053 translations yourself before they may be used.
1054 ASDF currently provides no specific support
1055 for defining logical pathname translations.
1056
1057
1058 @subsection Serial dependencies
1059 @cindex serial dependencies
1060
1061 If the @code{:serial t} option is specified for a module,
1062 ASDF will add dependencies for each child component,
1063 on all the children textually preceding it.
1064 This is done as if by @code{:depends-on}.
1065
1066 @lisp
1067 :serial t
1068 :components ((:file "a") (:file "b") (:file "c"))
1069 @end lisp
1070
1071 is equivalent to
1072
1073 @lisp
1074 :components ((:file "a")
1075              (:file "b" :depends-on ("a"))
1076              (:file "c" :depends-on ("a" "b")))
1077 @end lisp
1078
1079
1080 @subsection Source location
1081
1082 The @code{:pathname} option is optional in all cases for systems
1083 defined via @code{defsystem},
1084 and in the usual case the user is recommended not to supply it.
1085
1086 Instead, ASDF follows a hairy set of rules that are designed so that
1087 @enumerate
1088 @item
1089 @code{find-system}
1090 will load a system from disk
1091 and have its pathname default to the right place.
1092 @item
1093 This pathname information will not be overwritten with
1094 @code{*default-pathname-defaults*}
1095 (which could be somewhere else altogether)
1096 if the user loads up the @file{.asd} file into his editor
1097 and interactively re-evaluates that form.
1098 @end enumerate
1099
1100 If a system is being loaded for the first time,
1101 its top-level pathname will be set to:
1102
1103 @itemize
1104 @item
1105 The host/device/directory parts of @code{*load-truename*},
1106 if it is bound.
1107 @item
1108 @code{*default-pathname-defaults*}, otherwise.
1109 @end itemize
1110
1111 If a system is being redefined, the top-level pathname will be
1112
1113 @itemize
1114 @item
1115 changed, if explicitly supplied or obtained from @code{*load-truename*}
1116 (so that an updated source location is reflected in the system definition)
1117 @item
1118 changed if it had previously been set from @code{*default-pathname-defaults*}
1119 @item
1120 left as before, if it had previously been set from @code{*load-truename*}
1121 and @code{*load-truename*} is currently unbound
1122 (so that a developer can evaluate a @code{defsystem} form
1123 from within an editor without clobbering its source location)
1124 @end itemize
1125
1126 @subsection if-component-dep-fails option
1127
1128 This option is only appropriate for module components (including
1129 systems), not individual source files.
1130
1131 For more information about this option, @pxref{Pre-defined subclasses of component}.
1132
1133 @node Other code in .asd files,  , The defsystem grammar, Defining systems with defsystem
1134 @section Other code in .asd files
1135
1136 Files containing @code{defsystem} forms
1137 are regular Lisp files that are executed by @code{load}.
1138 Consequently, you can put whatever Lisp code you like into these files
1139 (e.g., code that examines the compile-time environment
1140 and adds appropriate features to @code{*features*}).
1141 However, some conventions should be followed,
1142 so that users can control certain details of execution
1143 of the Lisp in @file{.asd} files:
1144
1145 @itemize
1146 @item
1147 Any informative output
1148 (other than warnings and errors,
1149 which are the condition system's to dispose of)
1150 should be sent to the standard CL stream @code{*standard-output*},
1151 so that users can easily control the disposition
1152 of output from ASDF operations.
1153 @end itemize
1154
1155
1156 @node The object model of ASDF, Controlling where ASDF searches for systems, Defining systems with defsystem, Top
1157 @comment  node-name,  next,  previous,  up
1158 @chapter The object model of ASDF
1159
1160 ASDF is designed in an object-oriented way from the ground up.
1161 Both a system's structure and the operations that can be performed on systems
1162 follow a protocol.
1163 ASDF is extensible to new operations and to new component types.
1164 This allows the addition of behaviours:
1165 for example, a new component could be added for Java JAR archives,
1166 and methods specialised on @code{compile-op} added for it
1167 that would accomplish the relevant actions.
1168
1169 This chapter deals with @emph{components}, the building blocks of a system,
1170 and @emph{operations}, the actions that can be performed on a system.
1171
1172
1173
1174 @menu
1175 * Operations::
1176 * Components::
1177 @end menu
1178
1179 @node  Operations, Components, The object model of ASDF, The object model of ASDF
1180 @comment  node-name,  next,  previous,  up
1181 @section Operations
1182 @cindex operation
1183
1184 An @dfn{operation} object of the appropriate type is instantiated
1185 whenever the user wants to do something with a system like
1186
1187 @itemize
1188 @item compile all its files
1189 @item load the files into a running lisp environment
1190 @item copy its source files somewhere else
1191 @end itemize
1192
1193 Operations can be invoked directly, or examined
1194 to see what their effects would be without performing them.
1195 @emph{FIXME: document how!}
1196 There are a bunch of methods specialised on operation and component type
1197 that actually do the grunt work.
1198
1199 The operation object contains whatever state is relevant for this purpose
1200 (perhaps a list of visited nodes, for example)
1201 but primarily is a nice thing to specialise operation methods on
1202 and easier than having them all be @code{EQL} methods.
1203
1204 Operations are invoked on systems via @code{operate}.
1205 @anchor{operate}
1206 @deffn {Generic function} @code{operate} @var{operation} @var{system} @&rest @var{initargs}
1207 @deffnx {Generic function} @code{oos} @var{operation} @var{system} @&rest @var{initargs}
1208 @code{operate} invokes @var{operation} on @var{system}.
1209 @code{oos} is a synonym for @code{operate}.
1210
1211 @var{operation} is a symbol that is passed, along with the supplied
1212 @var{initargs}, to @code{make-instance} to create the operation object.
1213 @var{system} is a system designator.
1214
1215 The @var{initargs} are passed to the @code{make-instance} call
1216 when creating the operation object.
1217 Note that dependencies may cause the operation
1218 to invoke other operations on the system or its components:
1219 the new operations will be created
1220 with the same @var{initargs} as the original one.
1221
1222 @end deffn
1223
1224 @menu
1225 * Predefined operations of ASDF::
1226 * Creating new operations::
1227 @end menu
1228
1229 @node Predefined operations of ASDF, Creating new operations, Operations, Operations
1230 @comment  node-name,  next,  previous,  up
1231 @subsection Predefined operations of ASDF
1232
1233 All the operations described in this section are in the @code{asdf} package.
1234 They are invoked via the @code{operate} generic function.
1235
1236 @lisp
1237 (asdf:operate 'asdf:@var{operation-name} :@var{system-name} @{@var{operation-options ...}@})
1238 @end lisp
1239
1240 @deffn Operation @code{compile-op} @&key @code{proclamations}
1241
1242 This operation compiles the specified component.
1243 If proclamations are supplied, they will be proclaimed.
1244 This is a good place to specify optimization settings.
1245
1246 When creating a new component type,
1247 you should provide methods for @code{compile-op}.
1248
1249 When @code{compile-op} is invoked,
1250 component dependencies often cause some parts of the system
1251 to be loaded as well as compiled.
1252 Invoking @code{compile-op}
1253 does not necessarily load all the parts of the system, though;
1254 use @code{load-op} to load a system.
1255 @end deffn
1256
1257 @deffn Operation @code{load-op} @&key @code{proclamations}
1258
1259 This operation loads a system.
1260
1261 The default methods for @code{load-op} compile files before loading them.
1262 For parity, your own methods on new component types should probably do so too.
1263 @end deffn
1264
1265 @deffn Operation @code{load-source-op}
1266
1267 This operation will load the source for the files in a module
1268 even if the source files have been compiled.
1269 Systems sometimes have knotty dependencies
1270 which require that sources are loaded
1271 before they can be compiled.
1272 This is how you do that.
1273
1274 If you are creating a component type,
1275 you need to implement this operation --- at least, where meaningful.
1276 @end deffn
1277
1278 @anchor{test-op}
1279 @deffn Operation @code{test-op}
1280
1281 This operation will perform some tests on the module.
1282 The default method will do nothing.
1283 The default dependency is to require
1284 @code{load-op} to be performed on the module first.
1285 The default @code{operation-done-p} is that the operation is @emph{never} done
1286 ---
1287 we assume that if you invoke the @code{test-op},
1288 you want to test the system, even if you have already done so.
1289
1290 The results of this operation are not defined by ASDF.
1291 It has proven difficult to define how the test operation
1292 should signal its results to the user
1293 in a way that is compatible with all of the various test libraries
1294 and test techniques in use in the community.
1295 @end deffn
1296
1297 @c @deffn Operation test-system-version @&key minimum
1298
1299 @c Asks the system whether it satisfies a version requirement.
1300
1301 @c The default method accepts a string, which is expected to contain of a
1302 @c number of integers separated by #\. characters.  The method is not
1303 @c recursive.  The component satisfies the version dependency if it has
1304 @c the same major number as required and each of its sub-versions is
1305 @c greater than or equal to the sub-version number required.
1306
1307 @c @lisp
1308 @c (defun version-satisfies (x y)
1309 @c   (labels ((bigger (x y)
1310 @c           (cond ((not y) t)
1311 @c                 ((not x) nil)
1312 @c                 ((> (car x) (car y)) t)
1313 @c                 ((= (car x) (car y))
1314 @c                  (bigger (cdr x) (cdr y))))))
1315 @c     (and (= (car x) (car y))
1316 @c       (or (not (cdr y)) (bigger (cdr x) (cdr y))))))
1317 @c @end lisp
1318
1319 @c If that doesn't work for your system, you can override it.  I hope
1320 @c you have as much fun writing the new method as @verb{|#lisp|} did
1321 @c reimplementing this one.
1322 @c @end deffn
1323
1324 @c @deffn Operation feature-dependent-op
1325
1326 @c An instance of @code{feature-dependent-op} will ignore any components
1327 @c which have a @code{features} attribute, unless the feature combination
1328 @c it designates is satisfied by @code{*features*}.  This operation is
1329 @c not intended to be instantiated directly, but other operations may
1330 @c inherit from it.
1331
1332 @c @end deffn
1333
1334 @node  Creating new operations,  , Predefined operations of ASDF, Operations
1335 @comment  node-name,  next,  previous,  up
1336 @subsection Creating new operations
1337
1338 ASDF was designed to be extensible in an object-oriented fashion.
1339 To teach ASDF new tricks, a programmer can implement the behaviour he wants
1340 by creating a subclass of @code{operation}.
1341
1342 ASDF's pre-defined operations are in no way ``privileged'',
1343 but it is requested that developers never use the @code{asdf} package
1344 for operations they develop themselves.
1345 The rationale for this rule is that we don't want to establish a
1346 ``global asdf operation name registry'',
1347 but also want to avoid name clashes.
1348
1349 An operation must provide methods for the following generic functions
1350 when invoked with an object of type @code{source-file}:
1351 @emph{FIXME describe this better}
1352
1353 @itemize
1354
1355 @item @code{output-files}
1356 The @code{output-files} method determines where the method will put its files.
1357 It returns two values, a list of pathnames, and a boolean.
1358 If the boolean is @code{T} then the pathnames are marked
1359 not be translated by enclosing @code{:around} methods.
1360 If the boolean is @code{NIL} then enclosing @code{:around} methods
1361 may translate these pathnames, e.g. to ensure object files
1362 are somehow stored in some implementation-dependent cache.
1363 @item @code{perform}
1364 The @code{perform} method must call @code{output-files}
1365 to find out where to put its files,
1366 because the user is allowed to override.
1367 @item @code{output-files}
1368 for local policy @code{explain}
1369 @item @code{operation-done-p},
1370 if you don't like the default one
1371
1372 @end itemize
1373
1374 Operations that print output should send that output to the standard
1375 CL stream @code{*standard-output*}, as the Lisp compiler and loader do.
1376
1377 @node Components,  , Operations, The object model of ASDF
1378 @comment  node-name,  next,  previous,  up
1379 @section Components
1380 @cindex component
1381 @cindex system
1382 @cindex system designator
1383 @vindex *system-definition-search-functions*
1384
1385 A @dfn{component} represents a source file or
1386 (recursively) a collection of components.
1387 A @dfn{system} is (roughly speaking) a top-level component
1388 that can be found via @code{find-system}.
1389
1390 A @dfn{system designator} is a string or symbol
1391 and behaves just like any other component name
1392 (including with regard to the case conversion rules for component names).
1393
1394
1395 @defun find-system system-designator &optional (error-p t)
1396
1397 Given a system designator, @code{find-system} finds and returns a system.
1398 If no system is found, an error of type
1399 @code{missing-component} is thrown,
1400 or @code{nil} is returned if @code{error-p} is false.
1401
1402 To find and update systems, @code{find-system} funcalls each element
1403 in the @code{*system-definition-search-functions*} list,
1404 expecting a pathname to be returned, or a system object,
1405 from which a pathname may be extracted, and that will be registered.
1406 The resulting pathname (if any) is loaded
1407 if one of the following conditions is true:
1408
1409 @itemize
1410 @item
1411 there is no system of that name in memory
1412 @item
1413 the pathname is different from that which was previously loaded
1414 @item
1415 the file's @code{last-modified} time exceeds the @code{last-modified} time
1416 of the system in memory
1417 @end itemize
1418
1419 When system definitions are loaded from @file{.asd} files,
1420 a new scratch package is created for them to load into,
1421 so that different systems do not overwrite each others operations.
1422 The user may also wish to (and is recommended to)
1423 include @code{defpackage} and @code{in-package} forms
1424 in his system definition files, however,
1425 so that they can be loaded manually if need be.
1426
1427 The default value of @code{*system-definition-search-functions*}
1428 is a list of two functions.
1429 The first function looks in each of the directories given
1430 by evaluating members of @code{*central-registry*}
1431 for a file whose name is the name of the system and whose type is @file{asd}.
1432 The first such file is returned,
1433 whether or not it turns out to actually define the appropriate system.
1434 The second function does something similar,
1435 for the directories specified in the @code{source-registry}.
1436 Hence, it is strongly advised to define a system
1437 @var{foo} in the corresponding file @var{foo.asd}.
1438 @end defun
1439
1440
1441 @menu
1442 * Common attributes of components::
1443 * Pre-defined subclasses of component::
1444 * Creating new component types::
1445 @end menu
1446
1447 @node  Common attributes of components, Pre-defined subclasses of component, Components, Components
1448 @comment  node-name,  next,  previous,  up
1449 @subsection Common attributes of components
1450
1451 All components, regardless of type, have the following attributes.
1452 All attributes except @code{name} are optional.
1453
1454 @subsubsection Name
1455
1456 A component name is a string or a symbol.
1457 If a symbol, its name is taken and lowercased.
1458
1459 Unless overridden by a @code{:pathname} attribute,
1460 the name will be interpreted as a pathname specifier according
1461 to a Unix-style syntax.
1462 @xref{The defsystem grammar,,Pathname specifiers}.
1463
1464 @subsubsection Version identifier
1465 @findex version-satisfies
1466 @cindex :version
1467
1468 This optional attribute is used by the generic function
1469 @code{version-satisfies}, which tests to see if @code{:version}
1470 dependencies are satisfied.
1471 the version should be a string of integers separated by dots,
1472 for example @samp{1.0.11}.
1473 For more information on the semantics of version specifiers, see @ref{The defsystem grammar}.
1474
1475 @c This optional attribute is intended to be used by the @code{test-system-version} operation.
1476 @c @xref{Predefined operations of ASDF}.
1477 @c @emph{Nota Bene}:
1478 @c This operation, planned for ASDF 1,
1479 @c is still not implemented yet as of ASDF 2.
1480 @c Don't hold your breath.
1481
1482
1483
1484 @subsubsection Required features
1485
1486 @emph{FIXME: This subsection seems to contradict the
1487 @code{defsystem} grammar subsection,
1488 which doesn't provide any obvious way to specify required features.
1489 Furthermore, in 2009, discussions on the
1490 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
1491 suggested that the specification of required features may be broken,
1492 and that no one may have been using them for a while.
1493 Please contact the
1494 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
1495 if you are interested in getting this features feature fixed.}
1496
1497 Traditionally defsystem users have used reader conditionals
1498 to include or exclude specific per-implementation files.
1499 This means that any single implementation cannot read the entire system,
1500 which becomes a problem if it doesn't wish to compile it,
1501 but instead for example to create an archive file containing all the sources,
1502 as it will omit to process the system-dependent sources for other systems.
1503
1504 Each component in an asdf system may therefore specify features using
1505 the same syntax as @code{#+} does, and it will (somehow) be ignored for
1506 certain operations unless the feature conditional is a member of
1507 @code{*features*}.
1508
1509
1510 @subsubsection Dependencies
1511
1512 This attribute specifies dependencies of the component on its siblings.
1513 It is optional but often necessary.
1514
1515 There is an excitingly complicated relationship between the initarg
1516 and the method that you use to ask about dependencies
1517
1518 Dependencies are between (operation component) pairs.
1519 In your initargs for the component, you can say
1520
1521 @lisp
1522 :in-order-to ((compile-op (load-op "a" "b") (compile-op "c"))
1523               (load-op (load-op "foo")))
1524 @end lisp
1525
1526 This means the following things:
1527 @itemize
1528 @item
1529 before performing compile-op on this component, we must perform
1530 load-op on @var{a} and @var{b}, and compile-op on @var{c},
1531 @item
1532 before performing @code{load-op}, we have to load @var{foo}
1533 @end itemize
1534
1535 The syntax is approximately
1536
1537 @verbatim
1538 (this-op {(other-op required-components)}+)
1539
1540 required-components := component-name
1541                      | (required-components required-components)
1542
1543 component-name := string
1544                 | (:version string minimum-version-object)
1545 @end verbatim
1546
1547 Side note:
1548
1549 This is on a par with what ACL defsystem does.
1550 mk-defsystem is less general: it has an implied dependency
1551
1552 @verbatim
1553   for all x, (load x) depends on (compile x)
1554 @end verbatim
1555
1556 and using a @code{:depends-on} argument to say that @var{b} depends on
1557 @var{a} @emph{actually} means that
1558
1559 @verbatim
1560   (compile b) depends on (load a)
1561 @end verbatim
1562
1563 This is insufficient for e.g. the McCLIM system, which requires that
1564 all the files are loaded before any of them can be compiled ]
1565
1566 End side note
1567
1568 In ASDF, the dependency information for a given component and operation
1569 can be queried using @code{(component-depends-on operation component)},
1570 which returns a list
1571
1572 @lisp
1573 ((load-op "a") (load-op "b") (compile-op "c") ...)
1574 @end lisp
1575
1576 @code{component-depends-on} can be subclassed for more specific
1577 component/operation types: these need to @code{(call-next-method)}
1578 and append the answer to their dependency, unless
1579 they have a good reason for completely overriding the default dependencies.
1580
1581 If it weren't for CLISP, we'd be using @code{LIST} method
1582 combination to do this transparently.
1583 But, we need to support CLISP.
1584 If you have the time for some CLISP hacking,
1585 I'm sure they'd welcome your fixes.
1586 @c Doesn't CLISP now support LIST method combination?
1587
1588 See the discussion of the semantics of @code{:version} in the defsystem
1589 grammar.
1590
1591 @c FIXME: Should have cross-reference to "Version specifiers" in the
1592 @c defsystem grammar, but the cross-referencing is so broken by
1593 @c insufficient node breakdown that I have not put one in.
1594
1595
1596 @subsubsection pathname
1597
1598 This attribute is optional and if absent (which is the usual case),
1599 the component name will be used.
1600
1601 @xref{The defsystem grammar,,Pathname specifiers},
1602 for an explanation of how this attribute is interpreted.
1603
1604 Note that the @code{defsystem} macro (used to create a ``top-level'' system)
1605 does additional processing to set the filesystem location of
1606 the top component in that system.
1607 This is detailed elsewhere. @xref{Defining systems with defsystem}.
1608
1609
1610 @subsubsection properties
1611
1612 This attribute is optional.
1613
1614 Packaging systems often require information about files or systems
1615 in addition to that specified by ASDF's pre-defined component attributes.
1616 Programs that create vendor packages out of ASDF systems therefore
1617 have to create ``placeholder'' information to satisfy these systems.
1618 Sometimes the creator of an ASDF system may know the additional
1619 information and wish to provide it directly.
1620
1621 @code{(component-property component property-name)} and
1622 associated @code{setf} method will allow
1623 the programmatic update of this information.
1624 Property names are compared as if by @code{EQL},
1625 so use symbols or keywords or something.
1626
1627 @menu
1628 * Pre-defined subclasses of component::
1629 * Creating new component types::
1630 @end menu
1631
1632 @node Pre-defined subclasses of component, Creating new component types, Common attributes of components, Components
1633 @comment  node-name,  next,  previous,  up
1634 @subsection Pre-defined subclasses of component
1635
1636 @deffn Component source-file
1637
1638 A source file is any file that the system does not know how to
1639 generate from other components of the system.
1640
1641 Note that this is not necessarily the same thing as
1642 ``a file containing data that is typically fed to a compiler''.
1643 If a file is generated by some pre-processor stage
1644 (e.g. a @file{.h} file from @file{.h.in} by autoconf)
1645 then it is not, by this definition, a source file.
1646 Conversely, we might have a graphic file
1647 that cannot be automatically regenerated,
1648 or a proprietary shared library that we received as a binary:
1649 these do count as source files for our purposes.
1650
1651 Subclasses of source-file exist for various languages.
1652 @emph{FIXME: describe these.}
1653 @end deffn
1654
1655 @deffn Component module
1656
1657 A module is a collection of sub-components.
1658
1659 A module component has the following extra initargs:
1660
1661 @itemize
1662 @item
1663 @code{:components} the components contained in this module
1664
1665 @item
1666 @code{:default-component-class}
1667 All children components which don't specify their class explicitly
1668 are inferred to be of this type.
1669
1670 @item
1671 @code{:if-component-dep-fails}
1672 This attribute takes one of the values
1673 @code{:fail}, @code{:try-next}, @code{:ignore},
1674 its default value is @code{:fail}.
1675 The other values can be used for implementing conditional compilation
1676 based on implementation @code{*features*},
1677 for the case where it is not necessary for all files in a module to be
1678 compiled.
1679 @emph{FIXME: such conditional compilation has been reported
1680 to be broken in 2009.}
1681
1682 @item
1683 @code{:serial} When this attribute is set,
1684 each subcomponent of this component is assumed to depend on all subcomponents
1685 before it in the list given to @code{:components}, i.e.
1686 all of them are loaded before a compile or load operation is performed on it.
1687
1688 @end itemize
1689
1690 The default operation knows how to traverse a module, so
1691 most operations will not need to provide methods specialised on modules.
1692
1693 @code{module} may be subclassed to represent components such as
1694 foreign-language linked libraries or archive files.
1695 @end deffn
1696
1697 @deffn Component system
1698
1699 @code{system} is a subclass of @code{module}.
1700
1701 A system is a module with a few extra attributes for documentation
1702 purposes; these are given elsewhere.
1703 @xref{The defsystem grammar}.
1704
1705 Users can create new classes for their systems:
1706 the default @code{defsystem} macro takes a @code{:class} keyword argument.
1707 @end deffn
1708
1709 @node  Creating new component types,  , Pre-defined subclasses of component, Components
1710 @comment  node-name,  next,  previous,  up
1711 @subsection Creating new component types
1712
1713 New component types are defined by subclassing one of the existing
1714 component classes and specializing methods on the new component class.
1715
1716 @emph{FIXME: this should perhaps be explained more throughly,
1717 not only by example ...}
1718
1719 As an example, suppose we have some implementation-dependent
1720 functionality that we want to isolate
1721 in one subdirectory per Lisp implementation our system supports.
1722 We create a subclass of
1723 @code{cl-source-file}:
1724
1725 @lisp
1726 (defclass unportable-cl-source-file (cl-source-file)
1727   ())
1728 @end lisp
1729
1730 Function @code{asdf:implementation-type} (exported since 2.014.14)
1731 gives us the name of the subdirectory.
1732 All that's left is to define how to calculate the pathname
1733 of an @code{unportable-cl-source-file}.
1734
1735 @lisp
1736 (defmethod component-pathname ((component unportable-cl-source-file))
1737   (merge-pathnames*
1738    (coerce-pathname (format nil "~(~A~)/" (asdf:implementation-type)))
1739    (call-next-method)))
1740 @end lisp
1741
1742 The new component type is used in a @code{defsystem} form in this way:
1743
1744 @lisp
1745 (defsystem :foo
1746     :components
1747     ((:file "packages")
1748      ...
1749      (:unportable-cl-source-file "threads"
1750       :depends-on ("packages" ...))
1751      ...
1752     )
1753 @end lisp
1754
1755 @node Controlling where ASDF searches for systems, Controlling where ASDF saves compiled files, The object model of ASDF, Top
1756 @comment  node-name,  next,  previous,  up
1757 @chapter Controlling where ASDF searches for systems
1758
1759 @section Configurations
1760
1761 Configurations specify paths where to find system files.
1762
1763 @enumerate
1764
1765 @item
1766 The search registry may use some hardcoded wrapping registry specification.
1767 This allows some implementations (notably SBCL) to specify where to find
1768 some special implementation-provided systems that
1769 need to precisely match the version of the implementation itself.
1770
1771 @item
1772 An application may explicitly initialize the source-registry configuration
1773 using the configuration API
1774 (@pxref{Controlling where ASDF searches for systems,Configuration API,Configuration API}, below)
1775 in which case this takes precedence.
1776 It may itself compute this configuration from the command-line,
1777 from a script, from its own configuration file, etc.
1778
1779 @item
1780 The source registry will be configured from
1781 the environment variable @code{CL_SOURCE_REGISTRY} if it exists.
1782
1783 @item
1784 The source registry will be configured from
1785 user configuration file
1786 @file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf}
1787 (which defaults to
1788 @file{~/.config/common-lisp/source-registry.conf})
1789 if it exists.
1790
1791 @item
1792 The source registry will be configured from
1793 user configuration directory
1794 @file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf.d/}
1795 (which defaults to
1796 @file{~/.config/common-lisp/source-registry.conf.d/})
1797 if it exists.
1798
1799 @item
1800 The source registry will be configured from
1801 system configuration file
1802 @file{/etc/common-lisp/source-registry.conf}
1803 if it exists/
1804
1805 @item
1806 The source registry will be configured from
1807 system configuration directory
1808 @file{/etc/common-lisp/source-registry.conf.d/}
1809 if it exists.
1810
1811 @item
1812 The source registry will be configured from a default configuration.
1813 This configuration may allow for implementation-specific systems
1814 to be found, for systems to be found the current directory
1815 (at the time that the configuration is initialized) as well as
1816 @code{:directory} entries for @file{$XDG_DATA_DIRS/common-lisp/systems/} and
1817 @code{:tree} entries for @file{$XDG_DATA_DIRS/common-lisp/source/}.
1818 For instance, SBCL will include directories for its contribs
1819 when it can find them; it will look for them where SBCL was installed,
1820 or at the location specified by the @code{SBCL_HOME} environment variable.
1821
1822 @end enumerate
1823
1824 Each of these configurations is specified as an s-expression
1825 in a trivial domain-specific language (defined below).
1826 Additionally, a more shell-friendly syntax is available
1827 for the environment variable (defined yet below).
1828
1829 Each of these configurations is only used if the previous
1830 configuration explicitly or implicitly specifies that it
1831 includes its inherited configuration.
1832
1833 Additionally, some implementation-specific directories
1834 may be automatically prepended to whatever directories are specified
1835 in configuration files, no matter if the last one inherits or not.
1836
1837 @section XDG base directory
1838
1839 Note that we purport to respect the XDG base directory specification
1840 as to where configuration files are located,
1841 where data files are located,
1842 where output file caches are located.
1843 Mentions of XDG variables refer to that document.
1844
1845 @url{http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html}
1846
1847 This specification allows the user to specify some environment variables
1848 to customize how applications behave to his preferences.
1849
1850 On Windows platforms, when not using Cygwin,
1851 instead of the XDG base directory specification,
1852 we try to use folder configuration from the registry regarding
1853 @code{Common AppData} and similar directories.
1854 However, support for querying the Windows registry is limited as of ASDF 2,
1855 and on many implementations, we may fall back to always using the defaults
1856 without consulting the registry.
1857 Patches welcome.
1858
1859 @section Backward Compatibility
1860
1861 For backward compatibility as well as to provide a practical backdoor for hackers,
1862 ASDF will first search for @code{.asd} files in the directories specified in
1863 @code{asdf:*central-registry*}
1864 before it searches in the source registry above.
1865
1866 @xref{Configuring ASDF,,Configuring ASDF to find your systems -- old style}.
1867
1868 By default, @code{asdf:*central-registry*} will be empty.
1869
1870 This old mechanism will therefore not affect you if you don't use it,
1871 but will take precedence over the new mechanism if you do use it.
1872
1873 @section Configuration DSL
1874
1875 Here is the grammar of the s-expression (SEXP) DSL for source-registry
1876 configuration:
1877
1878 @c FIXME: This is too wide for happy compilation into pdf.
1879
1880 @example
1881 ;; A configuration is a single SEXP starting with keyword :source-registry
1882 ;; followed by a list of directives.
1883 CONFIGURATION := (:source-registry DIRECTIVE ...)
1884
1885 ;; A directive is one of the following:
1886 DIRECTIVE :=
1887     ;; INHERITANCE DIRECTIVE:
1888     ;; Your configuration expression MUST contain
1889     ;; exactly one of either of these:
1890     :inherit-configuration | ; splices inherited configuration (often specified last)
1891     :ignore-inherited-configuration | ; drop inherited configuration (specified anywhere)
1892
1893     ;; forward compatibility directive (since ASDF 2.011.4), useful when
1894     ;; you want to use new configuration features but have to bootstrap a
1895     ;; the newer required ASDF from an older release that doesn't sport said features:
1896     :ignore-invalid-entries | ; drops subsequent invalid entries instead of erroring out
1897
1898     ;; add a single directory to be scanned (no recursion)
1899     (:directory DIRECTORY-PATHNAME-DESIGNATOR) |
1900
1901     ;; add a directory hierarchy, recursing but excluding specified patterns
1902     (:tree DIRECTORY-PATHNAME-DESIGNATOR) |
1903
1904     ;; override the defaults for exclusion patterns
1905     (:exclude PATTERN ...) |
1906     ;; augment the defaults for exclusion patterns
1907     (:also-exclude PATTERN ...) |
1908     ;; Note that the scope of a an exclude pattern specification is
1909     ;; the rest of the current configuration expression or file.
1910
1911     ;; splice the parsed contents of another config file
1912     (:include REGULAR-FILE-PATHNAME-DESIGNATOR) |
1913
1914     ;; This directive specifies that some default must be spliced.
1915     :default-registry
1916
1917 REGULAR-FILE-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a file
1918 DIRECTORY-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a directory name
1919
1920 PATHNAME-DESIGNATOR :=
1921     NULL | ;; Special: skip this entry.
1922     ABSOLUTE-COMPONENT-DESIGNATOR |
1923     (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...)
1924
1925 ABSOLUTE-COMPONENT-DESIGNATOR :=
1926     STRING | ;; namestring (better be absolute or bust, directory assumed where applicable)
1927     PATHNAME | ;; pathname (better be an absolute path, or bust)
1928     :HOME | ;; designates the user-homedir-pathname ~/
1929     :USER-CACHE | ;; designates the default location for the user cache
1930     :SYSTEM-CACHE | ;; designates the default location for the system cache
1931     :HERE  ;; designates the location of the configuration file
1932            ;; (or *default-pathname-defaults*, if invoked interactively)
1933
1934 RELATIVE-COMPONENT-DESIGNATOR :=
1935     STRING | ;; namestring (directory assumed where applicable)
1936     PATHNAME | ;; pathname
1937     :IMPLEMENTATION | ;; a directory based on implementation, e.g. sbcl-1.0.45-linux-amd64
1938     :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl
1939     :UID | ;; current UID -- not available on Windows
1940     :USER ;; current USER name -- NOT IMPLEMENTED(!)
1941
1942 PATTERN := a string without wildcards, that will be matched exactly
1943         against the name of a any subdirectory in the directory component
1944         of a path. e.g. @code{"_darcs"} will match @file{#p"/foo/bar/_darcs/src/bar.asd"}
1945 @end example
1946
1947 For instance, as a simple case, my @file{~/.config/common-lisp/source-registry.conf},
1948 which is the default place ASDF looks for this configuration,
1949 once contained:
1950 @example
1951 (:source-registry
1952   (:tree (:home "cl")) ;; will expand to e.g. "/home/joeluser/cl/"
1953   :inherit-configuration)
1954 @end example
1955
1956 @section Configuration Directories
1957
1958 Configuration directories consist in files each containing
1959 a list of directives without any enclosing @code{(:source-registry ...)} form.
1960 The files will be sorted by namestring as if by @code{string<} and
1961 the lists of directives of these files with be concatenated in order.
1962 An implicit @code{:inherit-configuration} will be included
1963 at the @emph{end} of the list.
1964
1965 This allows for packaging software that has file granularity
1966 (e.g. Debian's @code{dpkg} or some future version of @code{clbuild})
1967 to easily include configuration information about distributed software.
1968
1969 The convention is that, for sorting purposes,
1970 the names of files in such a directory begin with two digits
1971 that determine the order in which these entries will be read.
1972 Also, the type of these files is conventionally @code{"conf"}
1973 and as a limitation to some implementations (e.g. GNU clisp),
1974 the type cannot be @code{NIL}.
1975
1976 Directories may be included by specifying a directory pathname
1977 or namestring in an @code{:include} directive, e.g.:
1978
1979 @example
1980         (:include "/foo/bar/")
1981 @end example
1982
1983 Hence, to achieve the same effect as
1984 my example @file{~/.config/common-lisp/source-registry.conf} above,
1985 I could simply create a file
1986 @file{~/.config/common-lisp/source-registry.conf.d/33-home-fare-cl.conf}
1987 alone in its directory with the following contents:
1988 @example
1989 (:tree "/home/fare/cl/")
1990 @end example
1991
1992 @subsection The :here directive
1993
1994 The @code{:here} directive is an absolute pathname designator that
1995 refers to the directory containing the configuration file currently
1996 being processed.
1997
1998 The @code{:here} directive is intended to simplify the delivery of
1999 complex CL systems, and for easy configuration of projects shared through
2000 revision control systems, in accordance with our design principle that
2001 each participant should be able to provide all and only the information
2002 available to him or her.
2003
2004 Consider a person X who has set up the source code repository for a
2005 complex project with a master directory @file{dir/}.  Ordinarily, one
2006 might simply have the user add a directive that would look something
2007 like this:
2008 @example
2009    (:tree  "path/to/dir")
2010 @end example
2011 But what if X knows that there are very large subtrees
2012 under dir that are filled with, e.g., Java source code, image files for
2013 icons, etc.?  All of the asdf system definitions are contained in the
2014 subdirectories @file{dir/src/lisp/} and @file{dir/extlib/lisp/}, and
2015 these are the only directories that should be searched.
2016
2017 In this case, X can put into @file{dir/} a file @file{asdf.conf} that
2018 contains the following:
2019 @example
2020 (:source-registry
2021    (:tree (:here "src/lisp/"))
2022    (:tree (:here "extlib/lisp"))
2023    (:directory (:here "outlier/")))
2024 @end example
2025
2026 Then when someone else (call her Y) checks out a copy of this
2027 repository, she need only add
2028 @example
2029 (:include "/path/to/my/checkout/directory/asdf.conf")
2030 @end example
2031 to one of her previously-existing asdf source location configuration
2032 files, or invoke @code{initialize-source-registry} with a configuration
2033 form containing that s-expression.  ASDF will find the .conf file that X
2034 has provided, and then set up source locations within the working
2035 directory according to X's (relative) instructions.
2036
2037 @section Shell-friendly syntax for configuration
2038
2039 When considering environment variable @code{CL_SOURCE_REGISTRY}
2040 ASDF will skip to next configuration if it's an empty string.
2041 It will @code{READ} the string as a SEXP in the DSL
2042 if it begins with a paren @code{(}
2043 and it will be interpreted much like @code{TEXINPUTS}
2044 list of paths, where
2045
2046   * paths are separated
2047    by a @code{:} (colon) on Unix platforms (including cygwin),
2048    by a @code{;} (semicolon) on other platforms (mainly, Windows).
2049
2050   * each entry is a directory to add to the search path.
2051
2052   * if the entry ends with a double slash @code{//}
2053     then it instead indicates a tree in the subdirectories
2054     of which to recurse.
2055
2056   * if the entry is the empty string (which may only appear once),
2057     then it indicates that the inherited configuration should be
2058     spliced there.
2059
2060
2061 @section Search Algorithm
2062 @vindex *default-source-registry-exclusions*
2063
2064 In case that isn't clear, the semantics of the configuration is that
2065 when searching for a system of a given name,
2066 directives are processed in order.
2067
2068 When looking in a directory, if the system is found, the search succeeds,
2069 otherwise it continues.
2070
2071 When looking in a tree, if one system is found, the search succeeds.
2072 If multiple systems are found, the consequences are unspecified:
2073 the search may succeed with any of the found systems,
2074 or an error may be raised.
2075 ASDF currently returns the first system found,
2076 XCVB currently raised an error.
2077 If none is found, the search continues.
2078
2079 Exclude statements specify patterns of subdirectories
2080 the systems from which to ignore.
2081 Typically you don't want to use copies of files kept by such
2082 version control systems as Darcs.
2083 Exclude statements are not propagated to further included or inherited
2084 configuration files or expressions;
2085 instead the defaults are reset around every configuration statement
2086 to the default defaults from @code{asdf::*default-source-registry-exclusions*}.
2087
2088 Include statements cause the search to recurse with the path specifications
2089 from the file specified.
2090
2091 An inherit-configuration statement cause the search to recurse with the path
2092 specifications from the next configuration
2093 (@pxref{Controlling where ASDF searches for systems,,Configurations} above).
2094
2095
2096 @section Caching Results
2097
2098 The implementation is allowed to either eagerly compute the information
2099 from the configurations and file system, or to lazily re-compute it
2100 every time, or to cache any part of it as it goes.
2101 To explicitly flush any information cached by the system, use the API below.
2102
2103
2104 @section Configuration API
2105
2106 The specified functions are exported from your build system's package.
2107 Thus for ASDF the corresponding functions are in package ASDF,
2108 and for XCVB the corresponding functions are in package XCVB.
2109
2110 @defun initialize-source-registry @&optional PARAMETER
2111    will read the configuration and initialize all internal variables.
2112    You may extend or override configuration
2113    from the environment and configuration files
2114    with the given @var{PARAMETER}, which can be
2115    @code{NIL} (no configuration override),
2116    or a SEXP (in the SEXP DSL),
2117    a string (as in the string DSL),
2118    a pathname (of a file or directory with configuration),
2119    or a symbol (fbound to function that when called returns one of the above).
2120 @end defun
2121
2122 @defun clear-source-registry
2123    undoes any source registry configuration
2124    and clears any cache for the search algorithm.
2125    You might want to call this function
2126    (or better, @code{clear-configuration})
2127    before you dump an image that would be resumed
2128    with a different configuration,
2129    and return an empty configuration.
2130    Note that this does not include clearing information about
2131    systems defined in the current image, only about
2132    where to look for systems not yet defined.
2133 @end defun
2134
2135 @defun ensure-source-registry @&optional PARAMETER
2136    checks whether a source registry has been initialized.
2137    If not, initialize it with the given @var{PARAMETER}.
2138 @end defun
2139
2140 Every time you use ASDF's @code{find-system}, or
2141 anything that uses it (such as @code{operate}, @code{load-system}, etc.),
2142 @code{ensure-source-registry} is called with parameter NIL,
2143 which the first time around causes your configuration to be read.
2144 If you change a configuration file,
2145 you need to explicitly @code{initialize-source-registry} again,
2146 or maybe simply to @code{clear-source-registry} (or @code{clear-configuration})
2147 which will cause the initialization to happen next time around.
2148
2149
2150 @section Future
2151
2152 If this mechanism is successful, in the future, we may declare
2153 @code{asdf:*central-registry*} obsolete and eventually remove it.
2154 Any hook into implementation-specific search mechanisms will by then
2155 have been integrated in the @code{:default-configuration} which everyone
2156 should either explicitly use or implicit inherit. Some shell syntax
2157 for it should probably be added somehow.
2158
2159 But we're not there yet. For now, let's see how practical this new
2160 source-registry is.
2161
2162
2163 @section Rejected ideas
2164
2165 Alternatives I considered and rejected included:
2166
2167 @enumerate
2168 @item Keep @code{asdf:*central-registry*} as the master with its current semantics,
2169    and somehow the configuration parser expands the new configuration
2170    language into a expanded series of directories of subdirectories to
2171    lookup, pre-recursing through specified hierarchies. This is kludgy,
2172    and leaves little space of future cleanups and extensions.
2173
2174 @item Keep @code{asdf:*central-registry*} remains the master but extend its semantics
2175    in completely new ways, so that new kinds of entries may be implemented
2176    as a recursive search, etc. This seems somewhat backwards.
2177
2178 @item Completely remove @code{asdf:*central-registry*}
2179    and break backwards compatibility.
2180    Hopefully this will happen in a few years after everyone migrate to
2181    a better ASDF and/or to XCVB, but it would be very bad to do it now.
2182
2183 @item Replace @code{asdf:*central-registry*} by a symbol-macro with appropriate magic
2184    when you dereference it or setf it. Only the new variable with new
2185    semantics is handled by the new search procedure.
2186    Complex and still introduces subtle semantic issues.
2187 @end enumerate
2188
2189
2190 I've been suggested the below features, but have rejected them,
2191 for the sake of keeping ASDF no more complex than strictly necessary.
2192
2193 @itemize
2194 @item
2195   More syntactic sugar: synonyms for the configuration directives, such as
2196   @code{(:add-directory X)} for @code{(:directory X)}, or @code{(:add-directory-hierarchy X)}
2197   or @code{(:add-directory X :recurse t)} for @code{(:tree X)}.
2198
2199 @item
2200    The possibility to register individual files instead of directories.
2201
2202 @item
2203   Integrate Xach Beane's tilde expander into the parser,
2204   or something similar that is shell-friendly or shell-compatible.
2205   I'd rather keep ASDF minimal. But maybe this precisely keeps it
2206   minimal by removing the need for evaluated entries that ASDF has?
2207   i.e. uses of @code{USER-HOMEDIR-PATHNAME} and @code{$SBCL_HOME}
2208   Hopefully, these are already superseded by the @code{:default-registry}
2209
2210 @item
2211   Using the shell-unfriendly syntax @code{/**} instead of @code{//} to specify recursion
2212   down a filesystem tree in the environment variable.
2213   It isn't that Lisp friendly either.
2214 @end itemize
2215
2216 @section TODO
2217
2218 @itemize
2219 @item Add examples
2220 @end itemize
2221
2222
2223 @section Credits for the source-registry
2224
2225 Thanks a lot to Stelian Ionescu for the initial idea.
2226
2227 Thanks to Rommel Martinez for the initial implementation attempt.
2228
2229 All bad design ideas and implementation bugs are to mine, not theirs.
2230 But so are good design ideas and elegant implementation tricks.
2231
2232  --- Francois-Rene Rideau @email{fare@@tunes.org}, Mon, 22 Feb 2010 00:07:33 -0500
2233
2234
2235
2236 @node Controlling where ASDF saves compiled files, Error handling, Controlling where ASDF searches for systems, Top
2237 @comment  node-name,  next,  previous,  up
2238 @chapter Controlling where ASDF saves compiled files
2239 @cindex asdf-output-translations
2240 @vindex ASDF_OUTPUT_TRANSLATIONS
2241
2242 Each Common Lisp implementation has its own format
2243 for compiled files (fasls for short, short for ``fast loading'').
2244 If you use multiple implementations
2245 (or multiple versions of the same implementation),
2246 you'll soon find your source directories
2247 littered with various @file{fasl}s, @file{dfsl}s, @file{cfsl}s and so on.
2248 Worse yet, some implementations use the same file extension
2249 while changing formats from version to version (or platform to platform)
2250 which means that you'll have to recompile binaries
2251 as you switch from one implementation to the next.
2252
2253 ASDF 2 includes the @code{asdf-output-translations} facility
2254 to mitigate the problem.
2255
2256 @section Configurations
2257
2258 Configurations specify mappings from input locations to output locations.
2259 Once again we rely on the XDG base directory specification for configuration.
2260 @xref{Controlling where ASDF searches for systems,,XDG base directory}.
2261
2262 @enumerate
2263
2264 @item
2265 Some hardcoded wrapping output translations configuration may be used.
2266 This allows special output translations (or usually, invariant directories)
2267 to be specified corresponding to the similar special entries in the source registry.
2268
2269 @item
2270 An application may explicitly initialize the output-translations
2271 configuration using the Configuration API
2272 in which case this takes precedence.
2273 (@pxref{Controlling where ASDF saves compiled files,,Configuration API}.)
2274 It may itself compute this configuration from the command-line,
2275 from a script, from its own configuration file, etc.
2276
2277 @item
2278 The source registry will be configured from
2279 the environment variable @code{ASDF_OUTPUT_TRANSLATIONS} if it exists.
2280
2281 @item
2282 The source registry will be configured from
2283 user configuration file
2284 @file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf}
2285 (which defaults to
2286 @file{~/.config/common-lisp/asdf-output-translations.conf})
2287 if it exists.
2288
2289 @item
2290 The source registry will be configured from
2291 user configuration directory
2292 @file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf.d/}
2293 (which defaults to
2294 @file{~/.config/common-lisp/asdf-output-translations.conf.d/})
2295 if it exists.
2296
2297 @item
2298 The source registry will be configured from
2299 system configuration file
2300 @file{/etc/common-lisp/asdf-output-translations.conf}
2301 if it exists.
2302
2303 @item
2304 The source registry will be configured from
2305 system configuration directory
2306 @file{/etc/common-lisp/asdf-output-translations.conf.d/}
2307 if it exists.
2308
2309 @end enumerate
2310
2311 Each of these configurations is specified as a SEXP
2312 in a trival domain-specific language (defined below).
2313 Additionally, a more shell-friendly syntax is available
2314 for the environment variable (defined yet below).
2315
2316 Each of these configurations is only used if the previous
2317 configuration explicitly or implicitly specifies that it
2318 includes its inherited configuration.
2319
2320 Note that by default, a per-user cache is used for output files.
2321 This allows the seamless use of shared installations of software
2322 between several users, and takes files out of the way of the developers
2323 when they browse source code,
2324 at the expense of taking a small toll when developers have to clean up
2325 output files and find they need to get familiar with output-translations first.
2326
2327
2328 @section Backward Compatibility
2329 @cindex ASDF-BINARY-LOCATIONS compatibility
2330
2331
2332 We purposefully do NOT provide backward compatibility with earlier versions of
2333 @code{ASDF-Binary-Locations} (8 Sept 2009),
2334 @code{common-lisp-controller} (7.0) or
2335 @code{cl-launch} (2.35),
2336 each of which had similar general capabilities.
2337 The previous APIs of these programs were not designed
2338 for configuration by the end-user
2339 in an easy way with configuration files.
2340 Recent versions of same packages use
2341 the new @code{asdf-output-translations} API as defined below:
2342 @code{common-lisp-controller} (7.2) and @code{cl-launch} (3.000).
2343 @code{ASDF-Binary-Locations} is fully superseded and not to be used anymore.
2344
2345 This incompatibility shouldn't inconvenience many people.
2346 Indeed, few people use and customize these packages;
2347 these few people are experts who can trivially adapt to the new configuration.
2348 Most people are not experts, could not properly configure these features
2349 (except inasmuch as the default configuration of
2350 @code{common-lisp-controller} and/or @code{cl-launch}
2351 might have been doing the right thing for some users),
2352 and yet will experience software that ``just works'',
2353 as configured by the system distributor, or by default.
2354
2355 Nevertheless, if you are a fan of @code{ASDF-Binary-Locations},
2356 we provide a limited emulation mode:
2357
2358 @defun enable-asdf-binary-locations-compatibility @&key centralize-lisp-binaries default-toplevel-directory include-per-user-information map-all-source-files source-to-target-mappings
2359 This function will initialize the new @code{asdf-output-translations} facility in a way
2360 that emulates the behavior of the old @code{ASDF-Binary-Locations} facility.
2361 Where you would previously set global variables
2362 @var{*centralize-lisp-binaries*},
2363 @var{*default-toplevel-directory*},
2364 @var{*include-per-user-information*},
2365 @var{*map-all-source-files*} or @var{*source-to-target-mappings*}
2366 you will now have to pass the same values as keyword arguments to this function.
2367 Note however that as an extension the @code{:source-to-target-mappings} keyword argument
2368 will accept any valid pathname designator for @code{asdf-output-translations}
2369 instead of just strings and pathnames.
2370 @end defun
2371
2372 If you insist, you can also keep using the old @code{ASDF-Binary-Locations}
2373 (the one available as an extension to load of top of ASDF,
2374 not the one built into a few old versions of ASDF),
2375 but first you must disable @code{asdf-output-translations}
2376 with @code{(asdf:disable-output-translations)},
2377 or you might experience ``interesting'' issues.
2378
2379 Also, note that output translation is enabled by default.
2380 To disable it, use @code{(asdf:disable-output-translations)}.
2381
2382
2383 @section Configuration DSL
2384
2385 Here is the grammar of the SEXP DSL
2386 for @code{asdf-output-translations} configuration:
2387
2388 @verbatim
2389 ;; A configuration is single SEXP starting with keyword :source-registry
2390 ;; followed by a list of directives.
2391 CONFIGURATION := (:output-translations DIRECTIVE ...)
2392
2393 ;; A directive is one of the following:
2394 DIRECTIVE :=
2395     ;; INHERITANCE DIRECTIVE:
2396     ;; Your configuration expression MUST contain
2397     ;; exactly one of either of these:
2398     :inherit-configuration | ; splices inherited configuration (often specified last)
2399     :ignore-inherited-configuration | ; drop inherited configuration (specified anywhere)
2400
2401     ;; forward compatibility directive (since ASDF 2.011.4), useful when
2402     ;; you want to use new configuration features but have to bootstrap a
2403     ;; the newer required ASDF from an older release that doesn't sport said features:
2404     :ignore-invalid-entries | ; drops subsequent invalid entries instead of erroring out
2405
2406     ;; include a configuration file or directory
2407     (:include PATHNAME-DESIGNATOR) |
2408
2409     ;; enable global cache in ~/.common-lisp/cache/sbcl-1.0.45-linux-amd64/ or something.
2410     :enable-user-cache |
2411     ;; Disable global cache. Map / to /
2412     :disable-cache |
2413
2414     ;; add a single directory to be scanned (no recursion)
2415     (DIRECTORY-DESIGNATOR DIRECTORY-DESIGNATOR)
2416
2417     ;; use a function to return the translation of a directory designator
2418     (DIRECTORY-DESIGNATOR (:function TRANSLATION-FUNCTION))
2419
2420 DIRECTORY-DESIGNATOR :=
2421     T | ;; as source matches anything, as destination leaves pathname unmapped.
2422     ABSOLUTE-COMPONENT-DESIGNATOR |
2423     (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...)
2424
2425 ABSOLUTE-COMPONENT-DESIGNATOR :=
2426     NULL | ;; As source: skip this entry. As destination: same as source
2427     :ROOT | ;; magic: paths that are relative to the root of the source host and device
2428     STRING | ;; namestring (directory is assumed, better be absolute or bust, ``/**/*.*'' added)
2429     PATHNAME | ;; pathname (better be an absolute directory or bust)
2430     :HOME | ;; designates the user-homedir-pathname ~/
2431     :USER-CACHE | ;; designates the default location for the user cache
2432     :SYSTEM-CACHE ;; designates the default location for the system cache
2433
2434 RELATIVE-COMPONENT-DESIGNATOR :=
2435     STRING | ;; namestring, directory is assumed. If the last component, /**/*.* is added
2436     PATHNAME | ;; pathname; unless last component, directory is assumed.
2437     :IMPLEMENTATION | ;; a directory based on implementation, e.g. sbcl-1.0.45-linux-amd64
2438     :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl
2439     :*/ | ;; any direct subdirectory (since ASDF 2.011.4)
2440     :**/ | ;; any recursively inferior subdirectory (since ASDF 2.011.4)
2441     :*.*.* | ;; any file (since ASDF 2.011.4)
2442     :UID | ;; current UID -- not available on Windows
2443     :USER ;; current USER name -- NOT IMPLEMENTED(!)
2444
2445 TRANSLATION-FUNCTION :=
2446     SYMBOL | ;; symbol of a function that takes two arguments,
2447              ;; the pathname to be translated and the matching DIRECTORY-DESIGNATOR
2448     LAMBDA   ;; A form which evalutates to a function taking two arguments consisting of
2449              ;; the pathname to be translated and the matching DIRECTORY-DESIGNATOR
2450
2451 @end verbatim
2452
2453 Relative components better be either relative
2454 or subdirectories of the path before them, or bust.
2455
2456 The last component, if not a pathname, is notionally completed by @file{/**/*.*}.
2457 You can specify more fine-grained patterns
2458 by using a pathname object as the last component
2459 e.g. @file{#p"some/path/**/foo*/bar-*.fasl"}
2460
2461 You may use @code{#+features} to customize the configuration file.
2462
2463 The second designator of a mapping may be @code{NIL}, indicating that files are not mapped
2464 to anything but themselves (same as if the second designator was the same as the first).
2465
2466 When the first designator is @code{t},
2467 the mapping always matches.
2468 When the first designator starts with @code{:root},
2469 the mapping matches any host and device.
2470 In either of these cases, if the second designator
2471 isn't @code{t} and doesn't start with @code{:root},
2472 then strings indicating the host and pathname are somehow copied
2473 in the beginning of the directory component of the source pathname
2474 before it is translated.
2475
2476 When the second designator is @code{t}, the mapping is the identity.
2477 When the second designator starts with @code{:root},
2478 the mapping preserves the host and device of the original pathname.
2479 Notably, this allows you to map files
2480 to a subdirectory of the whichever directory the file is in.
2481 Though the syntax is not quite as easy to use as we'd like,
2482 you can have an (source destination) mapping entry such as follows
2483 in your configuration file,
2484 or you may use @code{enable-asdf-binary-locations-compatibility}
2485 with @code{:centralize-lisp-binaries nil}
2486 which will do the same thing internally for you:
2487 @verbatim
2488   #.(let ((wild-subdir (make-pathname :directory '(:relative :wild-inferiors)))
2489           (wild-file (make-pathname :name :wild :version :wild :type :wild)))
2490      `((:root ,wild-subdir ,wild-file) ;; Or using the implicit wildcard, just :root
2491        (:root ,wild-subdir :implementation ,wild-file)))
2492 @end verbatim
2493 Starting with ASDF 2.011.4, you can use the simpler:
2494         @code{`(:root (:root :**/ :implementation :*.*.*))}
2495
2496
2497
2498 @code{:include} statements cause the search to recurse with the path specifications
2499 from the file specified.
2500
2501 If the @code{translate-pathname} mechanism cannot achieve a desired
2502 translation, the user may provide a function which provides the
2503 required algorithim.  Such a translation function is specified by
2504 supplying a list as the second @code{directory-designator}
2505 the first element of which is the keyword @code{:function},
2506 and the second element of which is
2507 either a symbol which designates a function or a lambda expression.
2508 The function designated by the second argument must take two arguments,
2509 the first being the pathname of the source file,
2510 the second being the wildcard that was matched.
2511 The result of the function invocation should be the translated pathname.
2512
2513 An @code{:inherit-configuration} statement cause the search to recurse with the path
2514 specifications from the next configuration.
2515 @xref{Controlling where ASDF saves compiled files,,Configurations}, above.
2516
2517 @itemize
2518 @item
2519 @code{:enable-user-cache} is the same as @code{(t :user-cache)}.
2520 @item
2521 @code{:disable-cache} is the same as @code{(t t)}.
2522 @item
2523 @code{:user-cache} uses the contents of variable @code{asdf::*user-cache*}
2524 which by default is the same as using
2525 @code{(:home ".cache" "common-lisp" :implementation)}.
2526 @item
2527 @code{:system-cache} uses the contents of variable @code{asdf::*system-cache*}
2528 which by default is the same as using
2529 @code{("/var/cache/common-lisp" :uid :implementation-type)}
2530 (on Unix and cygwin), or something semi-sensible on Windows.
2531 @end itemize
2532
2533
2534 @section Configuration Directories
2535
2536 Configuration directories consist in files each contains
2537 a list of directives without any enclosing
2538 @code{(:output-translations ...)} form.
2539 The files will be sorted by namestring as if by @code{string<} and
2540 the lists of directives of these files with be concatenated in order.
2541 An implicit @code{:inherit-configuration} will be included
2542 at the @emph{end} of the list.
2543
2544 This allows for packaging software that has file granularity
2545 (e.g. Debian's @command{dpkg} or some future version of @command{clbuild})
2546 to easily include configuration information about software being distributed.
2547
2548 The convention is that, for sorting purposes,
2549 the names of files in such a directory begin with two digits
2550 that determine the order in which these entries will be read.
2551 Also, the type of these files is conventionally @code{"conf"}
2552 and as a limitation of some implementations, the type cannot be @code{NIL}.
2553
2554 Directories may be included by specifying a directory pathname
2555 or namestring in an @code{:include} directive, e.g.:
2556 @verbatim
2557         (:include "/foo/bar/")
2558 @end verbatim
2559
2560 @section Shell-friendly syntax for configuration
2561
2562 When considering environment variable @code{ASDF_OUTPUT_TRANSLATIONS}
2563 ASDF will skip to next configuration if it's an empty string.
2564 It will @code{READ} the string as an SEXP in the DSL
2565 if it begins with a paren @code{(}
2566 and it will be interpreted as a list of directories.
2567 Directories should come by pairs, indicating a mapping directive.
2568 Entries are separated
2569 by a @code{:} (colon) on Unix platforms (including cygwin),
2570 by a @code{;} (semicolon) on other platforms (mainly, Windows).
2571
2572 The magic empty entry,
2573 if it comes in what would otherwise be the first entry in a pair,
2574 indicates the splicing of inherited configuration.
2575 If it comes as the second entry in a pair,
2576 it indicates that the directory specified first is to be left untranslated
2577 (which has the same effect as if the directory had been repeated).
2578
2579
2580 @section Semantics of Output Translations
2581
2582 From the specified configuration,
2583 a list of mappings is extracted in a straightforward way:
2584 mappings are collected in order, recursing through
2585 included or inherited configuration as specified.
2586 To this list is prepended some implementation-specific mappings,
2587 and is appended a global default.
2588
2589 The list is then compiled to a mapping table as follows:
2590 for each entry, in order, resolve the first designated directory
2591 into an actual directory pathname for source locations.
2592 If no mapping was specified yet for that location,
2593 resolve the second designated directory to an output location directory
2594 add a mapping to the table mapping the source location to the output location,
2595 and add another mapping from the output location to itself
2596 (unless a mapping already exists for the output location).
2597
2598 Based on the table, a mapping function is defined,
2599 mapping source pathnames to output pathnames:
2600 given a source pathname, locate the longest matching prefix
2601 in the source column of the mapping table.
2602 Replace that prefix by the corresponding output column
2603 in the same row of the table, and return the result.
2604 If no match is found, return the source pathname.
2605 (A global default mapping the filesystem root to itself
2606 may ensure that there will always be a match,
2607 with same fall-through semantics).
2608
2609 @section Caching Results
2610
2611 The implementation is allowed to either eagerly compute the information
2612 from the configurations and file system, or to lazily re-compute it
2613 every time, or to cache any part of it as it goes.
2614 To explicitly flush any information cached by the system, use the API below.
2615
2616
2617 @section Output location API
2618
2619 The specified functions are exported from package ASDF.
2620
2621 @defun initialize-output-translations @&optional PARAMETER
2622    will read the configuration and initialize all internal variables.
2623    You may extend or override configuration
2624    from the environment and configuration files
2625    with the given @var{PARAMETER}, which can be
2626    @code{NIL} (no configuration override),
2627    or a SEXP (in the SEXP DSL),
2628    a string (as in the string DSL),
2629    a pathname (of a file or directory with configuration),
2630    or a symbol (fbound to function that when called returns one of the above).
2631 @end defun
2632
2633 @defun disable-output-translations
2634    will initialize output translations in a way
2635    that maps every pathname to itself,
2636    effectively disabling the output translation facility.
2637 @end defun
2638
2639 @defun clear-output-translations
2640    undoes any output translation configuration
2641    and clears any cache for the mapping algorithm.
2642    You might want to call this function
2643    (or better, @code{clear-configuration})
2644    before you dump an image that would be resumed
2645    with a different configuration,
2646    and return an empty configuration.
2647    Note that this does not include clearing information about
2648    systems defined in the current image, only about
2649    where to look for systems not yet defined.
2650 @end defun
2651
2652 @defun ensure-output-translations @&optional PARAMETER
2653    checks whether output translations have been initialized.
2654    If not, initialize them with the given @var{PARAMETER}.
2655    This function will be called before any attempt to operate on a system.
2656 @end defun
2657
2658 @defun apply-output-translations PATHNAME
2659    Applies the configured output location translations to @var{PATHNAME}
2660    (calls @code{ensure-output-translations} for the translations).
2661 @end defun
2662
2663 Every time you use ASDF's @code{output-files}, or
2664 anything that uses it (that may compile, such as @code{operate}, @code{perform}, etc.),
2665 @code{ensure-output-translations} is called with parameter NIL,
2666 which the first time around causes your configuration to be read.
2667 If you change a configuration file,
2668 you need to explicitly @code{initialize-output-translations} again,
2669 or maybe @code{clear-output-translations} (or @code{clear-configuration}),
2670 which will cause the initialization to happen next time around.
2671
2672
2673 @section Credits for output translations
2674
2675 Thanks a lot to Bjorn Lindberg and Gary King for @code{ASDF-Binary-Locations},
2676 and to Peter van Eynde for @code{Common Lisp Controller}.
2677
2678 All bad design ideas and implementation bugs are to mine, not theirs.
2679 But so are good design ideas and elegant implementation tricks.
2680
2681  --- Francois-Rene Rideau @email{fare@@tunes.org}
2682
2683 @c @section Default locations
2684 @c @findex output-files-for-system-and-operation
2685
2686 @c The default binary location for each Lisp implementation
2687 @c is a subdirectory of each source directory.
2688 @c To account for different Lisps, Operating Systems, Implementation versions,
2689 @c and so on, ASDF borrows code from SLIME
2690 @c to create reasonable custom directory names.
2691 @c Here are some examples:
2692
2693 @c @itemize
2694 @c @item
2695 @c SBCL, version 1.0.45 on Mac OS X for Intel: @code{sbcl-1.0.45-darwin-x86}
2696
2697 @c @item
2698 @c Franz Allegro, version 8.0, ANSI Common Lisp: @code{allegro-8.0a-macosx-x86}
2699
2700 @c @item
2701 @c Franz Allegro, version 8.1, Modern (case sensitive) Common Lisp: @code{allegro-8.1m-macosx-x86}
2702 @c @end itemize
2703
2704 @c By default, all output file pathnames will be relocated
2705 @c to some thus-named subdirectory of @file{~/.cache/common-lisp/}.
2706
2707 @c See the document @file{README.asdf-output-translations}
2708 @c for a full specification on how to configure @code{asdf-output-translations}.
2709
2710 @node  Error handling, Miscellaneous additional functionality, Controlling where ASDF saves compiled files, Top
2711 @comment  node-name,  next,  previous,  up
2712 @chapter Error handling
2713 @findex SYSTEM-DEFINITION-ERROR
2714 @findex OPERATION-ERROR
2715
2716 @section ASDF errors
2717
2718 If ASDF detects an incorrect system definition, it will signal a generalised instance of
2719 @code{SYSTEM-DEFINITION-ERROR}.
2720
2721 Operations may go wrong (for example when source files contain errors).
2722 These are signalled using generalised instances of
2723 @code{OPERATION-ERROR}.
2724
2725 @section Compilation error and warning handling
2726 @vindex *compile-file-warnings-behaviour*
2727 @vindex *compile-file-errors-behavior*
2728
2729 ASDF checks for warnings and errors when a file is compiled.
2730 The variables @var{*compile-file-warnings-behaviour*} and
2731 @var{*compile-file-errors-behavior*}
2732 control the handling of any such events.
2733 The valid values for these variables are
2734 @code{:error}, @code{:warn}, and @code{:ignore}.
2735
2736 @node  Miscellaneous additional functionality, Getting the latest version, Error handling, Top
2737 @comment  node-name,  next,  previous,  up
2738 @chapter Miscellaneous additional functionality
2739
2740 @emph{FIXME:  Add discussion of @code{run-shell-command}?  Others?}
2741
2742 ASDF includes several additional features that are generally
2743 useful for system definition and development. These include:
2744
2745 @defun coerce-pathname name @&key type defaults
2746
2747 This function (available starting with ASDF 2.012.11)
2748 takes an argument, and portably interprets it as a pathname.
2749 If the argument @var{name} is a pathname or @code{nil}, it is passed through;
2750 if it's a symbol, it's interpreted as a string by downcasing it;
2751 if it's a string, it is first separated using @code{/} into substrings;
2752 the leading substrings denote subdirectories of a relative pathname.
2753 If @var{type} is @code{:directory} or the string ends with @code{/},
2754 the last substring is also a subdirectory;
2755 if @var{type} is a string, it is used as the type of the pathname, and
2756 the last substring is the name component of the pathname;
2757 if @var{type} is @code{nil}, the last substring specifies both name and type components
2758 of the pathname, with the last @code{.} separating them, or only the name component
2759 if there's no last @code{.} or if there is only one dot and it's the first character.
2760 The host, device and version components come from @var{defaults}, which defaults to
2761 @var{*default-pathname-defaults*}; but that shouldn't matter if you use @code{merge-pathnames*}.
2762
2763 @end defun
2764
2765 @defun merge-pathnames* @&key specified defaults
2766
2767 This function is a replacement for @code{merge-pathnames} that uses the host and device
2768 from the @var{defaults} rather than the @var{specified} pathname when the latter
2769 is a relative pathname. This allows ASDF and its users to create and use relative pathnames
2770 without having to know beforehand what are the host and device
2771 of the absolute pathnames they are relative to.
2772
2773 @end defun
2774
2775 @defun system-relative-pathname system name @&key type
2776
2777 It's often handy to locate a file relative to some system.
2778 The @code{system-relative-pathname} function meets this need.
2779
2780 It takes two mandatory arguments @var{system} and @var{name}
2781 and a keyword argument @var{type}:
2782 @var{system} is name of a system, whereas @var{name} and optionally @var{type}
2783 specify a relative pathname, interpreted like a component pathname specifier
2784 by @code{coerce-pathname}. @xref{The defsystem grammar,,Pathname specifiers}.
2785
2786 It returns a pathname built from the location of the system's
2787 source directory and the relative pathname. For example:
2788
2789 @lisp
2790 > (asdf:system-relative-pathname 'cl-ppcre "regex.data")
2791 #P"/repository/other/cl-ppcre/regex.data"
2792 @end lisp
2793
2794 @end defun
2795
2796 @defun system-source-directory system-designator
2797
2798 ASDF does not provide a turnkey solution for locating
2799 data (or other miscellaneous) files
2800 that are distributed together with the source code of a system.
2801 Programmers can use @code{system-source-directory} to find such files.
2802 Returns a pathname object.
2803 The @var{system-designator} may be a string, symbol, or ASDF system object.
2804 @end defun
2805
2806 @defun clear-system system-designator
2807
2808 It is sometimes useful to force recompilation of a previously loaded system.
2809 In these cases, it may be useful to @code{(asdf:clear-system :foo)}
2810 to remove the system from the table of currently loaded systems;
2811 the next time the system @code{foo} or one that depends on it is re-loaded,
2812 @code{foo} will then be loaded again.
2813 Alternatively, you could touch @code{foo.asd} or
2814 remove the corresponding fasls from the output file cache.
2815 (It was once conceived that one should provide
2816 a list of systems the recompilation of which to force
2817 as the @code{:force} keyword argument to @code{load-system};
2818 but this has never worked, and though the feature was fixed in ASDF 2.000,
2819 it remains @code{cerror}'ed out as nobody ever used it.)
2820
2821 Note that this does not and cannot by itself undo the previous loading
2822 of the system. Common Lisp has no provision for such an operation,
2823 and its reliance on irreversible side-effects to global datastructures
2824 makes such a thing impossible in the general case.
2825 If the software being re-loaded is not conceived with hot upgrade in mind,
2826 this re-loading may cause many errors, warnings or subtle silent problems,
2827 as packages, generic function signatures, structures, types, macros, constants, etc.
2828 are being redefined incompatibly.
2829 It is up to the user to make sure that reloading is possible and has the desired effect.
2830 In some cases, extreme measures such as recursively deleting packages,
2831 unregistering symbols, defining methods on @code{update-instance-for-redefined-class}
2832 and much more are necessary for reloading to happen smoothly.
2833 ASDF itself goes through notable pains to make such a hot upgrade possible
2834 with respect to its own code, and what it does is ridiculously complex;
2835 look at the beginning of @file{asdf.lisp} to see what it does.
2836 @end defun
2837
2838 @node Getting the latest version, FAQ, Miscellaneous additional functionality, Top
2839 @comment  node-name,  next,  previous,  up
2840 @chapter Getting the latest version
2841
2842 Decide which version you want.
2843 The @code{master} branch is where development happens;
2844 its @code{HEAD} is usually OK, including the latest fixes and portability tweaks,
2845 but an occasional regression may happen despite our (limited) test suite.
2846
2847 The @code{release} branch is what cautious people should be using;
2848 it has usually been tested more, and releases are cut at a point
2849 where there isn't any known unresolved issue.
2850
2851 You may get the ASDF source repository using git:
2852 @kbd{git clone git://common-lisp.net/projects/asdf/asdf.git}
2853
2854 You will find the above referenced tags in this repository.
2855 You can also browse the repository on
2856 @url{http://common-lisp.net/gitweb?p=projects/asdf/asdf.git}.
2857
2858 Discussion of ASDF development is conducted on the
2859 mailing list
2860 @kbd{asdf-devel@@common-lisp.net}.
2861 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel}
2862
2863
2864 @node FAQ, TODO list, Getting the latest version, Top
2865 @comment  node-name,  next,  previous,  up
2866 @chapter FAQ
2867
2868 @section  ``Where do I report a bug?''
2869
2870 ASDF bugs are tracked on launchpad: @url{https://launchpad.net/asdf}.
2871
2872 If you're unsure about whether something is a bug, or for general discussion,
2873 use the @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
2874
2875
2876 @section ``What has changed between ASDF 1 and ASDF 2?''
2877
2878 @subsection What are ASDF 1 and ASDF 2?
2879
2880 On May 31st 2010, we have released ASDF 2.
2881 ASDF 2 refers to release 2.000 and later.
2882 (Releases between 1.656 and 1.728 were development releases for ASDF 2.)
2883 ASDF 1 to any release earlier than 1.369 or so.
2884 If your ASDF doesn't sport a version, it's an old ASDF 1.
2885
2886 ASDF 2 and its release candidates push
2887 @code{:asdf2} onto @code{*features*} so that if you are writing
2888 ASDF-dependent code you may check for this feature
2889 to see if the new API is present.
2890 @emph{All} versions of ASDF should have the @code{:asdf} feature.
2891
2892 If you are experiencing problems or limitations of any sort with ASDF 1,
2893 we recommend that you should upgrade to ASDF 2,
2894 or whatever is the latest release.
2895
2896
2897 @subsection ASDF can portably name files in subdirectories
2898
2899 Common Lisp namestrings are not portable,
2900 except maybe for logical pathnamestrings,
2901 that themselves have various limitations and require a lot of setup
2902 that is itself ultimately non-portable.
2903
2904 In ASDF 1, the only portable ways to refer to pathnames inside systems and components
2905 were very awkward, using @code{#.(make-pathname ...)} and
2906 @code{#.(merge-pathnames ...)}.
2907 Even the above were themselves were inadequate in the general case
2908 due to host and device issues, unless horribly complex patterns were used.
2909 Plenty of simple cases that looked portable actually weren't,
2910 leading to much confusion and greavance.
2911
2912 ASDF 2 implements its own portable syntax for strings as pathname specifiers.
2913 Naming files within a system definition becomes easy and portable again.
2914 @xref{Miscellaneous additional functionality,asdf:system-relative-pathname},
2915 @code{merge-pathnames*},
2916 @code{coerce-pathname}.
2917
2918 On the other hand, there are places where systems used to accept namestrings
2919 where you must now use an explicit pathname object:
2920 @code{(defsystem ... :pathname "LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
2921 must now be written with the @code{#p} syntax:
2922 @code{(defsystem ... :pathname #p"LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
2923
2924 @xref{The defsystem grammar,,Pathname specifiers}.
2925
2926
2927 @subsection Output translations
2928
2929 A popular feature added to ASDF was output pathname translation:
2930 @code{asdf-binary-locations}, @code{common-lisp-controller},
2931 @code{cl-launch} and other hacks were all implementing it in ways
2932 both mutually incompatible and difficult to configure.
2933
2934 Output pathname translation is essential to share
2935 source directories of portable systems across multiple implementations
2936 or variants thereof,
2937 or source directories of shared installations of systems across multiple users,
2938 or combinations of the above.
2939
2940 In ASDF 2, a standard mechanism is provided for that,
2941 @code{asdf-output-translations},
2942 with sensible defaults, adequate configuration languages,
2943 a coherent set of configuration files and hooks,
2944 and support for non-Unix platforms.
2945
2946 @xref{Controlling where ASDF saves compiled files}.
2947
2948 @subsection Source Registry Configuration
2949
2950 Configuring ASDF used to require special magic
2951 to be applied just at the right moment,
2952 between the moment ASDF is loaded and the moment it is used,
2953 in a way that is specific to the user,
2954 the implementation he is using and the application he is building.
2955
2956 This made for awkward configuration files and startup scripts
2957 that could not be shared between users, managed by administrators
2958 or packaged by distributions.
2959
2960 ASDF 2 provides a well-documented way to configure ASDF,
2961 with sensible defaults, adequate configuration languages,
2962 and a coherent set of configuration files and hooks.
2963
2964 We believe it's a vast improvement because it decouples
2965 application distribution from library distribution.
2966 The application writer can avoid thinking where the libraries are,
2967 and the library distributor (dpkg, clbuild, advanced user, etc.)
2968 can configure them once and for every application.
2969 Yet settings can be easily overridden where needed,
2970 so whoever needs control has exactly as much as required.
2971
2972 At the same time, ASDF 2 remains compatible
2973 with the old magic you may have in your build scripts
2974 (using @code{*central-registry*} and
2975 @code{*system-definition-search-functions*})
2976 to tailor the ASDF configuration to your build automation needs,
2977 and also allows for new magic, simpler and more powerful magic.
2978
2979 @xref{Controlling where ASDF searches for systems}.
2980
2981
2982 @subsection Usual operations are made easier to the user
2983
2984 In ASDF 1, you had to use the awkward syntax
2985 @code{(asdf:oos 'asdf:load-op :foo)}
2986 to load a system,
2987 and similarly for @code{compile-op}, @code{test-op}.
2988
2989 In ASDF 2, you can use shortcuts for the usual operations:
2990 @code{(asdf:load-system :foo)}, and
2991 similarly for @code{compile-system}, @code{test-system}.
2992
2993
2994 @subsection Many bugs have been fixed
2995
2996 The following issues and many others have been fixed:
2997
2998 @itemize
2999 @item
3000 The infamous TRAVERSE function has been revamped significantly,
3001 with many bugs squashed.
3002 In particular, dependencies were not correctly propagated
3003 across submodules within a system but now are.
3004 The :version and :feature features and
3005 the :force (system1 .. systemN) feature have been fixed.
3006
3007 @item
3008 Performance has been notably improved for large systems
3009 (say with thousands of components) by using
3010 hash-tables instead of linear search,
3011 and linear-time list accumulation
3012 instead of quadratic-time recursive appends.
3013
3014 @item
3015 Many features used to not be portable,
3016 especially where pathnames were involved.
3017 Windows support was notably quirky because of such non-portability.
3018
3019 @item
3020 The internal test suite used to massively fail on many implementations.
3021 While still incomplete, it now fully passes
3022 on all implementations supported by the test suite,
3023 except for GCL (due to GCL bugs).
3024
3025 @item
3026 Support was lacking for some implementations.
3027 ABCL and GCL were notably wholly broken.
3028 ECL extensions were not integrated in the ASDF release.
3029
3030 @item
3031 The documentation was grossly out of date.
3032
3033 @end itemize
3034
3035
3036 @subsection ASDF itself is versioned
3037
3038 Between new features, old bugs fixed, and new bugs introduced,
3039 there were various releases of ASDF in the wild,
3040 and no simple way to check which release had which feature set.
3041 People using or writing systems had to either make worst-case assumptions
3042 as to what features were available and worked,
3043 or take great pains to have the correct version of ASDF installed.
3044
3045 With ASDF 2, we provide a new stable set of working features
3046 that everyone can rely on from now on.
3047 Use @code{#+asdf2} to detect presence of ASDF 2,
3048 @code{(asdf:version-satisfies (asdf:asdf-version) "2.000")}
3049 to check the availability of a version no earlier than required.
3050
3051
3052 @subsection ASDF can be upgraded
3053
3054 When an old version of ASDF was loaded,
3055 it was very hard to upgrade ASDF in your current image
3056 without breaking everything.
3057 Instead you have to exit the Lisp process and
3058 somehow arrange to start a new one from a simpler image.
3059 Something that can't be done from within Lisp,
3060 making automation of it difficult,
3061 which compounded with difficulty in configuration,
3062 made the task quite hard.
3063 Yet as we saw before, the task would have been required
3064 to not have to live with the worst case or non-portable
3065 subset of ASDF features.
3066
3067 With ASDF 2, it is easy to upgrade
3068 from ASDF 2 to later versions from within Lisp,
3069 and not too hard to upgrade from ASDF 1 to ASDF 2 from within Lisp.
3070 We support hot upgrade of ASDF and any breakage is a bug
3071 that we will do our best to fix.
3072 There are still limitations on upgrade, though,
3073 most notably the fact that after you upgrade ASDF,
3074 you must also reload or upgrade all ASDF extensions.
3075
3076 @subsection Decoupled release cycle
3077
3078 When vendors were releasing their Lisp implementations with ASDF,
3079 they had to basically never change version
3080 because neither upgrade nor downgrade was possible
3081 without breaking something for someone,
3082 and no obvious upgrade path was visible and recommendable.
3083
3084 With ASDF 2, upgrade is possible, easy and can be recommended.
3085 This means that vendors can safely ship a recent version of ASDF,
3086 confident that if a user isn't fully satisfied,
3087 he can easily upgrade ASDF and deal
3088 with a supported recent version of it.
3089 This means that release cycles will be causally decoupled,
3090 the practical consequence of which will mean faster convergence
3091 towards the latest version for everyone.
3092
3093
3094 @subsection Pitfalls of the transition to ASDF 2
3095
3096 The main pitfalls in upgrading to ASDF 2 seem to be related
3097 to the output translation mechanism.
3098
3099 @itemize
3100
3101 @item
3102 Output translations is enabled by default. This may surprise some users,
3103 most of them in pleasant way (we hope), a few of them in an unpleasant way.
3104 It is trivial to disable output translations.
3105 @xref{FAQ,,``How can I wholly disable the compiler output cache?''}.
3106
3107 @item
3108 Some systems in the large have been known not to play well with output translations.
3109 They were relatively easy to fix.
3110 Once again, it is also easy to disable output translations,
3111 or to override its configuration.
3112
3113 @item
3114 The new ASDF output translations are incompatible with ASDF-Binary-Locations.
3115 They replace A-B-L, and there is compatibility mode to emulate
3116 your previous A-B-L configuration.
3117 See @code{enable-asdf-binary-locations-compatibility} in
3118 @pxref{Controlling where ASDF saves compiled files,,Backward Compatibility}.
3119 But thou shall not load ABL on top of ASDF 2.
3120
3121 @end itemize
3122
3123 Other issues include the following:
3124
3125 @itemize
3126
3127 @item
3128 ASDF pathname designators are now specified in places where they were unspecified,
3129 and a few small adjustments have to be made to some non-portable defsystems.
3130 Notably, in the @code{:pathname} argument to a @code{defsystem} and its components,
3131 a logical pathname (or implementation-dependent hierarchical pathname)
3132 must now be specified with @code{#p} syntax
3133 where the namestring might have previously sufficed;
3134 moreover when evaluation is desired @code{#.} must be used,
3135 where it wasn't necessary in the toplevel @code{:pathname} argument.
3136
3137 @item
3138 There is a slight performance bug, notably on SBCL,
3139 when initially searching for @file{asd} files,
3140 the implicit @code{(directory "/configured/path/**/*.asd")}
3141 for every configured path @code{(:tree "/configured/path/")}
3142 in your @code{source-registry} configuration can cause a slight pause.
3143 Try to @code{(time (asdf:initialize-source-registry))}
3144 to see how bad it is or isn't on your system.
3145 If you insist on not having this pause,
3146 you can avoid the pause by overriding the default source-registry configuration
3147 and not use any deep @code{:tree} entry but only @code{:directory} entries
3148 or shallow @code{:tree} entries.
3149 Or you can fix your implementation to not be quite that slow
3150 when recursing through directories.
3151
3152 @item
3153 On Windows, only LispWorks supports proper default configuration pathnames
3154 based on the Windows registry.
3155 Other implementations make do with environment variables.
3156 Windows support is somewhat less tested than Unix support.
3157 Please help report and fix bugs.
3158
3159 @item
3160 The mechanism by which one customizes a system so that Lisp files
3161 may use a different extension from the default @file{.lisp} has changed.
3162 Previously, the pathname for a component was lazily computed when operating on a system,
3163 and you would
3164 @code{(defmethod source-file-type ((component cl-source-file) (system (eql (find-system 'foo))))
3165   (declare (ignorable component system)) "cl")}.
3166 Now, the pathname for a component is eagerly computed when defining the system,
3167 and instead you will @code{(defclass cl-source-file.lis (cl-source-file) ((type :initform "lis")))}
3168 and use @code{:default-component-class cl-source-file.lis} as argument to @code{defsystem},
3169 as detailed in a @pxref{FAQ,How do I create a system definition where all the source files have a .cl extension?} below.
3170
3171 @findex source-file-type
3172
3173
3174 @end itemize
3175
3176
3177 @section Issues with installing the proper version of ASDF
3178
3179 @subsection ``My Common Lisp implementation comes with an outdated version of ASDF. What to do?''
3180
3181 We recommend you upgrade ASDF.
3182 @xref{Loading ASDF,,Upgrading ASDF}.
3183
3184 If this does not work, it is a bug, and you should report it.
3185 @xref{FAQ, report-bugs, Where do I report a bug}.
3186 In the meantime, you can load @file{asdf.lisp} directly.
3187 @xref{Loading ASDF,Loading an otherwise installed ASDF}.
3188
3189
3190 @subsection ``I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?''
3191
3192 Starting with current candidate releases of ASDF 2,
3193 it should always be a good time to upgrade to a recent ASDF.
3194 You may consult with the maintainer for which specific version they recommend,
3195 but the latest @code{release} should be correct.
3196 We trust you to thoroughly test it with your implementation before you release it.
3197 If there are any issues with the current release,
3198 it's a bug that you should report upstream and that we will fix ASAP.
3199
3200 As to how to include ASDF, we recommend the following:
3201
3202 @itemize
3203 @item
3204 If ASDF isn't loaded yet, then @code{(require :asdf)}
3205 should load the version of ASDF that is bundled with your system.
3206 You may have it load some other version configured by the user,
3207 if you allow such configuration.
3208
3209 @item
3210 If your system provides a mechanism to hook into @code{CL:REQUIRE},
3211 then it would be nice to add ASDF to this hook the same way that
3212 ABCL, CCL, CLISP, CMUCL, ECL, SBCL and SCL do it.
3213
3214 @item
3215 You may, like SBCL, have ASDF be implicitly used to require systems
3216 that are bundled with your Lisp distribution.
3217 If you do have a few magic systems that come with your implementation
3218 in a precompiled way such that one should only use the binary version
3219 that goes with your distribution, like SBCL does,
3220 then you should add them in the beginning of @code{wrapping-source-registry}.
3221
3222 @item
3223 If you have magic systems as above, like SBCL does,
3224 then we explicitly ask you to @emph{NOT} distribute
3225 @file{asdf.asd} as part of those magic systems.
3226 You should still include the file @file{asdf.lisp} in your source distribution
3227 and precompile it in your binary distribution,
3228 but @file{asdf.asd} if included at all,
3229 should be secluded from the magic systems,
3230 in a separate file hierarchy;
3231 alternatively, you may provide the system
3232 after renaming it and its @file{.asd} file to e.g.
3233 @code{asdf-ecl} and @file{asdf-ecl.asd}, or
3234 @code{sb-asdf} and @file{sb-asdf.asd}.
3235 Indeed, if you made @file{asdf.asd} a magic system,
3236 then users would no longer be able to upgrade ASDF using ASDF itself
3237 to some version of their preference that
3238 they maintain independently from your Lisp distribution.
3239
3240 @item
3241 If you do not have any such magic systems, or have other non-magic systems
3242 that you want to bundle with your implementation,
3243 then you may add them to the @code{default-source-registry},
3244 and you are welcome to include @file{asdf.asd} amongst them.
3245
3246 @item
3247 Please send us upstream any patches you make to ASDF itself,
3248 so we can merge them back in for the benefit of your users
3249 when they upgrade to the upstream version.
3250
3251 @end itemize
3252
3253
3254
3255 @section Issues with configuring ASDF
3256
3257 @subsection ``How can I customize where fasl files are stored?''
3258
3259 @xref{Controlling where ASDF saves compiled files}.
3260
3261 Note that in the past there was an add-on to ASDF called
3262 @code{ASDF-binary-locations}, developed by Gary King.
3263 That add-on has been merged into ASDF proper,
3264 then superseded by the @code{asdf-output-translations} facility.
3265
3266 Note that use of @code{asdf-output-translations}
3267 can interfere with one aspect of your systems
3268 --- if your system uses @code{*load-truename*} to find files
3269 (e.g., if you have some data files stored with your program),
3270 then the relocation that this ASDF customization performs
3271 is likely to interfere.
3272 Use @code{asdf:system-relative-pathname} to locate a file
3273 in the source directory of some system, and
3274 use @code{asdf:apply-output-translations} to locate a file
3275 whose pathname has been translated by the facility.
3276
3277 @subsection ``How can I wholly disable the compiler output cache?''
3278
3279 To permanently disable the compiler output cache
3280 for all future runs of ASDF, you can:
3281
3282 @example
3283 mkdir -p ~/.config/common-lisp/asdf-output-translations.conf.d/
3284 echo ':disable-cache' > ~/.config/common-lisp/asdf-output-translations.conf.d/99-disable-cache.conf
3285 @end example
3286
3287 This assumes that you didn't otherwise configure the ASDF files
3288 (if you did, edit them again),
3289 and don't somehow override the configuration at runtime
3290 with a shell variable (see below) or some other runtime command
3291 (e.g. some call to @code{asdf:initialize-output-translations}).
3292
3293 To disable the compiler output cache in Lisp processes
3294 run by your current shell, try (assuming @code{bash} or @code{zsh})
3295 (on Unix and cygwin only):
3296
3297 @example
3298 export ASDF_OUTPUT_TRANSLATIONS=/:
3299 @end example
3300
3301 To disable the compiler output cache just in the current Lisp process,
3302 use (after loading ASDF but before using it):
3303
3304 @example
3305 (asdf:disable-output-translations)
3306 @end example
3307
3308 @section Issues with using and extending ASDF to define systems
3309
3310 @subsection ``How can I cater for unit-testing in my system?''
3311
3312 ASDF provides a predefined test operation, @code{test-op}.
3313 @xref{Predefined operations of ASDF, test-op}.
3314 The test operation, however, is largely left to the system definer to specify.
3315 @code{test-op} has been
3316 a topic of considerable discussion on the
3317 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list},
3318 and on the
3319 @url{https://launchpad.net/asdf,launchpad bug-tracker}.
3320
3321 Here are some guidelines:
3322
3323 @itemize
3324 @item
3325 For a given system, @var{foo}, you will want to define a corresponding
3326 test system, such as @var{foo-test}.  The reason that you will want this
3327 separate system is that ASDF does not out of the box supply components
3328 that are conditionally loaded.  So if you want to have source files
3329 (with the test definitions) that will not be loaded except when testing,
3330 they should be put elsewhere.
3331
3332 @item
3333 The @var{foo-test} system can be defined in an asd file of its own or
3334 together with @var{foo}.  An aesthetic preference against cluttering up
3335 the filesystem with extra asd files should be balanced against the
3336 question of whether one might want to directly load @var{foo-test}.
3337 Typically one would not want to do this except in early stages of
3338 debugging.
3339
3340 @item
3341 Record that testing is implemented by @var{foo-test}.  For example:
3342 @example
3343 (defsystem @var{foo}
3344    :in-order-to ((test-op (test-op @var{foo-test})))
3345    ....)
3346
3347 (defsystem @var{foo-test}
3348    :depends-on (@var{foo} @var{my-test-library} ...)
3349    ....)
3350 @end example
3351 @end itemize
3352
3353 This procedure will allow you to support users who do not wish to
3354 install your test framework.
3355
3356 One oddity of ASDF is that @code{operate} (@pxref{Operations,operate})
3357 does not return a value.  So in current versions of ASDF there is no
3358 reliable programmatic means of determining whether or not a set of tests
3359 has passed, or which tests have failed.  The user must simply read the
3360 console output.  This limitation has been the subject of much
3361 discussion.
3362
3363 @subsection ``How can I cater for documentation generation in my system?''
3364
3365 The ASDF developers are currently working to add a @code{doc-op}
3366 to the set of predefined ASDF operations.
3367 @xref{Predefined operations of ASDF}.
3368 See also @url{https://bugs.launchpad.net/asdf/+bug/479470}.
3369
3370
3371
3372 @subsection ``How can I maintain non-Lisp (e.g. C) source files?''
3373
3374 See @code{cffi}'s @code{cffi-grovel}.
3375
3376 @anchor{report-bugs}
3377
3378
3379 @subsection ``I want to put my module's files at the top level.  How do I do this?''
3380
3381 By default, the files contained in an asdf module go
3382 in a subdirectory with the same name as the module.
3383 However, this can be overridden by adding a @code{:pathname ""} argument
3384 to the module description.
3385 For example, here is how it could be done
3386 in the spatial-trees ASDF system definition for ASDF 2:
3387
3388 @example
3389 (asdf:defsystem :spatial-trees
3390   :components
3391   ((:module base
3392             :pathname ""
3393             :components
3394             ((:file "package")
3395              (:file "basedefs" :depends-on ("package"))
3396              (:file "rectangles" :depends-on ("package"))))
3397    (:module tree-impls
3398             :depends-on (base)
3399             :pathname ""
3400             :components
3401             ((:file "r-trees")
3402              (:file "greene-trees" :depends-on ("r-trees"))
3403              (:file "rstar-trees" :depends-on ("r-trees"))
3404              (:file "rplus-trees" :depends-on ("r-trees"))
3405              (:file "x-trees" :depends-on ("r-trees" "rstar-trees"))))
3406    (:module viz
3407             :depends-on (base)
3408             :pathname ""
3409             :components
3410             ((:static-file "spatial-tree-viz.lisp")))
3411    (:module tests
3412             :depends-on (base)
3413             :pathname ""
3414             :components
3415             ((:static-file "spatial-tree-test.lisp")))
3416    (:static-file "LICENCE")
3417    (:static-file "TODO")))
3418 @end example
3419
3420 All of the files in the @code{tree-impls} module are at the top level,
3421 instead of in a @file{tree-impls/} subdirectory.
3422
3423 Note that the argument to @code{:pathname} can be either a pathname object or a string.
3424 A pathname object can be constructed with the @file{#p"foo/bar/"} syntax,
3425 but this is discouraged because the results of parsing a namestring are not portable.
3426 A pathname can only be portably constructed with such syntax as
3427 @code{#.(make-pathname :directory '(:relative "foo" "bar"))},
3428 and similarly the current directory can only be portably specified as
3429 @code{#.(make-pathname :directory '(:relative))}.
3430 However, as of ASDF 2, you can portably use a string to denote a pathname.
3431 The string will be parsed as a @code{/}-separated path from the current directory,
3432 such that the empty string @code{""} denotes the current directory, and
3433 @code{"foo/bar"} (no trailing @code{/} required in the case of modules)
3434 portably denotes the same subdirectory as above.
3435 When files are specified, the last @code{/}-separated component is interpreted
3436 either as the name component of a pathname
3437 (if the component class specifies a pathname type),
3438 or as a name component plus optional dot-separated type component
3439 (if the component class doesn't specifies a pathname type).
3440
3441 @subsection How do I create a system definition where all the source files have a .cl extension?
3442
3443 Starting with ASDF 2.014.14, you may just pass
3444 the builtin class @code{cl-source-file.cl} as
3445 the @code{:default-component-class} argument to @code{defsystem}:
3446
3447 @lisp
3448 (defsystem my-cl-system
3449   :default-component-class cl-source-file.cl
3450   ...)
3451 @end lisp
3452
3453 Another builtin class @code{cl-source-file.lsp} is offered
3454 for files ending in @file{.lsp}.
3455
3456 If you want to use a different extension
3457 for which ASDF doesn't provide builtin support,
3458 or want to support versions of ASDF
3459 earlier than 2.014.14 (but later than 2.000),
3460 you can define a class as follows:
3461
3462 @lisp
3463 ;; Prologue: make sure we're using a sane package.
3464 (defpackage :my-asdf-extension
3465    (:use :asdf :common-lisp)
3466    (:export #:cl-source-file.lis))
3467 (in-package :my-asdf-extension)
3468
3469 (defclass cl-source-file.lis (cl-source-file)
3470    ((type :initform "lis")))
3471 @end lisp
3472
3473 Then you can use it as follows:
3474 @lisp
3475 (defsystem my-cl-system
3476   :default-component-class my-asdf-extension:cl-source-file.lis
3477   ...)
3478 @end lisp
3479
3480 Of course, if you're in the same package, e.g. in the same file,
3481 you won't need to use the package qualifier before @code{cl-source-file.lis}.
3482 Actually, if all you're doing is defining this class
3483 and using it in the same file without other fancy definitions,
3484 you might skip package complications:
3485
3486 @lisp
3487 (in-package :asdf)
3488 (defclass cl-source-file.lis (cl-source-file)
3489    ((type :initform "lis")))
3490 (defsystem my-cl-system
3491   :default-component-class cl-source-file.lis
3492   ...)
3493 @end lisp
3494
3495 It is possible to achieve the same effect
3496 in a way that supports both ASDF 1 and ASDF 2,
3497 but really, friends don't let friends use ASDF 1.
3498 Please upgrade to ASDF 2.
3499 In short, though: do same as above, but
3500 @emph{before} you use the class in a @code{defsystem},
3501 you also define the following method:
3502
3503 @lisp
3504 (defmethod source-file-type ((f cl-source-file.lis) (m module))
3505   (declare (ignorable f m))
3506   "lis")
3507 @end lisp
3508
3509
3510 @node  TODO list, Inspiration, FAQ, Top
3511 @comment  node-name,  next,  previous,  up
3512 @chapter TODO list
3513
3514 Here is an old list of things to do,
3515 in addition to the bugs that are now tracked on launchpad:
3516 @url{https://launchpad.net/asdf}.
3517
3518 @section Outstanding spec questions, things to add
3519
3520 ** packaging systems
3521
3522 *** manual page component?
3523
3524 ** style guide for .asd files
3525
3526 You should either use keywords or be careful
3527 with the package that you evaluate defsystem forms in.
3528 Otherwise @code{(defsystem partition ...)}
3529 being read in the @code{cl-user} package
3530 will intern a @code{cl-user:partition} symbol,
3531 which will then collide with the @code{partition:partition} symbol.
3532
3533 Actually there's a hairier packages problem to think about too.
3534 @code{in-order-to} is not a keyword:
3535 if you read @code{defsystem} forms in a package that doesn't use ASDF,
3536 odd things might happen.
3537
3538
3539 ** extending defsystem with new options
3540
3541 You might not want to write a whole parser,
3542 but just to add options to the existing syntax.
3543 Reinstate @code{parse-option} or something akin.
3544
3545
3546 ** document all the error classes
3547
3548 ** what to do with compile-file failure
3549
3550 Should check the primary return value from compile-file and see if
3551 that gets us any closer to a sensible error handling strategy
3552
3553 ** foreign files
3554
3555 lift unix-dso stuff from db-sockets
3556
3557 ** Diagnostics
3558
3559 A ``dry run'' of an operation can be made with the following form:
3560
3561 @lisp
3562 (traverse (make-instance '<operation-name>)
3563           (find-system <system-name>)
3564           'explain)
3565 @end lisp
3566
3567 This uses unexported symbols.
3568 What would be a nice interface for this functionality?
3569
3570 @section Missing bits in implementation
3571
3572 ** reuse the same scratch package whenever a system is reloaded from disk
3573
3574 ** proclamations probably aren't
3575
3576 ** when a system is reloaded with fewer components than it previously had, odd things happen
3577
3578 We should do something inventive when processing a @code{defsystem} form,
3579 like take the list of kids and @code{setf} the slot to @code{nil},
3580 then transfer children from old to new list as they're found.
3581
3582 ** (stuff that might happen later)
3583
3584 *** Propagation of the @code{:force} option.
3585
3586 ``I notice that
3587
3588         @code{(asdf:compile-system :araneida :force t)}
3589
3590 also forces compilation of every other system the @code{:araneida} system depends on.
3591 This is rarely useful to me;
3592 usually, when I want to force recompilation of something more than a single source file,
3593 I want to recompile only one system.
3594 So it would be more useful to have @code{make-sub-operation}
3595 refuse to propagate @code{:force t} to other systems, and
3596 propagate only something like @code{:force :recursively}.
3597
3598 Ideally what we actually want is some kind of criterion that says
3599 to which systems (and which operations) a @code{:force} switch will propagate.
3600
3601 The problem is perhaps that ``force'' is a pretty meaningless concept.
3602 How obvious is it that @code{load :force t} should force @emph{compilation}?
3603 But we don't really have the right dependency setup
3604 for the user to compile @code{:force t} and expect it to work
3605 (files will not be loaded after compilation, so the compile
3606 environment for subsequent files will be emptier than it needs to be)
3607
3608 What does the user actually want to do when he forces?
3609 Usually, for me, update for use with a new version of the Lisp compiler.
3610 Perhaps for recovery when he suspects that something has gone wrong.
3611 Or else when he's changed compilation options or configuration
3612 in some way that's not reflected in the dependency graph.
3613
3614 Other possible interface: have a ``revert'' function akin to @code{make clean}.
3615
3616 @lisp
3617 (asdf:revert 'asdf:compile-op 'araneida)
3618 @end lisp
3619
3620 would delete any files produced by @code{(compile-system :araneida)}.
3621 Of course, it wouldn't be able to do much about stuff in the image itself.
3622
3623 How would this work?
3624
3625 @code{traverse}
3626
3627 There's a difference between a module's dependencies (peers)
3628 and its components (children).
3629 Perhaps there's a similar difference in operations?
3630 For example, @code{(load "use") depends-on (load "macros")} is a peer,
3631 whereas @code{(load "use") depends-on (compile "use")}
3632 is more of a ``subservient'' relationship.
3633
3634 @node  Inspiration, Concept Index, TODO list, Top
3635 @comment  node-name,  next,  previous,  up
3636 @chapter Inspiration
3637
3638 @section mk-defsystem (defsystem-3.x)
3639
3640 We aim to solve basically the same problems as @code{mk-defsystem} does.
3641 However, our architecture for extensibility
3642 better exploits CL language features (and is documented),
3643 and we intend to be portable rather than just widely-ported.
3644 No slight on the @code{mk-defsystem} authors and maintainers is intended here;
3645 that implementation has the unenviable task
3646 of supporting pre-ANSI implementations, which is no longer necessary.
3647
3648 The surface defsystem syntax of asdf is more-or-less compatible with
3649 @code{mk-defsystem}, except that we do not support
3650 the @code{source-foo} and @code{binary-foo} prefixes
3651 for separating source and binary files, and
3652 we advise the removal of all options to specify pathnames.
3653
3654 The @code{mk-defsystem} code for topologically sorting
3655 a module's dependency list was very useful.
3656
3657 @section defsystem-4 proposal
3658
3659 Marco and Peter's proposal for defsystem 4 served as the driver for
3660 many of the features in here.  Notable differences are:
3661
3662 @itemize
3663 @item
3664 We don't specify output files or output file extensions
3665 as part of the system.
3666
3667 If you want to find out what files an operation would create,
3668 ask the operation.
3669
3670 @item
3671 We don't deal with CL packages
3672
3673 If you want to compile in a particular package, use an @code{in-package} form
3674 in that file (ilisp / SLIME will like you more if you do this anyway)
3675
3676 @item
3677 There is no proposal here that @code{defsystem} does version control.
3678
3679 A system has a given version which can be used to check dependencies,
3680 but that's all.
3681 @end itemize
3682
3683 The defsystem 4 proposal tends to look more at the external features,
3684 whereas this one centres on a protocol for system introspection.
3685
3686 @section kmp's ``The Description of Large Systems'', MIT AI Memo 801
3687
3688 Available in updated-for-CL form on the web at
3689 @url{http://nhplace.com/kent/Papers/Large-Systems.html}
3690
3691 In our implementation we borrow kmp's overall @code{PROCESS-OPTIONS}
3692 and concept to deal with creating component trees
3693 from @code{defsystem} surface syntax.
3694 [ this is not true right now, though it used to be and
3695 probably will be again soon ]
3696
3697
3698 @c -------------------
3699
3700
3701 @node Concept Index, Function and Class Index, Inspiration, Top
3702 @unnumbered Concept Index
3703
3704 @printindex cp
3705
3706 @node Function and Class Index, Variable Index, Concept Index, Top
3707 @unnumbered Function and Class Index
3708
3709 @printindex fn
3710
3711 @node Variable Index,  , Function and Class Index, Top
3712 @unnumbered Variable Index
3713
3714 @printindex vr
3715
3716 @bye