1 \input texinfo @c -*- texinfo -*-
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
26 @dircategory Software development
28 * asdf: (asdf). Another System Definition Facility (for Common Lisp)
32 This manual describes ASDF, a system definition facility
33 for Common Lisp programs and libraries.
35 You can find the latest version of this manual at
36 @url{http://common-lisp.net/project/asdf/asdf.html}.
38 ASDF Copyright @copyright{} 2001-2010 Daniel Barlow and contributors.
40 This manual Copyright @copyright{} 2001-2010 Daniel Barlow and contributors.
42 This manual revised @copyright{} 2009-2010 Robert P. Goldman and Francois-Rene Rideau.
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:
52 The above copyright notice and this permission notice shall be
53 included in all copies or substantial portions of the Software.
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.
68 @title ASDF: Another System Definition Facility
70 @c The following two commands start the copyright page.
72 @vskip 0pt plus 1filll
76 @c Output the table of contents at the beginning.
79 @c -------------------
83 @node Top, Introduction, (dir), (dir)
84 @top asdf: another system definition facility
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::
98 * Miscellaneous additional functionality::
99 * Getting the latest version::
104 * Function and Class Index::
108 @c --- The Detailed Node Listing ---
110 @c Defining systems with defsystem
112 @c * The defsystem form::
113 @c * A more involved example::
114 @c * The defsystem grammar::
115 @c * Other code in .asd files::
117 @c The object model of ASDF
124 @c * Predefined operations of ASDF::
125 @c * Creating new operations::
129 @c * Common attributes of components::
130 @c * Pre-defined subclasses of component::
131 @c * Creating new component types::
135 @c * Pre-defined subclasses of component::
136 @c * Creating new component types::
143 @c -------------------
145 @node Introduction, Loading ASDF, Top, Top
146 @comment node-name, next, previous, up
147 @chapter Introduction
148 @cindex ASDF-related features
150 @cindex Testing for ASDF
151 @cindex ASDF versions
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.
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.
173 We have released ASDF 2.000 on May 31st 2010.
174 It hopefully will have been it included
175 in all CL maintained implementations shortly afterwards.
176 @xref{FAQ,,``What has changed between ASDF 1 and ASDF 2?''}.
179 @node Loading ASDF, Configuring ASDF, Introduction, Top
180 @comment node-name, next, previous, up
181 @chapter Loading ASDF
182 @vindex *central-registry*
185 @findex compile-system
187 @cindex system directory designator
192 @c * Installing ASDF::
196 @section Loading a pre-installed ASDF
198 Many Lisp implementations include a copy of ASDF.
199 You can usually load this copy using Common Lisp's @code{require} function:
205 Consult your Lisp implementation's documentation for details.
207 Hopefully, ASDF 2 will soon be bundled with every Common Lisp implementation,
208 and you can load it that way.
209 If it is not, see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below.
210 if you are using the latest version of your Lisp vendor's software,
211 you may also send a bug report to your Lisp vendor and complain about
212 their failing to provide ASDF.
214 @section Checking whether ASDF is loaded
216 To check whether ASDF is properly loaded in your current Lisp image,
217 you can run this form:
223 If it returns a string,
224 that is the version of ASDF that is currently installed.
226 If it raises an error,
227 then either ASDF is not loaded, or
228 you are using an old version of ASDF.
230 You can check whether an old version is loaded
231 by checking if the ASDF package is present.
232 The form below will allow you to programmatically determine
233 whether a recent version is loaded, an old version is loaded,
237 (or #+asdf2 (asdf:asdf-version) #+asdf :old)
240 If it returns a version number, that's the version of ASDF installed.
241 If it returns the keyword @code{:OLD},
242 then you're using an old version of ASDF (from before 1.635).
243 If it returns @code{NIL} then ASDF is not installed.
245 If you are running a version older than 2.008,
246 we recommend that you load a newer ASDF using the method below.
249 @section Upgrading ASDF
251 If your implementation does provide ASDF 2 or later,
252 and you want to upgrade to a more recent version,
253 just install ASDF like any other package
254 (see @pxref{Loading ASDF,,Loading an otherwise installed ASDF} below),
255 configure ASDF as usual (see @pxref{Configuring ASDF} below),
260 (asdf:load-system :asdf)
263 If on the other hand, your implementation only provides an old ASDF,
264 you will require a special configuration step and an old-style loading:
268 (push #p"@var{/path/to/new/asdf/}" asdf:*central-registry*)
269 (asdf:oos 'asdf:load-op :asdf)
272 Don't forget the trailing @code{/} at the end of your pathname.
274 Also, note that older versions of ASDF won't redirect their output,
275 or at least won't do it according to your usual ASDF 2 configuration.
276 You therefore need write access on the directory
277 where you install the new ASDF,
278 and make sure you're not using it
279 for multiple mutually incompatible implementations.
280 At worst, you may have to have multiple copies of the new ASDF,
281 e.g. one per implementation installation, to avoid clashes.
283 Finally, note that there are some limitations to upgrading ASDF:
286 Any ASDF extension is invalidated, and will need to be reloaded.
288 It is safer if you upgrade ASDF and its extensions as a special step
289 at the very beginning of whatever script you are running,
290 before you start using ASDF to load anything else.
294 @section Loading an otherwise installed ASDF
296 If your implementation doesn't include ASDF,
297 if for some reason the upgrade somehow fails,
298 does not or cannot apply to your case,
299 you will have to install the file @file{asdf.lisp}
300 somewhere and load it with:
303 (load "/path/to/your/installed/asdf.lisp")
306 The single file @file{asdf.lisp} is all you normally need to use ASDF.
308 You can extract this file from latest release tarball on the
309 @url{http://common-lisp.net/project/asdf/,ASDF website}.
310 If you are daring and willing to report bugs, you can get
311 the latest and greatest version of ASDF from its git repository.
312 @xref{Getting the latest version}.
314 For maximum convenience you might want to have ASDF loaded
315 whenever you start your Lisp implementation,
316 for example by loading it from the startup script or dumping a custom core
317 --- check your Lisp implementation's manual for details.
320 @node Configuring ASDF, Using ASDF, Loading ASDF, Top
321 @comment node-name, next, previous, up
323 @chapter Configuring ASDF
325 @section Configuring ASDF to find your systems
327 So it may compile and load your systems, ASDF must be configured to find
328 the @file{.asd} files that contain system definitions.
330 Since ASDF 2, the preferred way to configure where ASDF finds your systems is
331 the @code{source-registry} facility,
332 fully described in its own chapter of this manual.
333 @xref{Controlling where ASDF searches for systems}.
335 The default location for a user to install Common Lisp software is under
336 @file{~/.local/share/common-lisp/source/}.
337 If you install software there, you don't need further configuration.
338 If you're installing software yourself at a location that isn't standard,
339 you have to tell ASDF where you installed it. See below.
340 If you're using some tool to install software,
341 the authors of that tool should already have configured ASDF.
343 The simplest way to add a path to your search path,
344 say @file{/home/luser/.asd-link-farm/}
345 is to create the directory
346 @file{~/.config/common-lisp/source-registry.conf.d/}
347 and there create a file with any name of your choice but the type @file{conf},
348 for instance @file{42-asd-link-farm.conf}
351 @kbd{(:directory "/home/luser/.asd-link-farm/")}
353 If you want all the subdirectories under @file{/home/luser/lisp/}
354 to be recursively scanned for @file{.asd} files, instead use:
356 @kbd{(:tree "/home/luser/lisp/")}
358 Note that your Operating System distribution or your system administrator
359 may already have configured system-managed libraries for you.
361 The required @file{.conf} extension allows you to have disabled files
362 or editor backups (ending in @file{~}), and works portably
363 (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
364 Excluded are files the name of which start with a @file{.} character.
365 It is customary to start the filename with two digits
366 that specify the order in which the directories will be scanned.
368 ASDF will automatically read your configuration
369 the first time you try to find a system.
370 You can reset the source-registry configuration with:
373 (asdf:clear-source-registry)
376 And you probably should do so before you dump your Lisp image,
377 if the configuration may change
378 between the machine where you save it at the time you save it
379 and the machine you resume it at the time you resume it.
382 @section Configuring ASDF to find your systems -- old style
384 The old way to configure ASDF to find your systems is by
385 @code{push}ing directory pathnames onto the variable
386 @code{asdf:*central-registry*}.
388 You must configure this variable between the time you load ASDF
389 and the time you first try to use it.
390 Loading and configuring ASDF presumably happen
391 as part of some initialization script that builds or starts
392 your Common Lisp software system.
393 (For instance, some SBCL users used to put it in their @file{~/.sbclrc}.)
395 The @code{asdf:*central-registry*} is empty by default in ASDF 2,
396 but is still supported for compatibility with ASDF 1.
397 When used, it takes precedence over the above source-registry@footnote{
398 It is possible to further customize
399 the system definition file search.
400 That's considered advanced use, and covered later:
402 @code{*system-definition-search-functions*}.
403 @xref{Defining systems with defsystem}.}.
405 For instance, if you wanted ASDF to find the @file{.asd} file
406 @file{/home/me/src/foo/foo.asd} your initialization script
407 could after it loads ASDF with @code{(require :asdf)}
411 (push "/home/me/src/foo/" asdf:*central-registry*)
414 Note the trailing slash: when searching for a system,
415 ASDF will evaluate each entry of the central registry
416 and coerce the result to a pathname@footnote{
417 ASDF will indeed call @code{EVAL} on each entry.
418 It will also skip entries that evaluate to @code{NIL}.
420 Strings and pathname objects are self-evaluating,
421 in which case the @code{EVAL} step does nothing;
422 but you may push arbitrary SEXP onto the central registry,
423 that will be evaluated to compute e.g. things that depend
424 on the value of shell variables or the identity of the user.
426 The variable @code{asdf:*central-registry*} is thus a list of
427 ``system directory designators''.
428 A @dfn{system directory designator} is a form
429 which will be evaluated whenever a system is to be found,
430 and must evaluate to a directory to look in.
431 By ``directory'' here, we mean
432 ``designator for a pathname with a supplied DIRECTORY component''.
434 at which point the presence of the trailing directory name separator
435 is necessary to tell Lisp that you're discussing a directory
438 Typically, however, there are a lot of @file{.asd} files, and
439 a common idiom was to have to put
440 a bunch of @emph{symbolic links} to @file{.asd} files
441 in a common directory
442 and push @emph{that} directory (the ``link farm'')
444 @code{asdf:*central-registry*}
445 instead of pushing each of the many involved directories
446 to the @code{asdf:*central-registry*}.
447 ASDF knows how to follow such @emph{symlinks}
448 to the actual file location when resolving the paths of system components
449 (on Windows, you can use Windows shortcuts instead of POSIX symlinks).
451 For example, if @code{#p"/home/me/cl/systems/"} (note the trailing slash)
452 is a member of @code{*central-registry*}, you could set up the
453 system @var{foo} for loading with asdf with the following
454 commands at the shell:
457 $ cd /home/me/cl/systems/
458 $ ln -s ~/src/foo/foo.asd .
461 This old style for configuring ASDF is not recommended for new users,
462 but it is supported for old users, and for users who want to programmatically
463 control what directories are added to the ASDF search path.
466 @section Configuring where ASDF stores object files
467 @findex clear-output-locations
469 ASDF lets you configure where object files will be stored.
470 Sensible defaults are provided and
471 you shouldn't normally have to worry about it.
473 This allows the same source code repository may be shared
474 between several versions of several Common Lisp implementations,
475 between several users using different compilation options
476 and without write privileges on shared source directories, etc.
477 This also allows to keep source directories uncluttered
478 by plenty of object files.
480 Starting with ASDF 2, the @code{asdf-output-translations} facility
481 was added to ASDF itself, that controls where object files will be stored.
482 This facility is fully described in a chapter of this manual,
483 @ref{Controlling where ASDF saves compiled files}.
485 The simplest way to add a translation to your search path,
486 say from @file{/foo/bar/baz/quux/}
487 to @file{/where/i/want/my/fasls/}
488 is to create the directory
489 @file{~/.config/common-lisp/asdf-output-translations.conf.d/}
490 and there create a file with any name of your choice and the type @file{conf},
491 for instance @file{42-bazquux.conf}
494 @kbd{("/foo/bar/baz/quux/" "/where/i/want/my/fasls/")}
496 To disable output translations for source under a given directory,
497 say @file{/toto/tata/}
498 you can create a file @file{40-disable-toto.conf}
501 @kbd{("/toto/tata/")}
503 To wholly disable output translations for all directories,
504 you can create a file @file{00-disable.conf}
509 Note that your Operating System distribution or your system administrator
510 may already have configured translations for you.
511 In absence of any configuration, the default is to redirect everything
512 under an implementation-dependent subdirectory of @file{~/.cache/common-lisp/}.
513 @xref{Controlling where ASDF searches for systems}, for full details.
515 The required @file{.conf} extension allows you to have disabled files
516 or editor backups (ending in @file{~}), and works portably
517 (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
518 Excluded are files the name of which start with a @file{.} character.
519 It is customary to start the filename with two digits
520 that specify the order in which the directories will be scanned.
522 ASDF will automatically read your configuration
523 the first time you try to find a system.
524 You can reset the source-registry configuration with:
527 (asdf:clear-output-translations)
530 And you probably should do so before you dump your Lisp image,
531 if the configuration may change
532 between the machine where you save it at the time you save it
533 and the machine you resume it at the time you resume it.
535 Finally note that before ASDF 2,
536 other ASDF add-ons offered the same functionality,
537 each in subtly different and incompatible ways:
538 ASDF-Binary-Locations, cl-launch, common-lisp-controller.
539 ASDF-Binary-Locations is now not needed anymore and should not be used.
540 cl-launch 3.000 and common-lisp-controller 7.2 have been updated
541 to just delegate this functionality to ASDF.
543 @node Using ASDF, Defining systems with defsystem, Configuring ASDF, Top
544 @comment node-name, next, previous, up
548 @section Loading a system
550 The system @var{foo} is loaded (and compiled, if necessary)
551 by evaluating the following Lisp form:
554 (asdf:load-system :@var{foo})
557 On some implementations (namely recent versions of
558 ABCL, Clozure CL, CLISP, CMUCL, ECL, SBCL and SCL),
559 ASDF hooks into the @code{CL:REQUIRE} facility
560 and you can just use:
566 In older versions of ASDF, you needed to use
567 @code{(asdf:oos 'asdf:load-op :@var{foo})}.
568 If your ASDF is too old to provide @code{asdf:load-system} though
569 we recommend that you upgrade to ASDF 2.
570 @xref{Loading ASDF,,Loading an otherwise installed ASDF}.
572 Note the name of a system is specified as a string or a symbol,
574 If a symbol (including a keyword), its name is taken and lowercased.
575 The name must be a suitable value for the @code{:name} initarg
576 to @code{make-pathname} in whatever filesystem the system is to be found.
577 The lower-casing-symbols behaviour is unconventional,
578 but was selected after some consideration.
579 Observations suggest that the type of systems we want to support
580 either have lowercase as customary case (unix, mac, windows)
581 or silently convert lowercase to uppercase (lpns),
582 so this makes more sense than attempting to use @code{:case :common},
583 which is reported not to work on some implementations
586 @section Other Operations
588 ASDF provides three commands for the most common system operations:
589 @code{load-system}, @code{compile-system} or @code{test-system}.
591 Because ASDF is an extensible system
592 for defining @emph{operations} on @emph{components},
593 it also provides a generic function @code{operate}
594 (which is usually abbreviated by @code{oos}).
595 You'll use @code{oos} whenever you want to do something beyond
596 compiling, loading and testing.
598 Output from ASDF and ASDF extensions are supposed to be sent
599 to the CL stream @code{*standard-output*},
600 and so rebinding that stream around calls to @code{asdf:operate}
601 should redirect all output from ASDF operations.
603 Reminder: before ASDF can operate on a system, however,
604 it must be able to find and load that system's definition.
605 @xref{Configuring ASDF,,Configuring ASDF to find your systems}.
614 Load ASDF itself into your Lisp image, either through
615 @code{(require :asdf)} or else through
616 @code{(load "/path/to/asdf.lisp")}.
619 Make sure ASDF can find system definitions
620 thanks to proper source-registry configuration.
623 Load a system with @code{(load-system :my-system)}
624 or use some other operation on some system of your choice.
630 That's all you need to know to use ASDF to load systems written by others.
631 The rest of this manual deals with writing system definitions
632 for Common Lisp software you write yourself,
633 including how to extend ASDF to define new operation and component types.
636 @node Defining systems with defsystem, The object model of ASDF, Using ASDF, Top
637 @comment node-name, next, previous, up
638 @chapter Defining systems with defsystem
640 This chapter describes how to use asdf to define systems and develop
645 * The defsystem form::
646 * A more involved example::
647 * The defsystem grammar::
648 * Other code in .asd files::
651 @node The defsystem form, A more involved example, Defining systems with defsystem, Defining systems with defsystem
652 @comment node-name, next, previous, up
653 @section The defsystem form
655 Systems can be constructed programmatically
656 by instantiating components using @code{make-instance}.
657 Most of the time, however, it is much more practical to use
658 a static @code{defsystem} form.
659 This section begins with an example of a system definition,
660 then gives the full grammar of @code{defsystem}.
662 Let's look at a simple system.
663 This is a complete file that would
664 usually be saved as @file{hello-lisp.asd}:
669 (defsystem "hello-lisp"
670 :description "hello-lisp: a sample Lisp system."
672 :author "Joe User <joe@@example.com>"
673 :licence "Public Domain"
674 :components ((:file "packages")
675 (:file "macros" :depends-on ("packages"))
676 (:file "hello" :depends-on ("macros"))))
679 Some notes about this example:
684 The file starts with an @code{in-package} form
685 to use package @code{asdf}.
686 You could instead start your definition by using
687 a qualified name @code{asdf:defsystem}.
690 If in addition to simply using @code{defsystem},
691 you are going to define functions,
692 create ASDF extension, globally bind symbols, etc.,
693 it is recommended that to avoid namespace pollution between systems,
694 you should create your own package for that purpose,
695 for instance replacing the above @code{(in-package :asdf)} with:
698 (defpackage :foo-system
701 (in-package :foo-system)
705 The @code{defsystem} form defines a system named @code{hello-lisp}
706 that contains three source files:
707 @file{packages}, @file{macros} and @file{hello}.
710 The file @file{macros} depends on @file{packages}
711 (presumably because the package it's in is defined in @file{packages}),
712 and the file @file{hello} depends on @file{macros}
713 (and hence, transitively on @file{packages}).
714 This means that ASDF will compile and load @file{packages} and @file{macros}
715 before starting the compilation of file @file{hello}.
718 The files are located in the same directory
719 as the file with the system definition.
720 ASDF resolves symbolic links (or Windows shortcuts)
721 before loading the system definition file and
722 stores its location in the resulting system@footnote{
723 It is possible, though almost never necessary, to override this behaviour.}.
724 This is a good thing because the user can move the system sources
725 without having to edit the system definition.
729 @node A more involved example, The defsystem grammar, The defsystem form, Defining systems with defsystem
730 @comment node-name, next, previous, up
731 @section A more involved example
733 Let's illustrate some more involved uses of @code{defsystem} via a
734 slightly convoluted example:
739 :components ((:module "mod"
740 :components ((:file "bar")
743 :perform (compile-op :after (op c)
745 :explain (compile-op :after (op c)
746 (explain-something c)))
750 The @code{:module} component named @code{"mod"} is a collection of three files,
751 which will be located in a subdirectory of the main code directory named
752 @file{mod} (this location can be overridden; see the discussion of the
753 @code{:pathname} option in @ref{The defsystem grammar}).
755 The method-form tokens provide a shorthand for defining methods on
756 particular components. This part
759 :perform (compile-op :after (op c)
761 :explain (compile-op :after (op c)
762 (explain-something c))
768 (defmethod perform :after ((op compile-op) (c (eql ...)))
770 (defmethod explain :after ((op compile-op) (c (eql ...)))
771 (explain-something c))
774 where @code{...} is the component in question.
775 In this case @code{...} would expand to something like
778 (find-component (find-system "foo") "mod")
781 For more details on the syntax of such forms, see @ref{The defsystem
783 For more details on what these methods do, @pxref{Operations} in
784 @ref{The object model of ASDF}.
786 @c The following plunge into the weeds is not appropriate in this
787 @c location. [2010/10/03:rpg]
788 @c note that although this also supports @code{:before} methods,
789 @c they may not do what you want them to ---
790 @c a @code{:before} method on perform @code{((op compile-op) (c (eql ...)))}
791 @c will run after all the dependencies and sub-components have been processed,
792 @c but before the component in question has been compiled.
794 @node The defsystem grammar, Other code in .asd files, A more involved example, Defining systems with defsystem
795 @comment node-name, next, previous, up
796 @section The defsystem grammar
799 system-definition := ( defsystem system-designator @var{option}* )
801 option := :components component-list
802 | :pathname pathname-specifier
803 | :default-component-class
804 | :perform method-form
805 | :explain method-form
806 | :output-files method-form
807 | :operation-done-p method-form
808 | :depends-on ( @var{dependency-def}* )
809 | :serial [ t | nil ]
810 | :in-order-to ( @var{dependency}+ )
812 component-list := ( @var{component-def}* )
814 component-def := ( component-type simple-component-name @var{option}* )
816 component-type := :system | :module | :file | :static-file | other-component-type
818 other-component-type := symbol-by-name (@pxref{The defsystem grammar,,Component types})
820 dependency-def := simple-component-name
822 | ( :version simple-component-name version-specifier)
824 dependency := (dependent-op @var{requirement}+)
825 requirement := (required-op @var{required-component}+)
826 | (feature feature-name)
827 dependent-op := operation-name
828 required-op := operation-name | feature
830 simple-component-name := string
833 pathname-specifier := pathname | string | symbol
835 method-form := (operation-name qual lambda-list @&rest body)
836 qual := method qualifier
839 @subsection Component names
841 Component names (@code{simple-component-name})
842 may be either strings or symbols.
844 @subsection Component types
846 Component type names, even if expressed as keywords, will be looked up
847 by name in the current package and in the asdf package, if not found in
848 the current package. So a component type @code{my-component-type}, in
849 the current package @code{my-system-asd} can be specified as
850 @code{:my-component-type}, or @code{my-component-type}.
852 @subsection Pathname specifiers
853 @cindex pathname specifiers
855 A pathname specifier (@code{pathname-specifier})
856 may be a pathname, a string or a symbol.
857 When no pathname specifier is given for a component,
858 which is the usual case, the component name itself is used.
860 If a string is given, which is the usual case,
861 the string will be interpreted as a Unix-style pathname
862 where @code{/} characters will be interpreted as directory separators.
863 Usually, Unix-style relative pathnames are used
864 (i.e. not starting with @code{/}, as opposed to absolute pathnames);
865 they are relative to the path of the parent component.
866 Finally, depending on the @code{component-type},
867 the pathname may be interpreted as either a file or a directory,
869 a file type may be added corresponding to the @code{component-type},
870 or else it will be extracted from the string itself (if applicable).
872 For instance, the @code{component-type} @code{:module}
873 wants a directory pathname, and so a string @code{"foo/bar"}
874 will be interpreted as the pathname @file{#p"foo/bar/"}.
875 On the other hand, the @code{component-type} @code{:file}
876 wants a file of type @code{lisp}, and so a string @code{"foo/bar"}
877 will be interpreted as the pathname @file{#p"foo/bar.lisp"},
878 and a string @code{"foo/bar.quux"}
879 will be interpreted as the pathname @file{#p"foo/bar.quux.lisp"}.
880 Finally, the @code{component-type} @code{:static-file}
881 wants a file without specifying a type, and so a string @code{"foo/bar"}
882 will be interpreted as the pathname @file{#p"foo/bar"},
883 and a string @code{"foo/bar.quux"}
884 will be interpreted as the pathname @file{#p"foo/bar.quux"}.
886 ASDF does not interpret the string @code{".."} to designate the parent
887 directory. This string will be passed through to the underlying
888 operating system for interpretation. We @emph{believe} that this will
889 work on all platforms where ASDF is deployed, but do not guarantee this
890 behavior. A pathname object with a relative directory component of
891 @code{:up} or @code{:back} is the only guaranteed way to specify a
894 If a symbol is given, it will be translated into a string,
895 and downcased in the process.
896 The downcasing of symbols is unconventional,
897 but was selected after some consideration.
898 Observations suggest that the type of systems we want to support
899 either have lowercase as customary case (Unix, Mac, windows)
900 or silently convert lowercase to uppercase (lpns),
901 so this makes more sense than attempting to use @code{:case :common}
902 as argument to @code{make-pathname},
903 which is reported not to work on some implementations.
905 Pathname objects may be given to override the path for a component.
906 Such objects are typically specified using reader macros such as @code{#p}
907 or @code{#.(make-pathname ...)}.
908 Note however, that @code{#p...} is a shorthand for @code{#.(parse-namestring ...)}
909 and that the behavior of @code{parse-namestring} is completely non-portable,
910 unless you are using Common Lisp @code{logical-pathname}s
911 (@pxref{The defsystem grammar,,Warning about logical pathnames}, below).
912 Pathnames made with @code{#.(make-pathname ...)}
913 can usually be done more easily with the string syntax above.
914 The only case that you really need a pathname object is to override
915 the component-type default file type for a given component.
916 Therefore, pathname objects should only rarely be used.
917 Unhappily, ASDF 1 didn't properly support
918 parsing component names as strings specifying paths with directories,
919 and the cumbersome @code{#.(make-pathname ...)} syntax had to be used.
921 Note that when specifying pathname objects,
922 ASDF does not do any special interpretation of the pathname
923 influenced by the component type, unlike the procedure for
924 pathname-specifying strings.
925 On the one hand, you have to be careful to provide a pathname that correctly
926 fulfills whatever constraints are required from that component type
927 (e.g. naming a directory or a file with appropriate type);
928 on the other hand, you can circumvent the file type that would otherwise
929 be forced upon you if you were specifying a string.
932 @subsection Warning about logical pathnames
933 @cindex logical pathnames
935 We recommend that you not use logical pathnames
936 in your asdf system definitions at this point,
937 but logical pathnames @emph{are} supported.
939 To use logical pathnames,
940 you will have to provide a pathname object as a @code{:pathname} specifier
941 to components that use it, using such syntax as
942 @code{#p"LOGICAL-HOST:absolute;path;to;component.lisp"}.
944 You only have to specify such logical pathname for your system or
945 some top-level component. Sub-components' relative pathnames, specified
946 using the string syntax
947 for names, will be properly merged with the pathnames of their parents.
948 The specification of a logical pathname host however is @emph{not}
949 otherwise directly supported in the ASDF syntax
950 for pathname specifiers as strings.
952 The @code{asdf-output-translation} layer will
953 avoid trying to resolve and translate logical-pathnames.
954 The advantage of this is that you can define yourself what translations you want to use
955 with the logical pathname facility.
956 The disadvantage is that if you do not define such translations, any
957 system that uses logical pathnames will behave differently under
958 asdf-output-translations than other systems you use.
960 If you wish to use logical pathnames you will have to configure the
961 translations yourself before they may be used.
962 ASDF currently provides no specific support
963 for defining logical pathname translations.
966 @subsection Serial dependencies
967 @cindex serial dependencies
969 If the @code{:serial t} option is specified for a module,
970 ASDF will add dependencies for each child component,
971 on all the children textually preceding it.
972 This is done as if by @code{:depends-on}.
976 :components ((:file "a") (:file "b") (:file "c"))
982 :components ((:file "a")
983 (:file "b" :depends-on ("a"))
984 (:file "c" :depends-on ("a" "b")))
988 @subsection Source location
990 The @code{:pathname} option is optional in all cases for systems
991 defined via @code{defsystem},
992 and in the usual case the user is recommended not to supply it.
994 Instead, ASDF follows a hairy set of rules that are designed so that
998 will load a system from disk
999 and have its pathname default to the right place.
1001 This pathname information will not be overwritten with
1002 @code{*default-pathname-defaults*}
1003 (which could be somewhere else altogether)
1004 if the user loads up the @file{.asd} file into his editor
1005 and interactively re-evaluates that form.
1008 If a system is being loaded for the first time,
1009 its top-level pathname will be set to:
1013 The host/device/directory parts of @code{*load-truename*},
1016 @code{*default-pathname-defaults*}, otherwise.
1019 If a system is being redefined, the top-level pathname will be
1023 changed, if explicitly supplied or obtained from @code{*load-truename*}
1024 (so that an updated source location is reflected in the system definition)
1026 changed if it had previously been set from @code{*default-pathname-defaults*}
1028 left as before, if it had previously been set from @code{*load-truename*}
1029 and @code{*load-truename*} is currently unbound
1030 (so that a developer can evaluate a @code{defsystem} form
1031 from within an editor without clobbering its source location)
1034 @node Other code in .asd files, , The defsystem grammar, Defining systems with defsystem
1035 @section Other code in .asd files
1037 Files containing @code{defsystem} forms
1038 are regular Lisp files that are executed by @code{load}.
1039 Consequently, you can put whatever Lisp code you like into these files
1040 (e.g., code that examines the compile-time environment
1041 and adds appropriate features to @code{*features*}).
1042 However, some conventions should be followed,
1043 so that users can control certain details of execution
1044 of the Lisp in @file{.asd} files:
1048 Any informative output
1049 (other than warnings and errors,
1050 which are the condition system's to dispose of)
1051 should be sent to the standard CL stream @code{*standard-output*},
1052 so that users can easily control the disposition
1053 of output from ASDF operations.
1057 @node The object model of ASDF, Controlling where ASDF searches for systems, Defining systems with defsystem, Top
1058 @comment node-name, next, previous, up
1059 @chapter The object model of ASDF
1061 ASDF is designed in an object-oriented way from the ground up.
1062 Both a system's structure and the operations that can be performed on systems
1064 ASDF is extensible to new operations and to new component types.
1065 This allows the addition of behaviours:
1066 for example, a new component could be added for Java JAR archives,
1067 and methods specialised on @code{compile-op} added for it
1068 that would accomplish the relevant actions.
1070 This chapter deals with @emph{components}, the building blocks of a system,
1071 and @emph{operations}, the actions that can be performed on a system.
1080 @node Operations, Components, The object model of ASDF, The object model of ASDF
1081 @comment node-name, next, previous, up
1085 An @dfn{operation} object of the appropriate type is instantiated
1086 whenever the user wants to do something with a system like
1089 @item compile all its files
1090 @item load the files into a running lisp environment
1091 @item copy its source files somewhere else
1094 Operations can be invoked directly, or examined
1095 to see what their effects would be without performing them.
1096 @emph{FIXME: document how!}
1097 There are a bunch of methods specialised on operation and component type
1098 that actually do the grunt work.
1100 The operation object contains whatever state is relevant for this purpose
1101 (perhaps a list of visited nodes, for example)
1102 but primarily is a nice thing to specialise operation methods on
1103 and easier than having them all be @code{EQL} methods.
1105 Operations are invoked on systems via @code{operate}.
1107 @deffn {Generic function} @code{operate} @var{operation} @var{system} @&rest @var{initargs}
1108 @deffnx {Generic function} @code{oos} @var{operation} @var{system} @&rest @var{initargs}
1109 @code{operate} invokes @var{operation} on @var{system}.
1110 @code{oos} is a synonym for @code{operate}.
1112 @var{operation} is a symbol that is passed, along with the supplied
1113 @var{initargs}, to @code{make-instance} to create the operation object.
1114 @var{system} is a system designator.
1116 The @var{initargs} are passed to the @code{make-instance} call
1117 when creating the operation object.
1118 Note that dependencies may cause the operation
1119 to invoke other operations on the system or its components:
1120 the new operations will be created
1121 with the same @var{initargs} as the original one.
1126 * Predefined operations of ASDF::
1127 * Creating new operations::
1130 @node Predefined operations of ASDF, Creating new operations, Operations, Operations
1131 @comment node-name, next, previous, up
1132 @subsection Predefined operations of ASDF
1134 All the operations described in this section are in the @code{asdf} package.
1135 They are invoked via the @code{operate} generic function.
1138 (asdf:operate 'asdf:@var{operation-name} :@var{system-name} @{@var{operation-options ...}@})
1141 @deffn Operation @code{compile-op} @&key @code{proclamations}
1143 This operation compiles the specified component.
1144 If proclamations are supplied, they will be proclaimed.
1145 This is a good place to specify optimization settings.
1147 When creating a new component type,
1148 you should provide methods for @code{compile-op}.
1150 When @code{compile-op} is invoked,
1151 component dependencies often cause some parts of the system
1152 to be loaded as well as compiled.
1153 Invoking @code{compile-op}
1154 does not necessarily load all the parts of the system, though;
1155 use @code{load-op} to load a system.
1158 @deffn Operation @code{load-op} @&key @code{proclamations}
1160 This operation loads a system.
1162 The default methods for @code{load-op} compile files before loading them.
1163 For parity, your own methods on new component types should probably do so too.
1166 @deffn Operation @code{load-source-op}
1168 This operation will load the source for the files in a module
1169 even if the source files have been compiled.
1170 Systems sometimes have knotty dependencies
1171 which require that sources are loaded
1172 before they can be compiled.
1173 This is how you do that.
1175 If you are creating a component type,
1176 you need to implement this operation --- at least, where meaningful.
1180 @deffn Operation @code{test-op}
1182 This operation will perform some tests on the module.
1183 The default method will do nothing.
1184 The default dependency is to require
1185 @code{load-op} to be performed on the module first.
1186 The default @code{operation-done-p} is that the operation is @emph{never} done
1188 we assume that if you invoke the @code{test-op},
1189 you want to test the system, even if you have already done so.
1191 The results of this operation are not defined by ASDF.
1192 It has proven difficult to define how the test operation
1193 should signal its results to the user
1194 in a way that is compatible with all of the various test libraries
1195 and test techniques in use in the community.
1198 @c @deffn Operation test-system-version @&key minimum
1200 @c Asks the system whether it satisfies a version requirement.
1202 @c The default method accepts a string, which is expected to contain of a
1203 @c number of integers separated by #\. characters. The method is not
1204 @c recursive. The component satisfies the version dependency if it has
1205 @c the same major number as required and each of its sub-versions is
1206 @c greater than or equal to the sub-version number required.
1209 @c (defun version-satisfies (x y)
1210 @c (labels ((bigger (x y)
1211 @c (cond ((not y) t)
1213 @c ((> (car x) (car y)) t)
1214 @c ((= (car x) (car y))
1215 @c (bigger (cdr x) (cdr y))))))
1216 @c (and (= (car x) (car y))
1217 @c (or (not (cdr y)) (bigger (cdr x) (cdr y))))))
1220 @c If that doesn't work for your system, you can override it. I hope
1221 @c you have as much fun writing the new method as @verb{|#lisp|} did
1222 @c reimplementing this one.
1225 @c @deffn Operation feature-dependent-op
1227 @c An instance of @code{feature-dependent-op} will ignore any components
1228 @c which have a @code{features} attribute, unless the feature combination
1229 @c it designates is satisfied by @code{*features*}. This operation is
1230 @c not intended to be instantiated directly, but other operations may
1235 @node Creating new operations, , Predefined operations of ASDF, Operations
1236 @comment node-name, next, previous, up
1237 @subsection Creating new operations
1239 ASDF was designed to be extensible in an object-oriented fashion.
1240 To teach ASDF new tricks, a programmer can implement the behaviour he wants
1241 by creating a subclass of @code{operation}.
1243 ASDF's pre-defined operations are in no way ``privileged'',
1244 but it is requested that developers never use the @code{asdf} package
1245 for operations they develop themselves.
1246 The rationale for this rule is that we don't want to establish a
1247 ``global asdf operation name registry'',
1248 but also want to avoid name clashes.
1250 An operation must provide methods for the following generic functions
1251 when invoked with an object of type @code{source-file}:
1252 @emph{FIXME describe this better}
1256 @item @code{output-files}
1257 The @code{output-files} method determines where the method will put its files.
1258 It returns two values, a list of pathnames, and a boolean.
1259 If the boolean is @code{T} then the pathnames are marked
1260 not be translated by enclosing @code{:around} methods.
1261 If the boolean is @code{NIL} then enclosing @code{:around} methods
1262 may translate these pathnames, e.g. to ensure object files
1263 are somehow stored in some implementation-dependent cache.
1264 @item @code{perform}
1265 The @code{perform} method must call @code{output-files}
1266 to find out where to put its files,
1267 because the user is allowed to override.
1268 @item @code{output-files}
1269 for local policy @code{explain}
1270 @item @code{operation-done-p},
1271 if you don't like the default one
1275 Operations that print output should send that output to the standard
1276 CL stream @code{*standard-output*}, as the Lisp compiler and loader do.
1278 @node Components, , Operations, The object model of ASDF
1279 @comment node-name, next, previous, up
1283 @cindex system designator
1284 @vindex *system-definition-search-functions*
1286 A @dfn{component} represents a source file or
1287 (recursively) a collection of components.
1288 A @dfn{system} is (roughly speaking) a top-level component
1289 that can be found via @code{find-system}.
1291 A @dfn{system designator} is a string or symbol
1292 and behaves just like any other component name
1293 (including with regard to the case conversion rules for component names).
1296 @defun find-system system-designator &optional (error-p t)
1298 Given a system designator, @code{find-system} finds and returns a system.
1299 If no system is found, an error of type
1300 @code{missing-component} is thrown,
1301 or @code{nil} is returned if @code{error-p} is false.
1303 To find and update systems, @code{find-system} funcalls each element
1304 in the @code{*system-definition-search-functions*} list,
1305 expecting a pathname to be returned.
1306 The resulting pathname is loaded if either of the following conditions is true:
1310 there is no system of that name in memory
1312 the file's @code{last-modified} time exceeds the @code{last-modified} time
1313 of the system in memory
1316 When system definitions are loaded from @file{.asd} files,
1317 a new scratch package is created for them to load into,
1318 so that different systems do not overwrite each others operations.
1319 The user may also wish to (and is recommended to)
1320 include @code{defpackage} and @code{in-package} forms
1321 in his system definition files, however,
1322 so that they can be loaded manually if need be.
1324 The default value of @code{*system-definition-search-functions*}
1325 is a list of two functions.
1326 The first function looks in each of the directories given
1327 by evaluating members of @code{*central-registry*}
1328 for a file whose name is the name of the system and whose type is @file{asd}.
1329 The first such file is returned,
1330 whether or not it turns out to actually define the appropriate system.
1331 The second function does something similar,
1332 for the directories specified in the @code{source-registry}.
1333 Hence, it is strongly advised to define a system
1334 @var{foo} in the corresponding file @var{foo.asd}.
1339 * Common attributes of components::
1340 * Pre-defined subclasses of component::
1341 * Creating new component types::
1344 @node Common attributes of components, Pre-defined subclasses of component, Components, Components
1345 @comment node-name, next, previous, up
1346 @subsection Common attributes of components
1348 All components, regardless of type, have the following attributes.
1349 All attributes except @code{name} are optional.
1353 A component name is a string or a symbol.
1354 If a symbol, its name is taken and lowercased.
1356 Unless overridden by a @code{:pathname} attribute,
1357 the name will be interpreted as a pathname specifier according
1358 to a Unix-style syntax.
1359 @xref{The defsystem grammar,,Pathname specifiers}.
1361 @subsubsection Version identifier
1363 This optional attribute is used by the @code{test-system-version} operation.
1364 @xref{Predefined operations of ASDF}.
1365 For the default method of @code{test-system-version},
1366 the version should be a string of integers separated by dots,
1367 for example @samp{1.0.11}.
1370 This operation, planned for ASDF 1,
1371 is still not implement yet as of ASDF 2.
1372 Don't hold your breath.
1375 @subsubsection Required features
1377 @emph{FIXME: This subsection seems to contradict the
1378 @code{defsystem} grammar subsection,
1379 which doesn't provide any obvious way to specify required features.
1380 Furthermore, in 2009, discussions on the
1381 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
1382 suggested that the specification of required features may be broken,
1383 and that no one may have been using them for a while.
1385 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
1386 if you are interested in getting this features feature fixed.}
1388 Traditionally defsystem users have used reader conditionals
1389 to include or exclude specific per-implementation files.
1390 This means that any single implementation cannot read the entire system,
1391 which becomes a problem if it doesn't wish to compile it,
1392 but instead for example to create an archive file containing all the sources,
1393 as it will omit to process the system-dependent sources for other systems.
1395 Each component in an asdf system may therefore specify features using
1396 the same syntax as @code{#+} does, and it will (somehow) be ignored for
1397 certain operations unless the feature conditional is a member of
1401 @subsubsection Dependencies
1403 This attribute specifies dependencies of the component on its siblings.
1404 It is optional but often necessary.
1406 There is an excitingly complicated relationship between the initarg
1407 and the method that you use to ask about dependencies
1409 Dependencies are between (operation component) pairs.
1410 In your initargs for the component, you can say
1413 :in-order-to ((compile-op (load-op "a" "b") (compile-op "c"))
1414 (load-op (load-op "foo")))
1417 This means the following things:
1420 before performing compile-op on this component, we must perform
1421 load-op on @var{a} and @var{b}, and compile-op on @var{c},
1423 before performing @code{load-op}, we have to load @var{foo}
1426 The syntax is approximately
1429 (this-op {(other-op required-components)}+)
1431 required-components := component-name
1432 | (required-components required-components)
1434 component-name := string
1435 | (:version string minimum-version-object)
1440 This is on a par with what ACL defsystem does.
1441 mk-defsystem is less general: it has an implied dependency
1444 for all x, (load x) depends on (compile x)
1447 and using a @code{:depends-on} argument to say that @var{b} depends on
1448 @var{a} @emph{actually} means that
1451 (compile b) depends on (load a)
1454 This is insufficient for e.g. the McCLIM system, which requires that
1455 all the files are loaded before any of them can be compiled ]
1459 In ASDF, the dependency information for a given component and operation
1460 can be queried using @code{(component-depends-on operation component)},
1461 which returns a list
1464 ((load-op "a") (load-op "b") (compile-op "c") ...)
1467 @code{component-depends-on} can be subclassed for more specific
1468 component/operation types: these need to @code{(call-next-method)}
1469 and append the answer to their dependency, unless
1470 they have a good reason for completely overriding the default dependencies.
1472 If it weren't for CLISP, we'd be using @code{LIST} method
1473 combination to do this transparently.
1474 But, we need to support CLISP.
1475 If you have the time for some CLISP hacking,
1476 I'm sure they'd welcome your fixes.
1477 @c Doesn't CLISP now support LIST method combination?
1479 @subsubsection pathname
1481 This attribute is optional and if absent (which is the usual case),
1482 the component name will be used.
1484 @xref{The defsystem grammar,,Pathname specifiers},
1485 for an explanation of how this attribute is interpreted.
1487 Note that the @code{defsystem} macro (used to create a ``top-level'' system)
1488 does additional processing to set the filesystem location of
1489 the top component in that system.
1490 This is detailed elsewhere. @xref{Defining systems with defsystem}.
1493 @subsubsection properties
1495 This attribute is optional.
1497 Packaging systems often require information about files or systems
1498 in addition to that specified by ASDF's pre-defined component attributes.
1499 Programs that create vendor packages out of ASDF systems therefore
1500 have to create ``placeholder'' information to satisfy these systems.
1501 Sometimes the creator of an ASDF system may know the additional
1502 information and wish to provide it directly.
1504 @code{(component-property component property-name)} and
1505 associated @code{setf} method will allow
1506 the programmatic update of this information.
1507 Property names are compared as if by @code{EQL},
1508 so use symbols or keywords or something.
1511 * Pre-defined subclasses of component::
1512 * Creating new component types::
1515 @node Pre-defined subclasses of component, Creating new component types, Common attributes of components, Components
1516 @comment node-name, next, previous, up
1517 @subsection Pre-defined subclasses of component
1519 @deffn Component source-file
1521 A source file is any file that the system does not know how to
1522 generate from other components of the system.
1524 Note that this is not necessarily the same thing as
1525 ``a file containing data that is typically fed to a compiler''.
1526 If a file is generated by some pre-processor stage
1527 (e.g. a @file{.h} file from @file{.h.in} by autoconf)
1528 then it is not, by this definition, a source file.
1529 Conversely, we might have a graphic file
1530 that cannot be automatically regenerated,
1531 or a proprietary shared library that we received as a binary:
1532 these do count as source files for our purposes.
1534 Subclasses of source-file exist for various languages.
1535 @emph{FIXME: describe these.}
1538 @deffn Component module
1540 A module is a collection of sub-components.
1542 A module component has the following extra initargs:
1546 @code{:components} the components contained in this module
1549 @code{:default-component-class}
1550 All children components which don't specify their class explicitly
1551 are inferred to be of this type.
1554 @code{:if-component-dep-fails}
1555 This attribute takes one of the values
1556 @code{:fail}, @code{:try-next}, @code{:ignore},
1557 its default value is @code{:fail}.
1558 The other values can be used for implementing conditional compilation
1559 based on implementation @code{*features*},
1560 for the case where it is not necessary for all files in a module to be
1562 @emph{FIXME: such conditional compilation has been reported
1563 to be broken in 2009.}
1566 @code{:serial} When this attribute is set,
1567 each subcomponent of this component is assumed to depend on all subcomponents
1568 before it in the list given to @code{:components}, i.e.
1569 all of them are loaded before a compile or load operation is performed on it.
1573 The default operation knows how to traverse a module, so
1574 most operations will not need to provide methods specialised on modules.
1576 @code{module} may be subclassed to represent components such as
1577 foreign-language linked libraries or archive files.
1580 @deffn Component system
1582 @code{system} is a subclass of @code{module}.
1584 A system is a module with a few extra attributes for documentation
1585 purposes; these are given elsewhere.
1586 @xref{The defsystem grammar}.
1588 Users can create new classes for their systems:
1589 the default @code{defsystem} macro takes a @code{:class} keyword argument.
1592 @node Creating new component types, , Pre-defined subclasses of component, Components
1593 @comment node-name, next, previous, up
1594 @subsection Creating new component types
1596 New component types are defined by subclassing one of the existing
1597 component classes and specializing methods on the new component class.
1599 @emph{FIXME: this should perhaps be explained more throughly,
1600 not only by example ...}
1602 As an example, suppose we have some implementation-dependent
1603 functionality that we want to isolate
1604 in one subdirectory per Lisp implementation our system supports.
1605 We create a subclass of
1606 @code{cl-source-file}:
1609 (defclass unportable-cl-source-file (cl-source-file)
1613 A hypothetical function @code{system-dependent-dirname}
1614 gives us the name of the subdirectory.
1615 All that's left is to define how to calculate the pathname
1616 of an @code{unportable-cl-source-file}.
1619 (defmethod component-pathname ((component unportable-cl-source-file))
1620 (let ((pathname (call-next-method))
1621 (name (string-downcase (system-dependent-dirname))))
1623 (make-pathname :directory (list :relative name))
1627 The new component type is used in a @code{defsystem} form in this way:
1634 (:unportable-cl-source-file "threads"
1635 :depends-on ("packages" ...))
1640 @node Controlling where ASDF searches for systems, Controlling where ASDF saves compiled files, The object model of ASDF, Top
1641 @comment node-name, next, previous, up
1642 @chapter Controlling where ASDF searches for systems
1644 @section Configurations
1646 Configurations specify paths where to find system files.
1651 The search registry may use some hardcoded wrapping registry specification.
1652 This allows some implementations (notably SBCL) to specify where to find
1653 some special implementation-provided systems that
1654 need to precisely match the version of the implementation itself.
1657 An application may explicitly initialize the source-registry configuration
1658 using the configuration API
1659 (@pxref{Controlling where ASDF searches for systems,Configuration API,Configuration API}, below)
1660 in which case this takes precedence.
1661 It may itself compute this configuration from the command-line,
1662 from a script, from its own configuration file, etc.
1665 The source registry will be configured from
1666 the environment variable @code{CL_SOURCE_REGISTRY} if it exists.
1669 The source registry will be configured from
1670 user configuration file
1671 @file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf}
1673 @file{~/.config/common-lisp/source-registry.conf})
1677 The source registry will be configured from
1678 user configuration directory
1679 @file{$XDG_CONFIG_DIRS/common-lisp/source-registry.conf.d/}
1681 @file{~/.config/common-lisp/source-registry.conf.d/})
1685 The source registry will be configured from
1686 system configuration file
1687 @file{/etc/common-lisp/source-registry.conf}
1691 The source registry will be configured from
1692 system configuration directory
1693 @file{/etc/common-lisp/source-registry.conf.d/}
1697 The source registry will be configured from a default configuration.
1698 This configuration may allow for implementation-specific systems
1699 to be found, for systems to be found the current directory
1700 (at the time that the configuration is initialized) as well as
1701 @code{:directory} entries for @file{$XDG_DATA_DIRS/common-lisp/systems/} and
1702 @code{:tree} entries for @file{$XDG_DATA_DIRS/common-lisp/source/}.
1706 Each of these configuration is specified as a SEXP
1707 in a trival domain-specific language (defined below).
1708 Additionally, a more shell-friendly syntax is available
1709 for the environment variable (defined yet below).
1711 Each of these configurations is only used if the previous
1712 configuration explicitly or implicitly specifies that it
1713 includes its inherited configuration.
1715 Additionally, some implementation-specific directories
1716 may be automatically prepended to whatever directories are specified
1717 in configuration files, no matter if the last one inherits or not.
1719 @section XDG base directory
1721 Note that we purport to respect the XDG base directory specification
1722 as to where configuration files are located,
1723 where data files are located,
1724 where output file caches are located.
1725 Mentions of XDG variables refer to that document.
1727 @url{http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html}
1729 This specification allows the user to specify some environment variables
1730 to customize how applications behave to his preferences.
1732 On Windows platforms, when not using Cygwin,
1733 instead of the XDG base directory specification,
1734 we try to use folder configuration from the registry regarding
1735 @code{Common AppData} and similar directories.
1736 However, support querying the Windows registry is limited as of ASDF 2,
1737 and on many implementations, we may fall back to always using the defaults
1738 without consulting the registry.
1741 @section Backward Compatibility
1743 For backward compatibility as well as for a practical backdoor for hackers,
1744 ASDF will first search for @code{.asd} files in the directories specified in
1745 @code{asdf:*central-registry*}
1746 before it searches in the source registry above.
1748 @xref{Configuring ASDF,,Configuring ASDF to find your systems -- old style}.
1750 By default, @code{asdf:*central-registry*} will be empty.
1752 This old mechanism will therefore not affect you if you don't use it,
1753 but will take precedence over the new mechanism if you do use it.
1755 @section Configuration DSL
1757 Here is the grammar of the SEXP DSL for source-registry configuration:
1760 ;; A configuration is single SEXP starting with keyword :source-registry
1761 ;; followed by a list of directives.
1762 CONFIGURATION := (:source-registry DIRECTIVE ...)
1764 ;; A directive is one of the following:
1766 ;; INHERITANCE DIRECTIVE:
1767 ;; Your configuration expression MUST contain
1768 ;; exactly one of either of these:
1769 :inherit-configuration | ; splices inherited configuration (often specified last)
1770 :ignore-inherited-configuration | ; drop inherited configuration (specified anywhere)
1772 ;; add a single directory to be scanned (no recursion)
1773 (:directory DIRECTORY-PATHNAME-DESIGNATOR) |
1775 ;; add a directory hierarchy, recursing but excluding specified patterns
1776 (:tree DIRECTORY-PATHNAME-DESIGNATOR) |
1778 ;; override the defaults for exclusion patterns
1779 (:exclude PATTERN ...) |
1780 ;; augment the defaults for exclusion patterns
1781 (:also-exclude PATTERN ...) |
1783 ;; splice the parsed contents of another config file
1784 (:include REGULAR-FILE-PATHNAME-DESIGNATOR) |
1786 ;; This directive specifies that some default must be spliced.
1789 REGULAR-FILE-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a file
1790 DIRECTORY-PATHNAME-DESIGNATOR := PATHNAME-DESIGNATOR ;; interpreted as a directory name
1792 PATHNAME-DESIGNATOR :=
1793 NULL | ;; Special: skip this entry.
1794 ABSOLUTE-COMPONENT-DESIGNATOR |
1795 (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...)
1797 ABSOLUTE-COMPONENT-DESIGNATOR :=
1798 STRING | ;; namestring (better be absolute or bust, directory assumed where applicable)
1799 PATHNAME | ;; pathname (better be an absolute path, or bust)
1800 :HOME | ;; designates the user-homedir-pathname ~/
1801 :USER-CACHE | ;; designates the default location for the user cache
1802 :SYSTEM-CACHE ;; designates the default location for the system cache
1804 RELATIVE-COMPONENT-DESIGNATOR :=
1805 STRING | ;; namestring (directory assumed where applicable)
1806 PATHNAME | ;; pathname
1807 :IMPLEMENTATION | ;; a directory based on implementation, e.g. sbcl-1.0.32.30-linux-x86-64
1808 :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl
1809 :UID | ;; current UID -- not available on Windows
1810 :USER ;; current USER name -- NOT IMPLEMENTED(!)
1812 PATTERN := a string without wildcards, that will be matched exactly
1813 against the name of a any subdirectory in the directory component
1814 of a path. e.g. @code{"_darcs"} will match @file{#p"/foo/bar/_darcs/src/bar.asd"}
1817 For instance, as a simple case, my @file{~/.config/common-lisp/source-registry.conf},
1818 which is the default place ASDF looks for this configuration,
1822 (:tree (:home "cl")) ;; will expand to e.g. "/home/joeluser/cl/"
1823 :inherit-configuration)
1827 @section Configuration Directories
1829 Configuration directories consist in files each contains
1830 a list of directives without any enclosing @code{(:source-registry ...)} form.
1831 The files will be sorted by namestring as if by @code{string<} and
1832 the lists of directives of these files with be concatenated in order.
1833 An implicit @code{:inherit-configuration} will be included
1834 at the @emph{end} of the list.
1836 This allows for packaging software that has file granularity
1837 (e.g. Debian's @code{dpkg} or some future version of @code{clbuild})
1838 to easily include configuration information about distributed software.
1840 The convention is that, for sorting purposes,
1841 the names of files in such a directory begin with two digits
1842 that determine the order in which these entries will be read.
1843 Also, the type of these files is conventionally @code{"conf"}
1844 and as a limitation to some implementations (e.g. GNU clisp),
1845 the type cannot be @code{NIL}.
1847 Directories may be included by specifying a directory pathname
1848 or namestring in an @code{:include} directive, e.g.:
1851 (:include "/foo/bar/")
1854 Hence, to achieve the same effect as
1855 my example @file{~/.config/common-lisp/source-registry.conf} above,
1856 I could simply create a file
1857 @file{~/.config/common-lisp/source-registry.conf.d/33-home-fare-cl.conf}
1858 alone in its directory with the following contents:
1860 (:tree "/home/fare/cl/")
1864 @section Shell-friendly syntax for configuration
1866 When considering environment variable @code{CL_SOURCE_REGISTRY}
1867 ASDF will skip to next configuration if it's an empty string.
1868 It will @code{READ} the string as a SEXP in the DSL
1869 if it begins with a paren @code{(}
1870 and it will be interpreted much like @code{TEXINPUTS}
1871 list of paths, where
1873 * paths are separated
1874 by a @code{:} (colon) on Unix platforms (including cygwin),
1875 by a @code{;} (semicolon) on other platforms (mainly, Windows).
1877 * each entry is a directory to add to the search path.
1879 * if the entry ends with a double slash @code{//}
1880 then it instead indicates a tree in the subdirectories
1881 of which to recurse.
1883 * if the entry is the empty string (which may only appear once),
1884 then it indicates that the inherited configuration should be
1888 @section Search Algorithm
1890 In case that isn't clear, the semantics of the configuration is that
1891 when searching for a system of a given name,
1892 directives are processed in order.
1894 When looking in a directory, if the system is found, the search succeeds,
1895 otherwise it continues.
1897 When looking in a tree, if one system is found, the search succeeds.
1898 If multiple systems are found, the consequences are unspecified:
1899 the search may succeed with any of the found systems,
1900 or an error may be raised.
1901 ASDF currently returns the first system found,
1902 XCVB currently raised an error.
1903 If none is found, the search continues.
1905 Exclude statements specify patterns of subdirectories
1906 the systems from which to ignore.
1907 Typically you don't want to use copies of files kept by such
1908 version control systems as Darcs.
1909 Exclude statements are not propagated to further included or inherited
1910 configuration files or expressions;
1911 instead the defaults are reset around every configuration statement
1912 to the default defaults from @code{asdf::*default-source-registry-exclusions*}.
1914 Include statements cause the search to recurse with the path specifications
1915 from the file specified.
1917 An inherit-configuration statement cause the search to recurse with the path
1918 specifications from the next configuration
1919 (@pxref{Controlling where ASDF searches for systems,,Configurations} above).
1922 @section Caching Results
1924 The implementation is allowed to either eagerly compute the information
1925 from the configurations and file system, or to lazily re-compute it
1926 every time, or to cache any part of it as it goes.
1927 To explicitly flush any information cached by the system, use the API below.
1930 @section Configuration API
1932 The specified functions are exported from your build system's package.
1933 Thus for ASDF the corresponding functions are in package ASDF,
1934 and for XCVB the corresponding functions are in package XCVB.
1936 @defun initialize-source-registry @&optional PARAMETER
1937 will read the configuration and initialize all internal variables.
1938 You may extend or override configuration
1939 from the environment and configuration files
1940 with the given @var{PARAMETER}, which can be
1941 @code{NIL} (no configuration override),
1942 or a SEXP (in the SEXP DSL),
1943 a string (as in the string DSL),
1944 a pathname (of a file or directory with configuration),
1945 or a symbol (fbound to function that when called returns one of the above).
1948 @defun clear-source-registry
1949 undoes any source registry configuration
1950 and clears any cache for the search algorithm.
1951 You might want to call this function
1952 (or better, @code{clear-configuration})
1953 before you dump an image that would be resumed
1954 with a different configuration,
1955 and return an empty configuration.
1956 Note that this does not include clearing information about
1957 systems defined in the current image, only about
1958 where to look for systems not yet defined.
1961 @defun ensure-source-registry @&optional PARAMETER
1962 checks whether a source registry has been initialized.
1963 If not, initialize it with the given @var{PARAMETER}.
1966 Every time you use ASDF's @code{find-system}, or
1967 anything that uses it (such as @code{operate}, @code{load-system}, etc.),
1968 @code{ensure-source-registry} is called with parameter NIL,
1969 which the first time around causes your configuration to be read.
1970 If you change a configuration file,
1971 you need to explicitly @code{initialize-source-registry} again,
1972 or maybe simply to @code{clear-source-registry} (or @code{clear-configuration})
1973 which will cause the initialization to happen next time around.
1978 If this mechanism is successful, in the future, we may declare
1979 @code{asdf:*central-registry*} obsolete and eventually remove it.
1980 Any hook into implementation-specific search mechanisms will by then
1981 have been integrated in the @code{:default-configuration} which everyone
1982 should either explicitly use or implicit inherit. Some shell syntax
1983 for it should probably be added somehow.
1985 But we're not there yet. For now, let's see how practical this new
1989 @section Rejected ideas
1991 Alternatives I considered and rejected included:
1994 @item Keep @code{asdf:*central-registry*} as the master with its current semantics,
1995 and somehow the configuration parser expands the new configuration
1996 language into a expanded series of directories of subdirectories to
1997 lookup, pre-recursing through specified hierarchies. This is kludgy,
1998 and leaves little space of future cleanups and extensions.
2000 @item Keep @code{asdf:*central-registry*} remains the master but extend its semantics
2001 in completely new ways, so that new kinds of entries may be implemented
2002 as a recursive search, etc. This seems somewhat backwards.
2004 @item Completely remove @code{asdf:*central-registry*}
2005 and break backwards compatibility.
2006 Hopefully this will happen in a few years after everyone migrate to
2007 a better ASDF and/or to XCVB, but it would be very bad to do it now.
2009 @item Replace @code{asdf:*central-registry*} by a symbol-macro with appropriate magic
2010 when you dereference it or setf it. Only the new variable with new
2011 semantics is handled by the new search procedure.
2012 Complex and still introduces subtle semantic issues.
2016 I've been suggested the below features, but have rejected them,
2017 for the sake of keeping ASDF no more complex than strictly necessary.
2021 More syntactic sugar: synonyms for the configuration directives, such as
2022 @code{(:add-directory X)} for @code{(:directory X)}, or @code{(:add-directory-hierarchy X)}
2023 or @code{(:add-directory X :recurse t)} for @code{(:tree X)}.
2026 The possibility to register individual files instead of directories.
2029 Integrate Xach Beane's tilde expander into the parser,
2030 or something similar that is shell-friendly or shell-compatible.
2031 I'd rather keep ASDF minimal. But maybe this precisely keeps it
2032 minimal by removing the need for evaluated entries that ASDF has?
2033 i.e. uses of @code{USER-HOMEDIR-PATHNAME} and @code{$SBCL_HOME}
2034 Hopefully, these are already superseded by the @code{:default-registry}
2037 Using the shell-unfriendly syntax @code{/**} instead of @code{//} to specify recursion
2038 down a filesystem tree in the environment variable.
2039 It isn't that Lisp friendly either.
2049 @section Credits for the source-registry
2051 Thanks a lot to Stelian Ionescu for the initial idea.
2053 Thanks to Rommel Martinez for the initial implementation attempt.
2055 All bad design ideas and implementation bugs are to mine, not theirs.
2056 But so are good design ideas and elegant implementation tricks.
2058 --- Francois-Rene Rideau @email{fare@@tunes.org}, Mon, 22 Feb 2010 00:07:33 -0500
2062 @node Controlling where ASDF saves compiled files, Error handling, Controlling where ASDF searches for systems, Top
2063 @comment node-name, next, previous, up
2064 @chapter Controlling where ASDF saves compiled files
2065 @cindex asdf-output-translations
2066 @vindex ASDF_OUTPUT_TRANSLATIONS
2068 Each Common Lisp implementation has its own format
2069 for compiled files (fasls for short, short for ``fast loading'').
2070 If you use multiple implementations
2071 (or multiple versions of the same implementation),
2072 you'll soon find your source directories
2073 littered with various @file{fasl}s, @file{dfsl}s, @file{cfsl}s and so on.
2074 Worse yet, some implementations use the same file extension
2075 while changing formats from version to version (or platform to platform)
2076 which means that you'll have to recompile binaries
2077 as you switch from one implementation to the next.
2079 ASDF 2 includes the @code{asdf-output-translations} facility
2080 to mitigate the problem.
2082 @section Configurations
2084 Configurations specify mappings from input locations to output locations.
2085 Once again we rely on the XDG base directory specification for configuration.
2086 @xref{Controlling where ASDF searches for systems,,XDG base directory}.
2091 Some hardcoded wrapping output translations configuration may be used.
2092 This allows special output translations (or usually, invariant directories)
2093 to be specified corresponding to the similar special entries in the source registry.
2096 An application may explicitly initialize the output-translations
2097 configuration using the Configuration API
2098 in which case this takes precedence.
2099 (@pxref{Controlling where ASDF saves compiled files,,Configuration API}.)
2100 It may itself compute this configuration from the command-line,
2101 from a script, from its own configuration file, etc.
2104 The source registry will be configured from
2105 the environment variable @code{ASDF_OUTPUT_TRANSLATIONS} if it exists.
2108 The source registry will be configured from
2109 user configuration file
2110 @file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf}
2112 @file{~/.config/common-lisp/asdf-output-translations.conf})
2116 The source registry will be configured from
2117 user configuration directory
2118 @file{$XDG_CONFIG_DIRS/common-lisp/asdf-output-translations.conf.d/}
2120 @file{~/.config/common-lisp/asdf-output-translations.conf.d/})
2124 The source registry will be configured from
2125 system configuration file
2126 @file{/etc/common-lisp/asdf-output-translations.conf}
2130 The source registry will be configured from
2131 system configuration directory
2132 @file{/etc/common-lisp/asdf-output-translations.conf.d/}
2137 Each of these configurations is specified as a SEXP
2138 in a trival domain-specific language (defined below).
2139 Additionally, a more shell-friendly syntax is available
2140 for the environment variable (defined yet below).
2142 Each of these configurations is only used if the previous
2143 configuration explicitly or implicitly specifies that it
2144 includes its inherited configuration.
2146 Note that by default, a per-user cache is used for output files.
2147 This allows the seamless use of shared installations of software
2148 between several users, and takes files out of the way of the developers
2149 when they browse source code,
2150 at the expense of taking a small toll when developers have to clean up
2151 output files and find they need to get familiar with output-translations first.
2154 @section Backward Compatibility
2156 @c FIXME -- I think we should provide an easy way
2157 @c to get behavior equivalent to A-B-L and
2158 @c I will propose a technique for doing this.
2160 We purposefully do NOT provide backward compatibility with earlier versions of
2161 @code{ASDF-Binary-Locations} (8 Sept 2009),
2162 @code{common-lisp-controller} (7.0) or
2163 @code{cl-launch} (2.35),
2164 each of which had similar general capabilities.
2165 The previous APIs of these programs were not designed
2166 for configuration by the end-user
2167 in an easy way with configuration files.
2168 Recent versions of same packages use
2169 the new @code{asdf-output-translations} API as defined below:
2170 @code{common-lisp-controller} (7.2) and @code{cl-launch} (3.000).
2171 @code{ASDF-Binary-Locations} is fully superseded and not to be used anymore.
2173 This incompatibility shouldn't inconvenience many people.
2174 Indeed, few people use and customize these packages;
2175 these few people are experts who can trivially adapt to the new configuration.
2176 Most people are not experts, could not properly configure these features
2177 (except inasmuch as the default configuration of
2178 @code{common-lisp-controller} and/or @code{cl-launch}
2179 might have been doing the right thing for some users),
2180 and yet will experience software that ``just works'',
2181 as configured by the system distributor, or by default.
2183 Nevertheless, if you are a fan of @code{ASDF-Binary-Locations},
2184 we provide a limited emulation mode:
2186 @defun asdf:enable-asdf-binary-locations-compatibility @&key centralize-lisp-binaries default-toplevel-directory include-per-user-information map-all-source-files source-to-target-mappings
2187 This function will initialize the new @code{asdf-output-translations} facility in a way
2188 that emulates the behavior of the old @code{ASDF-Binary-Locations} facility.
2189 Where you would previously set global variables
2190 @var{*centralize-lisp-binaries*},
2191 @var{*default-toplevel-directory*},
2192 @var{*include-per-user-information*},
2193 @var{*map-all-source-files*} or @var{*source-to-target-mappings*}
2194 you will now have to pass the same values as keyword arguments to this function.
2195 Note however that as an extension the @code{:source-to-target-mappings} keyword argument
2196 will accept any valid pathname designator for @code{asdf-output-translations}
2197 instead of just strings and pathnames.
2200 If you insist, you can also keep using the old @code{ASDF-Binary-Locations}
2201 (the one available as an extension to load of top of ASDF,
2202 not the one built into a few old versions of ASDF),
2203 but first you must disable @code{asdf-output-translations}
2204 with @code{(asdf:disable-output-translations)},
2205 or you might experience ``interesting'' issues.
2207 Also, note that output translation is enabled by default.
2208 To disable it, use @code{(asdf:disable-output-translations)}.
2211 @section Configuration DSL
2213 Here is the grammar of the SEXP DSL
2214 for @code{asdf-output-translations} configuration:
2217 ;; A configuration is single SEXP starting with keyword :source-registry
2218 ;; followed by a list of directives.
2219 CONFIGURATION := (:output-translations DIRECTIVE ...)
2221 ;; A directive is one of the following:
2223 ;; INHERITANCE DIRECTIVE:
2224 ;; Your configuration expression MUST contain
2225 ;; exactly one of either of these:
2226 :inherit-configuration | ; splices inherited configuration (often specified last)
2227 :ignore-inherited-configuration | ; drop inherited configuration (specified anywhere)
2229 ;; include a configuration file or directory
2230 (:include PATHNAME-DESIGNATOR) |
2232 ;; enable global cache in ~/.common-lisp/cache/sbcl-1.0.35-x86-64/ or something.
2233 :enable-user-cache |
2234 ;; Disable global cache. Map / to /
2237 ;; add a single directory to be scanned (no recursion)
2238 (DIRECTORY-DESIGNATOR DIRECTORY-DESIGNATOR)
2240 ;; use a function to return the translation of a directory designator
2241 (DIRECTORY-DESIGNATOR (:function TRANSLATION-FUNCTION))
2243 DIRECTORY-DESIGNATOR :=
2244 T | ;; as source matches anything, as destination leaves pathname unmapped.
2245 ABSOLUTE-COMPONENT-DESIGNATOR |
2246 (ABSOLUTE-COMPONENT-DESIGNATOR RELATIVE-COMPONENT-DESIGNATOR ...)
2248 ABSOLUTE-COMPONENT-DESIGNATOR :=
2249 NULL | ;; As source: skip this entry. As destination: same as source
2250 :ROOT | ;; magic: paths that are relative to the root of the source host and device
2251 STRING | ;; namestring (directory is assumed, better be absolute or bust, ``/**/*.*'' added)
2252 PATHNAME | ;; pathname (better be an absolute directory or bust)
2253 :HOME | ;; designates the user-homedir-pathname ~/
2254 :USER-CACHE | ;; designates the default location for the user cache
2255 :SYSTEM-CACHE ;; designates the default location for the system cache
2257 RELATIVE-COMPONENT-DESIGNATOR :=
2258 STRING | ;; namestring, directory is assumed. If the last component, /**/*.* is added
2259 PATHNAME | ;; pathname unless last component, directory is assumed.
2260 :IMPLEMENTATION | ;; a directory based on implementation, e.g. sbcl-1.0.32.30-linux-x86-64
2261 :IMPLEMENTATION-TYPE | ;; a directory based on lisp-implementation-type only, e.g. sbcl
2262 :UID | ;; current UID -- not available on Windows
2263 :USER ;; current USER name -- NOT IMPLEMENTED(!)
2265 TRANSLATION-FUNCTION :=
2266 SYMBOL | ;; symbol of a function that takes two arguments,
2267 ;; the pathname to be translated and the matching DIRECTORY-DESIGNATOR
2268 LAMBDA ;; A form which evalutates to a function taking two arguments consisting of
2269 ;; the pathname to be translated and the matching DIRECTORY-DESIGNATOR
2273 Relative components better be either relative
2274 or subdirectories of the path before them, or bust.
2276 The last component, if not a pathname, is notionally completed by @file{/**/*.*}.
2277 You can specify more fine-grained patterns
2278 by using a pathname object as the last component
2279 e.g. @file{#p"some/path/**/foo*/bar-*.fasl"}
2281 You may use @code{#+features} to customize the configuration file.
2283 The second designator of a mapping may be @code{NIL}, indicating that files are not mapped
2284 to anything but themselves (same as if the second designator was the same as the first).
2286 When the first designator is @code{t},
2287 the mapping always matches.
2288 When the first designator starts with @code{:root},
2289 the mapping matches any host and device.
2290 In either of these cases, if the second designator
2291 isn't @code{t} and doesn't start with @code{:root},
2292 then strings indicating the host and pathname are somehow copied
2293 in the beginning of the directory component of the source pathname
2294 before it is translated.
2296 When the second designator is @code{t}, the mapping is the identity.
2297 When the second designator starts with @code{root},
2298 the mapping preserves the host and device of the original pathname.
2300 @code{:include} statements cause the search to recurse with the path specifications
2301 from the file specified.
2303 If the @code{translate-pathname} mechanism cannot achieve a desired
2304 translation, the user may provide a function which provides the
2305 required algorithim. Such a translation function is specified by
2306 supplying a list as the second @code{directory-designator}
2307 the first element of which is the keyword @code{:function},
2308 and the second element of which is
2309 either a symbol which designates a function or a lambda expression.
2310 The function designated by the second argument must take two arguments,
2311 the first being the pathname of the source file,
2312 the second being the wildcard that was matched.
2313 The result of the function invocation should be the translated pathname.
2315 An @code{:inherit-configuration} statement cause the search to recurse with the path
2316 specifications from the next configuration.
2317 @xref{Controlling where ASDF saves compiled files,,Configurations}, above.
2321 @code{:enable-user-cache} is the same as @code{(t :user-cache)}.
2323 @code{:disable-cache} is the same as @code{(t t)}.
2325 @code{:user-cache} uses the contents of variable @code{asdf::*user-cache*}
2326 which by default is the same as using
2327 @code{(:home ".cache" "common-lisp" :implementation)}.
2329 @code{:system-cache} uses the contents of variable @code{asdf::*system-cache*}
2330 which by default is the same as using
2331 @code{("/var/cache/common-lisp" :uid :implementation-type)}
2332 (on Unix and cygwin), or something semi-sensible on Windows.
2336 @section Configuration Directories
2338 Configuration directories consist in files each contains
2339 a list of directives without any enclosing
2340 @code{(:output-translations ...)} form.
2341 The files will be sorted by namestring as if by @code{string<} and
2342 the lists of directives of these files with be concatenated in order.
2343 An implicit @code{:inherit-configuration} will be included
2344 at the @emph{end} of the list.
2346 This allows for packaging software that has file granularity
2347 (e.g. Debian's @command{dpkg} or some future version of @command{clbuild})
2348 to easily include configuration information about software being distributed.
2350 The convention is that, for sorting purposes,
2351 the names of files in such a directory begin with two digits
2352 that determine the order in which these entries will be read.
2353 Also, the type of these files is conventionally @code{"conf"}
2354 and as a limitation of some implementations, the type cannot be @code{NIL}.
2356 Directories may be included by specifying a directory pathname
2357 or namestring in an @code{:include} directive, e.g.:
2359 (:include "/foo/bar/")
2362 @section Shell-friendly syntax for configuration
2364 When considering environment variable @code{ASDF_OUTPUT_TRANSLATIONS}
2365 ASDF will skip to next configuration if it's an empty string.
2366 It will @code{READ} the string as an SEXP in the DSL
2367 if it begins with a paren @code{(}
2368 and it will be interpreted as a list of directories.
2369 Directories should come by pairs, indicating a mapping directive.
2370 Entries are separated
2371 by a @code{:} (colon) on Unix platforms (including cygwin),
2372 by a @code{;} (semicolon) on other platforms (mainly, Windows).
2374 The magic empty entry,
2375 if it comes in what would otherwise be the first entry in a pair,
2376 indicates the splicing of inherited configuration.
2377 If it comes as the second entry in a pair,
2378 it indicates that the directory specified first is to be left untranslated
2379 (which has the same effect as if the directory had been repeated).
2382 @section Semantics of Output Translations
2384 From the specified configuration,
2385 a list of mappings is extracted in a straightforward way:
2386 mappings are collected in order, recursing through
2387 included or inherited configuration as specified.
2388 To this list is prepended some implementation-specific mappings,
2389 and is appended a global default.
2391 The list is then compiled to a mapping table as follows:
2392 for each entry, in order, resolve the first designated directory
2393 into an actual directory pathname for source locations.
2394 If no mapping was specified yet for that location,
2395 resolve the second designated directory to an output location directory
2396 add a mapping to the table mapping the source location to the output location,
2397 and add another mapping from the output location to itself
2398 (unless a mapping already exists for the output location).
2400 Based on the table, a mapping function is defined,
2401 mapping source pathnames to output pathnames:
2402 given a source pathname, locate the longest matching prefix
2403 in the source column of the mapping table.
2404 Replace that prefix by the corresponding output column
2405 in the same row of the table, and return the result.
2406 If no match is found, return the source pathname.
2407 (A global default mapping the filesystem root to itself
2408 may ensure that there will always be a match,
2409 with same fall-through semantics).
2411 @section Caching Results
2413 The implementation is allowed to either eagerly compute the information
2414 from the configurations and file system, or to lazily re-compute it
2415 every time, or to cache any part of it as it goes.
2416 To explicitly flush any information cached by the system, use the API below.
2419 @section Output location API
2421 The specified functions are exported from package ASDF.
2423 @defun initialize-output-translations @&optional PARAMETER
2424 will read the configuration and initialize all internal variables.
2425 You may extend or override configuration
2426 from the environment and configuration files
2427 with the given @var{PARAMETER}, which can be
2428 @code{NIL} (no configuration override),
2429 or a SEXP (in the SEXP DSL),
2430 a string (as in the string DSL),
2431 a pathname (of a file or directory with configuration),
2432 or a symbol (fbound to function that when called returns one of the above).
2435 @defun disable-output-translations
2436 will initialize output translations in a way
2437 that maps every pathname to itself,
2438 effectively disabling the output translation facility.
2441 @defun clear-output-translations
2442 undoes any output translation configuration
2443 and clears any cache for the mapping algorithm.
2444 You might want to call this function
2445 (or better, @code{clear-configuration})
2446 before you dump an image that would be resumed
2447 with a different configuration,
2448 and return an empty configuration.
2449 Note that this does not include clearing information about
2450 systems defined in the current image, only about
2451 where to look for systems not yet defined.
2454 @defun ensure-output-translations @&optional PARAMETER
2455 checks whether output translations have been initialized.
2456 If not, initialize them with the given @var{PARAMETER}.
2457 This function will be called before any attempt to operate on a system.
2460 @defun apply-output-translations PATHNAME
2461 Applies the configured output location translations to @var{PATHNAME}
2462 (calls @code{ensure-output-translations} for the translations).
2465 Every time you use ASDF's @code{output-files}, or
2466 anything that uses it (that may compile, such as @code{operate}, @code{perform}, etc.),
2467 @code{ensure-output-translations} is called with parameter NIL,
2468 which the first time around causes your configuration to be read.
2469 If you change a configuration file,
2470 you need to explicitly @code{initialize-output-translations} again,
2471 or maybe @code{clear-output-translations} (or @code{clear-configuration}),
2472 which will cause the initialization to happen next time around.
2475 @section Credits for output translations
2477 Thanks a lot to Bjorn Lindberg and Gary King for @code{ASDF-Binary-Locations},
2478 and to Peter van Eynde for @code{Common Lisp Controller}.
2480 All bad design ideas and implementation bugs are to mine, not theirs.
2481 But so are good design ideas and elegant implementation tricks.
2483 --- Francois-Rene Rideau @email{fare@@tunes.org}
2485 @c @section Default locations
2486 @c @findex output-files-for-system-and-operation
2488 @c The default binary location for each Lisp implementation
2489 @c is a subdirectory of each source directory.
2490 @c To account for different Lisps, Operating Systems, Implementation versions,
2491 @c and so on, ASDF borrows code from SLIME
2492 @c to create reasonable custom directory names.
2493 @c Here are some examples:
2497 @c SBCL, version 1.0 on Mac OS X for intel: @code{sbcl-1.0-darwin-x86}
2500 @c Franz Allegro, version 8.0, ANSI Common Lisp: @code{allegro-8.0a-macosx-x86}
2503 @c Franz Allegro, version 8.1, Modern (case sensitive) Common Lisp: @code{allegro-8.1m-macosx-x86}
2506 @c By default, all output file pathnames will be relocated
2507 @c to some thus-named subdirectory of @file{~/.cache/common-lisp/}.
2509 @c See the document @file{README.asdf-output-translations}
2510 @c for a full specification on how to configure @code{asdf-output-translations}.
2512 @node Error handling, Miscellaneous additional functionality, Controlling where ASDF saves compiled files, Top
2513 @comment node-name, next, previous, up
2514 @chapter Error handling
2515 @findex SYSTEM-DEFINITION-ERROR
2516 @findex OPERATION-ERROR
2518 @section ASDF errors
2520 If ASDF detects an incorrect system definition, it will signal a generalised instance of
2521 @code{SYSTEM-DEFINITION-ERROR}.
2523 Operations may go wrong (for example when source files contain errors).
2524 These are signalled using generalised instances of
2525 @code{OPERATION-ERROR}.
2527 @section Compilation error and warning handling
2528 @vindex *compile-file-warnings-behaviour*
2529 @vindex *compile-file-errors-behavior*
2531 ASDF checks for warnings and errors when a file is compiled.
2532 The variables @var{*compile-file-warnings-behaviour*} and
2533 @var{*compile-file-errors-behavior*}
2534 control the handling of any such events.
2535 The valid values for these variables are
2536 @code{:error}, @code{:warn}, and @code{:ignore}.
2538 @node Miscellaneous additional functionality, Getting the latest version, Error handling, Top
2539 @comment node-name, next, previous, up
2540 @chapter Miscellaneous additional functionality
2542 @emph{FIXME: Add discussion of @code{run-shell-command}? Others?}
2544 ASDF includes several additional features that are generally
2545 useful for system definition and development. These include:
2547 @defun system-relative-pathname system name @&key type
2549 It's often handy to locate a file relative to some system.
2550 The @code{system-relative-pathname} function meets this need.
2551 It takes two arguments: the name of a system and a relative pathname.
2552 It returns a pathname built from the location of the system's source file
2553 and the relative pathname. For example
2556 > (asdf:system-relative-pathname 'cl-ppcre #p"regex.data")
2557 #P"/repository/other/cl-ppcre/regex.data"
2560 Instead of a pathname, you can provide a symbol or a string,
2561 and optionally a keyword argument @code{type}.
2562 The arguments will then be interpreted in the same way
2563 as pathname specifiers for components.
2564 @xref{The defsystem grammar,,Pathname specifiers}.
2567 @defun system-source-directory system-designator
2569 ASDF does not provide a turnkey solution for locating
2570 data (or other miscellaneous) files
2571 that are distributed together with the source code of a system.
2572 Programmers can use @code{system-source-directory} to find such files.
2573 Returns a pathname object.
2574 The @var{system-designator} may be a string, symbol, or ASDF system object.
2577 @defun clear-system system-designator
2579 It is sometimes useful to force recompilation of a previously loaded system.
2580 In these cases, it may be useful to @code{(asdf:clear-system :foo)}
2581 to remove the system from the table of currently loaded systems;
2582 the next time the system @code{foo} or one that depends on it is re-loaded,
2583 @code{foo} will then be loaded again.
2584 Alternatively, you could touch @code{foo.asd} or
2585 remove the corresponding fasls from the output file cache.
2586 (It was once conceived that one should provide
2587 a list of systems the recompilation of which to force
2588 as the @code{:force} keyword argument to @code{load-system};
2589 but this has never worked, and though the feature was fixed in ASDF 2.000,
2590 it remains @code{cerror}'ed out as nobody ever used it.)
2592 Note that this does not and cannot by itself undo the previous loading
2593 of the system. Common Lisp has no provision for such an operation,
2594 and its reliance on irreversible side-effects to global datastructures
2595 makes such a thing impossible in the general case.
2596 If the software being re-loaded is not conceived with hot upgrade in mind,
2597 this re-loading may cause many errors, warnings or subtle silent problems,
2598 as packages, generic function signatures, structures, types, macros, constants, etc.
2599 are being redefined incompatibly.
2600 It is up to the user to make sure that reloading is possible and has the desired effect.
2601 In some cases, extreme measures such as recursively deleting packages,
2602 unregistering symbols, defining methods on @code{update-instance-for-redefined-class}
2603 and much more are necessary for reloading to happen smoothly.
2604 ASDF itself goes through notable pains to make such a hot upgrade possible
2605 with respect to its own code, and what it does is ridiculously complex;
2606 look at the beginning of @file{asdf.lisp} to see what it does.
2609 @node Getting the latest version, FAQ, Miscellaneous additional functionality, Top
2610 @comment node-name, next, previous, up
2611 @chapter Getting the latest version
2613 Decide which version you want.
2614 HEAD is the newest version and usually OK, whereas
2615 RELEASE is for cautious people
2616 (e.g. who already have systems using ASDF that they don't want broken),
2617 a slightly older version about which none of the HEAD users have complained.
2618 There is also a STABLE version, which is earlier than release.
2620 You may get the ASDF source repository using git:
2621 @kbd{git clone git://common-lisp.net/projects/asdf/asdf.git}
2623 You will find the above referenced tags in this repository.
2624 You can also browse the repository on
2625 @url{http://common-lisp.net/gitweb?p=projects/asdf/asdf.git}.
2627 Discussion of ASDF development is conducted on the
2629 @kbd{asdf-devel@@common-lisp.net}.
2630 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel}
2633 @node FAQ, TODO list, Getting the latest version, Top
2634 @comment node-name, next, previous, up
2637 @section ``Where do I report a bug?''
2639 ASDF bugs are tracked on launchpad: @url{https://launchpad.net/asdf}.
2641 If you're unsure about whether something is a bug, or for general discussion,
2642 use the @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list}
2645 @section ``What has changed between ASDF 1 and ASDF 2?''
2647 @subsection What are ASDF 1 and ASDF 2?
2649 On May 31st 2010, we have released ASDF 2.
2650 ASDF 2 refers to release 2.000 and later.
2651 (Releases between 1.656 and 1.728 were development releases for ASDF 2.)
2652 ASDF 1 to any release earlier than 1.369 or so.
2653 If your ASDF doesn't sport a version, it's an old ASDF 1.
2655 ASDF 2 and its release candidates push
2656 @code{:asdf2} onto @code{*features*} so that if you are writing
2657 ASDF-dependent code you may check for this feature
2658 to see if the new API is present.
2659 @emph{All} versions of ASDF should have the @code{:asdf} feature.
2661 If you are experiencing problems or limitations of any sort with ASDF 1,
2662 we recommend that you should upgrade to ASDF 2,
2663 or whatever is the latest release.
2666 @subsection ASDF can portably name files in subdirectories
2668 Common Lisp namestrings are not portable,
2669 except maybe for logical pathnamestrings,
2670 that themselves have various limitations and require a lot of setup
2671 that is itself ultimately non-portable.
2673 In ASDF 1, the only portable ways to refer to pathnames inside systems and components
2674 were very awkward, using @code{#.(make-pathname ...)} and
2675 @code{#.(merge-pathnames ...)}.
2676 Even the above were themselves were inadequate in the general case
2677 due to host and device issues, unless horribly complex patterns were used.
2678 Plenty of simple cases that looked portable actually weren't,
2679 leading to much confusion and greavance.
2681 ASDF 2 implements its own portable syntax for strings as pathname specifiers.
2682 Naming files within a system definition becomes easy and portable again.
2683 @xref{Miscellaneous additional functionality,asdf:system-relative-pathname},
2684 @code{asdf-utilities:merge-pathnames*},
2685 @code{asdf::merge-component-name-type}.
2687 On the other hand, there are places where systems used to accept namestrings
2688 where you must now use an explicit pathname object:
2689 @code{(defsystem ... :pathname "LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
2690 must now be written with the @code{#p} syntax:
2691 @code{(defsystem ... :pathname #p"LOGICAL-HOST:PATH;TO;SYSTEM;" ...)}
2693 @xref{The defsystem grammar,,Pathname specifiers}.
2696 @subsection Output translations
2698 A popular feature added to ASDF was output pathname translation:
2699 @code{asdf-binary-locations}, @code{common-lisp-controller},
2700 @code{cl-launch} and other hacks were all implementing it in ways
2701 both mutually incompatible and difficult to configure.
2703 Output pathname translation is essential to share
2704 source directories of portable systems across multiple implementations
2705 or variants thereof,
2706 or source directories of shared installations of systems across multiple users,
2707 or combinations of the above.
2709 In ASDF 2, a standard mechanism is provided for that,
2710 @code{asdf-output-translations},
2711 with sensible defaults, adequate configuration languages,
2712 a coherent set of configuration files and hooks,
2713 and support for non-Unix platforms.
2715 @xref{Controlling where ASDF saves compiled files}.
2717 @subsection Source Registry Configuration
2719 Configuring ASDF used to require special magic
2720 to be applied just at the right moment,
2721 between the moment ASDF is loaded and the moment it is used,
2722 in a way that is specific to the user,
2723 the implementation he is using and the application he is building.
2725 This made for awkward configuration files and startup scripts
2726 that could not be shared between users, managed by administrators
2727 or packaged by distributions.
2729 ASDF 2 provides a well-documented way to configure ASDF,
2730 with sensible defaults, adequate configuration languages,
2731 and a coherent set of configuration files and hooks.
2733 We believe it's a vast improvement because it decouples
2734 application distribution from library distribution.
2735 The application writer can avoid thinking where the libraries are,
2736 and the library distributor (dpkg, clbuild, advanced user, etc.)
2737 can configure them once and for every application.
2738 Yet settings can be easily overridden where needed,
2739 so whoever needs control has exactly as much as required.
2741 At the same time, ASDF 2 remains compatible
2742 with the old magic you may have in your build scripts
2743 (using @code{*central-registry*} and
2744 @code{*system-definition-search-functions*})
2745 to tailor the ASDF configuration to your build automation needs,
2746 and also allows for new magic, simpler and more powerful magic.
2748 @xref{Controlling where ASDF searches for systems}.
2751 @subsection Usual operations are made easier to the user
2753 In ASDF 1, you had to use the awkward syntax
2754 @code{(asdf:oos 'asdf:load-op :foo)}
2756 and similarly for @code{compile-op}, @code{test-op}.
2758 In ASDF 2, you can use shortcuts for the usual operations:
2759 @code{(asdf:load-system :foo)}, and
2760 similarly for @code{compile-system}, @code{test-system}.
2763 @subsection Many bugs have been fixed
2765 The following issues and many others have been fixed:
2769 The infamous TRAVERSE function has been revamped significantly,
2770 with many bugs squashed.
2771 In particular, dependencies were not correctly propagated
2772 across submodules within a system but now are.
2773 The :version and :feature features and
2774 the :force (system1 .. systemN) feature have been fixed.
2777 Performance has been notably improved for large systems
2778 (say with thousands of components) by using
2779 hash-tables instead of linear search,
2780 and linear-time list accumulation
2781 instead of quadratic-time recursive appends.
2784 Many features used to not be portable,
2785 especially where pathnames were involved.
2786 Windows support was notably quirky because of such non-portability.
2789 The internal test suite used to massively fail on many implementations.
2790 While still incomplete, it now fully passes
2791 on all implementations supported by the test suite,
2792 except for GCL (due to GCL bugs).
2795 Support was lacking for some implementations.
2796 ABCL and GCL were notably wholly broken.
2797 ECL extensions were not integrated in the ASDF release.
2800 The documentation was grossly out of date.
2805 @subsection ASDF itself is versioned
2807 Between new features, old bugs fixed, and new bugs introduced,
2808 there were various releases of ASDF in the wild,
2809 and no simple way to check which release had which feature set.
2810 People using or writing systems had to either make worst-case assumptions
2811 as to what features were available and worked,
2812 or take great pains to have the correct version of ASDF installed.
2814 With ASDF 2, we provide a new stable set of working features
2815 that everyone can rely on from now on.
2816 Use @code{#+asdf2} to detect presence of ASDF 2,
2817 @code{(asdf:version-satisfies (asdf:asdf-version) "2.000")}
2818 to check the availability of a version no earlier than required.
2821 @subsection ASDF can be upgraded
2823 When an old version of ASDF was loaded,
2824 it was very hard to upgrade ASDF in your current image
2825 without breaking everything.
2826 Instead you have to exit the Lisp process and
2827 somehow arrange to start a new one from a simpler image.
2828 Something that can't be done from within Lisp,
2829 making automation of it difficult,
2830 which compounded with difficulty in configuration,
2831 made the task quite hard.
2832 Yet as we saw before, the task would have been required
2833 to not have to live with the worst case or non-portable
2834 subset of ASDF features.
2836 With ASDF 2, it is easy to upgrade
2837 from ASDF 2 to later versions from within Lisp,
2838 and not too hard to upgrade from ASDF 1 to ASDF 2 from within Lisp.
2839 We support hot upgrade of ASDF and any breakage is a bug
2840 that we will do our best to fix.
2841 There are still limitations on upgrade, though,
2842 most notably the fact that after you upgrade ASDF,
2843 you must also reload or upgrade all ASDF extensions.
2845 @subsection Decoupled release cycle
2847 When vendors were releasing their Lisp implementations with ASDF,
2848 they had to basically never change version
2849 because neither upgrade nor downgrade was possible
2850 without breaking something for someone,
2851 and no obvious upgrade path was visible and recommendable.
2853 With ASDF 2, upgrade is possible, easy and can be recommended.
2854 This means that vendors can safely ship a recent version of ASDF,
2855 confident that if a user isn't fully satisfied,
2856 he can easily upgrade ASDF and deal
2857 with a supported recent version of it.
2858 This means that release cycles will be causally decoupled,
2859 the practical consequence of which will mean faster convergence
2860 towards the latest version for everyone.
2863 @subsection Pitfalls of the transition to ASDF 2
2865 The main pitfalls in upgrading to ASDF 2 seem to be related
2866 to the output translation mechanism.
2871 Output translations is enabled by default. This may surprise some users,
2872 most of them in pleasant way (we hope), a few of them in an unpleasant way.
2873 It is trivial to disable output translations.
2874 @xref{FAQ,,``How can I wholly disable the compiler output cache?''}.
2877 Some systems in the large have been known not to play well with output translations.
2878 They were relatively easy to fix.
2879 Once again, it is also easy to disable output translations,
2880 or to override its configuration.
2883 The new ASDF output translations are incompatible with ASDF-Binary-Locations.
2884 They replace A-B-L, and there is compatibility mode to emulate
2885 your previous A-B-L configuration.
2886 See @code{asdf:enable-asdf-binary-locations-compatibility} in
2887 @pxref{Controlling where ASDF saves compiled files,,Backward Compatibility}.
2888 But thou shall not load ABL on top of ASDF 2.
2892 Other issues include the following:
2897 ASDF pathname designators are now specified in places where they were unspecified,
2898 and a few small adjustments have to be made to some non-portable defsystems.
2899 Notably, in the @code{:pathname} argument to a @code{defsystem} and its components,
2900 a logical pathname (or implementation-dependent hierarchical pathname)
2901 must now be specified with @code{#p} syntax
2902 where the namestring might have previously sufficed;
2903 moreover when evaluation is desired @code{#.} must be used,
2904 where it wasn't necessary in the toplevel @code{:pathname} argument.
2907 There is a slight performance bug, notably on SBCL,
2908 when initially searching for @file{asd} files,
2909 the implicit @code{(directory "/configured/path/**/*.asd")}
2910 for every configured path @code{(:tree "/configured/path/")}
2911 in your @code{source-registry} configuration can cause a slight pause.
2912 Try to @code{(time (asdf:initialize-source-registry))}
2913 to see how bad it is or isn't on your system.
2914 If you insist on not having this pause,
2915 you can avoid the pause by overriding the default source-registry configuration
2916 and not use any deep @code{:tree} entry but only @code{:directory} entries
2917 or shallow @code{:tree} entries.
2918 Or you can fix your implementation to not be quite that slow
2919 when recursing through directories.
2922 On Windows, only LispWorks supports proper default configuration pathnames
2923 based on the Windows registry.
2924 Other implementations make do with environment variables.
2925 Windows support is somewhat less tested than Unix support.
2926 Please help report and fix bugs.
2929 The mechanism by which one customizes a system so that Lisp files
2930 may use a different extension from the default @file{.lisp} has changed.
2931 Previously, the pathname for a component was lazily computed when operating on a system,
2933 @code{(defmethod source-file-type ((component cl-source-file) (system (eql (find-system 'foo))))
2934 (declare (ignorable component system)) "cl")}.
2935 Now, the pathname for a component is eagerly computed when defining the system,
2936 and instead you will @code{(defclass my-cl-source-file (cl-source-file) ((type :iniform "cl")))}
2937 and use @code{:default-component-class my-cl-source-file} as argument to @code{defsystem},
2938 as detailed in a @pxref{FAQ,How do I create a system definition where all the source files have a .cl extension?} below.
2940 @findex source-file-type
2946 @section Issues with installing the proper version of ASDF
2948 @subsection ``My Common Lisp implementation comes with an outdated version of ASDF. What to do?''
2950 We recommend you upgrade ASDF.
2951 @xref{Loading ASDF,,Upgrading ASDF}.
2953 If this does not work, it is a bug, and you should report it.
2954 @xref{FAQ, report-bugs, Where do I report a bug}.
2955 In the meantime, you can load @file{asdf.lisp} directly.
2956 @xref{Loading ASDF,Loading an otherwise installed ASDF}.
2959 @subsection ``I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?''
2961 Starting with current candidate releases of ASDF 2,
2962 it should always be a good time to upgrade to a recent ASDF.
2963 You may consult with the maintainer for which specific version they recommend,
2964 but the latest RELEASE should be correct.
2965 We trust you to thoroughly test it with your implementation before you release it.
2966 If there are any issues with the current release,
2967 it's a bug that you should report upstream and that we will fix ASAP.
2969 As to how to include ASDF, we recommend the following:
2973 If ASDF isn't loaded yet, then @code{(require :asdf)}
2974 should load the version of ASDF that is bundled with your system.
2975 You may have it load some other version configured by the user,
2976 if you allow such configuration.
2979 If your system provides a mechanism to hook into @code{CL:REQUIRE},
2980 then it would be nice to add ASDF to this hook the same way that
2981 ABCL, CCL, CLISP, CMUCL, ECL, SBCL and SCL do it.
2984 You may, like SBCL, have ASDF be implicitly used to require systems
2985 that are bundled with your Lisp distribution.
2986 If you do have a few magic systems that come with your implementation
2987 in a precompiled way such that one should only use the binary version
2988 that goes with your distribution, like SBCL does,
2989 then you should add them in the beginning of @code{wrapping-source-registry}.
2992 If you have magic systems as above, like SBCL does,
2993 then we explicitly ask you to @emph{NOT} distribute
2994 @file{asdf.asd} as part of those magic systems.
2995 You should still include the file @file{asdf.lisp} in your source distribution
2996 and precompile it in your binary distribution,
2997 but @file{asdf.asd} if included at all,
2998 should be secluded from the magic systems,
2999 in a separate file hierarchy;
3000 alternatively, you may provide the system
3001 after renaming it and its @file{.asd} file to e.g.
3002 @code{asdf-ecl} and @file{asdf-ecl.asd}, or
3003 @code{sb-asdf} and @file{sb-asdf.asd}.
3004 Indeed, if you made @file{asdf.asd} a magic system,
3005 then users would no longer be able to upgrade ASDF using ASDF itself
3006 to some version of their preference that
3007 they maintain independently from your Lisp distribution.
3010 If you do not have any such magic systems, or have other non-magic systems
3011 that you want to bundle with your implementation,
3012 then you may add them to the @code{default-source-registry},
3013 and you are welcome to include @file{asdf.asd} amongst them.
3016 Please send us upstream any patches you make to ASDF itself,
3017 so we can merge them back in for the benefit of your users
3018 when they upgrade to the upstream version.
3024 @section Issues with configuring ASDF
3026 @subsection ``How can I customize where fasl files are stored?''
3028 @xref{Controlling where ASDF saves compiled files}.
3030 Note that in the past there was an add-on to ASDF called
3031 @code{ASDF-binary-locations}, developed by Gary King.
3032 That add-on has been merged into ASDF proper,
3033 then superseded by the @code{asdf-output-translations} facility.
3035 Note that use of @code{asdf-output-translations}
3036 can interfere with one aspect of your systems
3037 --- if your system uses @code{*load-truename*} to find files
3038 (e.g., if you have some data files stored with your program),
3039 then the relocation that this ASDF customization performs
3040 is likely to interfere.
3041 Use @code{asdf:system-relative-pathname} to locate a file
3042 in the source directory of some system, and
3043 use @code{asdf:apply-output-translations} to locate a file
3044 whose pathname has been translated by the facility.
3046 @subsection ``How can I wholly disable the compiler output cache?''
3048 To permanently disable the compiler output cache
3049 for all future runs of ASDF, you can:
3052 mkdir -p ~/.config/common-lisp/asdf-output-translations.conf.d/
3053 echo ':disable-cache' > ~/.config/common-lisp/asdf-output-translations.conf.d/99-disable-cache.conf
3056 This assumes that you didn't otherwise configure the ASDF files
3057 (if you did, edit them again),
3058 and don't somehow override the configuration at runtime
3059 with a shell variable (see below) or some other runtime command
3060 (e.g. some call to @code{asdf:initialize-output-translations}).
3062 To disable the compiler output cache in Lisp processes
3063 run by your current shell, try (assuming @code{bash} or @code{zsh})
3064 (on Unix and cygwin only):
3067 export ASDF_OUTPUT_TRANSLATIONS=/:
3070 To disable the compiler output cache just in the current Lisp process,
3071 use (after loading ASDF but before using it):
3074 (asdf:disable-output-translations)
3077 @section Issues with using and extending ASDF to define systems
3079 @subsection ``How can I cater for unit-testing in my system?''
3081 ASDF provides a predefined test operation, @code{test-op}.
3082 @xref{Predefined operations of ASDF, test-op}.
3083 The test operation, however, is largely left to the system definer to specify.
3084 @code{test-op} has been
3085 a topic of considerable discussion on the
3086 @url{http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel,asdf-devel mailing list},
3088 @url{https://launchpad.net/asdf,launchpad bug-tracker}.
3090 Here are some guidelines:
3094 For a given system, @var{foo}, you will want to define a corresponding
3095 test system, such as @var{foo-test}. The reason that you will want this
3096 separate system is that ASDF does not out of the box supply components
3097 that are conditionally loaded. So if you want to have source files
3098 (with the test definitions) that will not be loaded except when testing,
3099 they should be put elsewhere.
3102 The @var{foo-test} system can be defined in an asd file of its own or
3103 together with @var{foo}. An aesthetic preference against cluttering up
3104 the filesystem with extra asd files should be balanced against the
3105 question of whether one might want to directly load @var{foo-test}.
3106 Typically one would not want to do this except in early stages of
3110 Record that testing is implemented by @var{foo-test}. For example:
3112 (defsystem @var{foo}
3113 :in-order-to ((test-op (test-op @var{foo-test})))
3116 (defsystem @var{foo-test}
3117 :depends-on (@var{foo} @var{my-test-library} ...)
3122 This procedure will allow you to support users who do not wish to
3123 install your test framework.
3125 One oddity of ASDF is that @code{operate} (@pxref{Operations,operate})
3126 does not return a value. So in current versions of ASDF there is no
3127 reliable programmatic means of determining whether or not a set of tests
3128 has passed, or which tests have failed. The user must simply read the
3129 console output. This limitation has been the subject of much
3132 @subsection ``How can I cater for documentation generation in my system?''
3134 The ASDF developers are currently working to add a @code{doc-op}
3135 to the set of predefined ASDF operations.
3136 @xref{Predefined operations of ASDF}.
3137 See also @url{https://bugs.launchpad.net/asdf/+bug/479470}.
3141 @subsection ``How can I maintain non-Lisp (e.g. C) source files?''
3143 See @code{cffi}'s @code{cffi-grovel}.
3145 @anchor{report-bugs}
3148 @subsection ``I want to put my module's files at the top level. How do I do this?''
3150 By default, the files contained in an asdf module go
3151 in a subdirectory with the same name as the module.
3152 However, this can be overridden by adding a @code{:pathname ""} argument
3153 to the module description.
3154 For example, here is how it could be done
3155 in the spatial-trees ASDF system definition for ASDF 2:
3158 (asdf:defsystem :spatial-trees
3164 (:file "basedefs" :depends-on ("package"))
3165 (:file "rectangles" :depends-on ("package"))))
3171 (:file "greene-trees" :depends-on ("r-trees"))
3172 (:file "rstar-trees" :depends-on ("r-trees"))
3173 (:file "rplus-trees" :depends-on ("r-trees"))
3174 (:file "x-trees" :depends-on ("r-trees" "rstar-trees"))))
3179 ((:static-file "spatial-tree-viz.lisp")))
3184 ((:static-file "spatial-tree-test.lisp")))
3185 (:static-file "LICENCE")
3186 (:static-file "TODO")))
3189 All of the files in the @code{tree-impls} module are at the top level,
3190 instead of in a @file{tree-impls/} subdirectory.
3192 Note that the argument to @code{:pathname} can be either a pathname object or a string.
3193 A pathname object can be constructed with the @file{#p"foo/bar/"} syntax,
3194 but this is discouraged because the results of parsing a namestring are not portable.
3195 A pathname can only be portably constructed with such syntax as
3196 @code{#.(make-pathname :directory '(:relative "foo" "bar"))},
3197 and similarly the current directory can only be portably specified as
3198 @code{#.(make-pathname :directory '(:relative))}.
3199 However, as of ASDF 2, you can portably use a string to denote a pathname.
3200 The string will be parsed as a @code{/}-separated path from the current directory,
3201 such that the empty string @code{""} denotes the current directory, and
3202 @code{"foo/bar"} (no trailing @code{/} required in the case of modules)
3203 portably denotes the same subdirectory as above.
3204 When files are specified, the last @code{/}-separated component is interpreted
3205 either as the name component of a pathname
3206 (if the component class specifies a pathname type),
3207 or as a name component plus optional dot-separated type component
3208 (if the component class doesn't specifies a pathname type).
3210 @subsection How do I create a system definition where all the source files have a .cl extension?
3212 First, create a new @code{cl-source-file} subclass that provides an
3213 initform for the @code{type} slot:
3216 (defclass my-cl-source-file (cl-source-file)
3217 ((type :initform "cl")))
3220 To support both ASDF 1 and ASDF 2,
3221 you may omit the above @code{type} slot definition and instead define:
3224 (defmethod source-file-type ((f my-cl-source-file) (m module))
3225 (declare (ignorable f m))
3229 Then make your system use this subclass in preference to the standard
3233 (defsystem my-cl-system
3234 :default-component-class my-cl-source-file
3239 We assume that these definitions are loaded into a package that uses
3244 @node TODO list, Inspiration, FAQ, Top
3245 @comment node-name, next, previous, up
3248 Here is an old list of things to do,
3249 in addition to the bugs that are now tracked on launchpad:
3250 @url{https://launchpad.net/asdf}.
3252 @section Outstanding spec questions, things to add
3254 ** packaging systems
3256 *** manual page component?
3258 ** style guide for .asd files
3260 You should either use keywords or be careful
3261 with the package that you evaluate defsystem forms in.
3262 Otherwise @code{(defsystem partition ...)}
3263 being read in the @code{cl-user} package
3264 will intern a @code{cl-user:partition} symbol,
3265 which will then collide with the @code{partition:partition} symbol.
3267 Actually there's a hairier packages problem to think about too.
3268 @code{in-order-to} is not a keyword:
3269 if you read @code{defsystem} forms in a package that doesn't use ASDF,
3270 odd things might happen.
3273 ** extending defsystem with new options
3275 You might not want to write a whole parser,
3276 but just to add options to the existing syntax.
3277 Reinstate @code{parse-option} or something akin.
3280 ** document all the error classes
3282 ** what to do with compile-file failure
3284 Should check the primary return value from compile-file and see if
3285 that gets us any closer to a sensible error handling strategy
3289 lift unix-dso stuff from db-sockets
3293 A ``dry run'' of an operation can be made with the following form:
3296 (traverse (make-instance '<operation-name>)
3297 (find-system <system-name>)
3301 This uses unexported symbols.
3302 What would be a nice interface for this functionality?
3304 @section Missing bits in implementation
3306 ** reuse the same scratch package whenever a system is reloaded from disk
3308 ** proclamations probably aren't
3310 ** when a system is reloaded with fewer components than it previously had, odd things happen
3312 We should do something inventive when processing a @code{defsystem} form,
3313 like take the list of kids and @code{setf} the slot to @code{nil},
3314 then transfer children from old to new list as they're found.
3316 ** (stuff that might happen later)
3318 *** Propagation of the @code{:force} option.
3322 @code{(asdf:compile-system :araneida :force t)}
3324 also forces compilation of every other system the @code{:araneida} system depends on.
3325 This is rarely useful to me;
3326 usually, when I want to force recompilation of something more than a single source file,
3327 I want to recompile only one system.
3328 So it would be more useful to have @code{make-sub-operation}
3329 refuse to propagate @code{:force t} to other systems, and
3330 propagate only something like @code{:force :recursively}.
3332 Ideally what we actually want is some kind of criterion that says
3333 to which systems (and which operations) a @code{:force} switch will propagate.
3335 The problem is perhaps that ``force'' is a pretty meaningless concept.
3336 How obvious is it that @code{load :force t} should force @emph{compilation}?
3337 But we don't really have the right dependency setup
3338 for the user to compile @code{:force t} and expect it to work
3339 (files will not be loaded after compilation, so the compile
3340 environment for subsequent files will be emptier than it needs to be)
3342 What does the user actually want to do when he forces?
3343 Usually, for me, update for use with a new version of the Lisp compiler.
3344 Perhaps for recovery when he suspects that something has gone wrong.
3345 Or else when he's changed compilation options or configuration
3346 in some way that's not reflected in the dependency graph.
3348 Other possible interface: have a ``revert'' function akin to @code{make clean}.
3351 (asdf:revert 'asdf:compile-op 'araneida)
3354 would delete any files produced by @code{(compile-system :araneida)}.
3355 Of course, it wouldn't be able to do much about stuff in the image itself.
3357 How would this work?
3361 There's a difference between a module's dependencies (peers)
3362 and its components (children).
3363 Perhaps there's a similar difference in operations?
3364 For example, @code{(load "use") depends-on (load "macros")} is a peer,
3365 whereas @code{(load "use") depends-on (compile "use")}
3366 is more of a ``subservient'' relationship.
3368 @node Inspiration, Concept Index, TODO list, Top
3369 @comment node-name, next, previous, up
3370 @chapter Inspiration
3372 @section mk-defsystem (defsystem-3.x)
3374 We aim to solve basically the same problems as @code{mk-defsystem} does.
3375 However, our architecture for extensibility
3376 better exploits CL language features (and is documented),
3377 and we intend to be portable rather than just widely-ported.
3378 No slight on the @code{mk-defsystem} authors and maintainers is intended here;
3379 that implementation has the unenviable task
3380 of supporting pre-ANSI implementations, which is no longer necessary.
3382 The surface defsystem syntax of asdf is more-or-less compatible with
3383 @code{mk-defsystem}, except that we do not support
3384 the @code{source-foo} and @code{binary-foo} prefixes
3385 for separating source and binary files, and
3386 we advise the removal of all options to specify pathnames.
3388 The @code{mk-defsystem} code for topologically sorting
3389 a module's dependency list was very useful.
3391 @section defsystem-4 proposal
3393 Marco and Peter's proposal for defsystem 4 served as the driver for
3394 many of the features in here. Notable differences are:
3398 We don't specify output files or output file extensions
3399 as part of the system.
3401 If you want to find out what files an operation would create,
3405 We don't deal with CL packages
3407 If you want to compile in a particular package, use an @code{in-package} form
3408 in that file (ilisp / SLIME will like you more if you do this anyway)
3411 There is no proposal here that @code{defsystem} does version control.
3413 A system has a given version which can be used to check dependencies,
3417 The defsystem 4 proposal tends to look more at the external features,
3418 whereas this one centres on a protocol for system introspection.
3420 @section kmp's ``The Description of Large Systems'', MIT AI Memu 801
3422 Available in updated-for-CL form on the web at
3423 @url{http://nhplace.com/kent/Papers/Large-Systems.html}
3425 In our implementation we borrow kmp's overall @code{PROCESS-OPTIONS}
3426 and concept to deal with creating component trees
3427 from @code{defsystem} surface syntax.
3428 [ this is not true right now, though it used to be and
3429 probably will be again soon ]
3432 @c -------------------
3435 @node Concept Index, Function and Class Index, Inspiration, Top
3436 @unnumbered Concept Index
3440 @node Function and Class Index, Variable Index, Concept Index, Top
3441 @unnumbered Function and Class Index
3445 @node Variable Index, , Function and Class Index, Top
3446 @unnumbered Variable Index