asdf.texinfo 254 KB
Newer Older
1
2
\input texinfo          @c -*- texinfo -*-
@c %**start of header
3
@setfilename asdf.info
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
4
@settitle ASDF Manual
5
@syncodeindex tp fn
6
7
@c %**end of header

8
9
@c We use @&key, etc to escape & from TeX in lambda lists --
@c so we need to define them for info as well.
10
@macro AallowOtherKeys
11
12
&allow-other-keys
@end macro
13
@macro Aoptional
14
15
&optional
@end macro
16
@macro Arest
17
18
&rest
@end macro
19
@macro Akey
20
21
&key
@end macro
22
@macro Abody
23
24
25
&body
@end macro

26
27
28
@c for install-info
@dircategory Software development
@direntry
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
29
* asdf: (asdf).           Another System Definition Facility (for Common Lisp)
30
31
@end direntry

32
@copying
33
34
This manual describes ASDF, a system definition facility
for Common Lisp programs and libraries.
35

36
You can find the latest version of this manual at
37
@url{https://common-lisp.net/project/asdf/asdf.html}.
38

39
ASDF Copyright @copyright{} 2001-2016 Daniel Barlow and contributors.
40

41
This manual Copyright @copyright{} 2001-2016 Daniel Barlow and contributors.
42

43
This manual revised @copyright{} 2009-2016 Robert P. Goldman and Francois-Rene Rideau.
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@end copying

@titlepage
67
@title ASDF: Another System Definition Facility
Robert Goldman's avatar
Robert Goldman committed
68
@subtitle Manual for Version 3.1.7.7
69
70
71
72
73
@c The following two commands start the copyright page.
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
74

75
76
77
78
79
80
81
@c Output the table of contents at the beginning.
@contents

@c -------------------

@ifnottex

82
@node Top, Introduction, (dir), (dir)
83
@top ASDF: Another System Definition Facility
84
@ifnottex
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
85
Manual for Version 3.1.7.1
86
87
@end ifnottex

88

89
90
91
@insertcopying

@menu
92
* Introduction::
93
* Quick start summary::
94
* Loading ASDF::
95
96
* Configuring ASDF::
* Using ASDF::
97
98
* Defining systems with defsystem::
* The object model of ASDF::
99
* Controlling where ASDF searches for systems::
100
101
102
103
104
* Controlling where ASDF saves compiled files::
* Error handling::
* Miscellaneous additional functionality::
* Getting the latest version::
* FAQ::
105
106
* Ongoing Work::
* Bibliography::
107
108
* Concept Index::
* Function and Class Index::
109
* Variable Index::              @c @detailmenu
110
@c
111
112
113
114
115
116
117
118
119

@detailmenu
 --- The Detailed Node Listing ---

Loading ASDF

* Loading a pre-installed ASDF::
* Checking whether ASDF is loaded::
* Upgrading ASDF::
120
* Replacing your implementation's ASDF::
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
121
* Loading ASDF from source::
122

123
124
125
Configuring ASDF

* Configuring ASDF to find your systems::
Robert P. Goldman's avatar
Robert P. Goldman committed
126
* Configuring ASDF to find your systems --- old style::
127
* Configuring where ASDF stores object files::
Robert P. Goldman's avatar
Robert P. Goldman committed
128
* Resetting the ASDF configuration::
129

130
131
132
Using ASDF

* Loading a system::
133
* Convenience Functions::
134
135
* Moving on::

136
137
138
139
140
141
Defining systems with defsystem

* The defsystem form::
* A more involved example::
* The defsystem grammar::
* Other code in .asd files::
142
* The package-inferred-system extension::
143

144
The Object model of ASDF
145

146
147
* Operations::
* Components::
148
* Dependencies::
149
* Functions::
150

151
Operations
152

153
154
* Predefined operations of ASDF::
* Creating new operations::
155

156
Components
157

158
159
160
* Common attributes of components::
* Pre-defined subclasses of component::
* Creating new component types::
161

162
properties
163

164
165
* Pre-defined subclasses of component::
* Creating new component types::
166

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Controlling where ASDF searches for systems

* Configurations::
* Truenames and other dangers::
* XDG base directory::
* Backward Compatibility::
* Configuration DSL::
* Configuration Directories::
* Shell-friendly syntax for configuration::
* Search Algorithm::
* Caching Results::
* Configuration API::
* Introspection::
* Status::
* Rejected ideas::
* TODO::
* Credits for the source-registry::

Configuration Directories

Robert P. Goldman's avatar
Robert P. Goldman committed
187
* The here directive::
188
189
190
191
192
193
194
195

Introspection

* *source-registry-parameter* variable::
* Information about system dependencies::

Controlling where ASDF saves compiled files

196
197
198
199
200
* Output Configurations::
* Output Backward Compatibility::
* Output Configuration DSL::
* Output Configuration Directories::
* Output Shell-friendly syntax for configuration::
201
* Semantics of Output Translations::
202
* Output Caching Results::
203
204
205
206
207
208
* Output location API::
* Credits for output translations::

Miscellaneous additional functionality

* Controlling file compilation::
209
* Controlling source file character encoding::
210
* Miscellaneous Functions::
211
212
* Some Utility Functions::

213
FAQ
214

215
* Where do I report a bug?::
216
* Mailing list::
217
* What has changed between ASDF 1 ASDF 2 and ASDF 3?::
218
219
220
221
* Issues with installing the proper version of ASDF::
* Issues with configuring ASDF::
* Issues with using and extending ASDF to define systems::
* ASDF development FAQs::
222

223
``What has changed between ASDF 1, ASDF 2, and ASDF 3?''
224

225
* What are ASDF 1 2 3?::
226
* How do I detect the ASDF version?::
227
228
229
230
231
232
233
234
235
* ASDF can portably name files in subdirectories::
* Output translations::
* Source Registry Configuration::
* Usual operations are made easier to the user::
* Many bugs have been fixed::
* ASDF itself is versioned::
* ASDF can be upgraded::
* Decoupled release cycle::
* Pitfalls of the transition to ASDF 2::
236
* Pitfalls of the upgrade to ASDF 3::
237
* What happened to the bundle operations::
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

Issues with installing the proper version of ASDF

* My Common Lisp implementation comes with an outdated version of ASDF. What to do?::
* I'm a Common Lisp implementation vendor. When and how should I upgrade ASDF?::

Issues with configuring ASDF

* How can I customize where fasl files are stored?::
* How can I wholly disable the compiler output cache?::

Issues with using and extending ASDF to define systems

* How can I cater for unit-testing in my system?::
* How can I cater for documentation generation in my system?::
* How can I maintain non-Lisp (e.g. C) source files?::
* I want to put my module's files at the top level.  How do I do this?::
* How do I create a system definition where all the source files have a .cl extension?::
256
* How do I mark a source file to be loaded only and not compiled?::
257
* How do I work with readtables?::
258
* How can I capture ASDF's output?::
259
260
261

ASDF development FAQs

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
262
* How do I run the tests interactively in a REPL?::
263
264

@end detailmenu
265
266
267
268
269
270
@end menu

@end ifnottex

@c -------------------

271
@node Introduction, Quick start summary, Top, Top
272
273
@comment  node-name,  next,  previous,  up
@chapter Introduction
Robert P. Goldman's avatar
Robert P. Goldman committed
274
275
276
277
278
279
@cindex ASDF-related features
@vindex *features*
@cindex Testing for ASDF
@cindex ASDF versions
@cindex :asdf
@cindex :asdf2
280
@cindex :asdf3
281

282
283
ASDF is Another System Definition Facility:
a tool for specifying how systems of Common Lisp software
284
are made up of components (sub-systems and files),
285
286
and how to operate on these components in the right order
so that they can be compiled, loaded, tested, etc.
287
If you are new to ASDF, @pxref{Quick start summary,,the quick start
288
guide}.
289
290
291
292

ASDF presents three faces:
one for users of Common Lisp software who want to reuse other people's code,
one for writers of Common Lisp software who want to specify how to build their systems,
293
294
and one for implementers of Common Lisp extensions who want to extend
the build system.
295
For more specifics,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
296
@pxref{Using ASDF},
297
to learn how to use ASDF to load a system.
Robert P. Goldman's avatar
Robert P. Goldman committed
298
@xref{Defining systems with defsystem},
299
to learn how to define a system of your own.
300
@xref{The object model of ASDF}, for a description of
Robert P. Goldman's avatar
Robert P. Goldman committed
301
the ASDF internals and how to extend ASDF.
302

303
Note that
304
305
306
307
ASDF is @emph{not} a tool for library and system @emph{installation};
it plays a role like @code{make} or @code{ant}, not like a package manager.
In particular, ASDF should not to be confused with Quicklisp or ASDF-Install,
that attempt to find and download ASDF systems for you.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
308
Despite what the name might suggest, ASDF-Install is not part of ASDF, but a separate piece of software.
309
ASDF-Install is also unmaintained and obsolete.
310
We recommend you use Quicklisp
311
(@uref{http://www.quicklisp.org/}) instead,
312
a Common Lisp package manager which works well and is being actively maintained.
313
If you want to download software from version control instead of tarballs,
314
so you may more easily modify it, we recommend clbuild (@uref{http://common-lisp.net/project/clbuild/}).
315
316
We recommend @file{~/common-lisp/}
as a place into which to install Common Lisp software;
317
starting with ASDF 3.1.2, it is included in the default source-registry configuration.
318

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
319
320
Finally, note that this manual is incomplete.
All the bases are covered,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
321
322
but many advanced topics are only barely alluded to,
and there is not much in terms of examples.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
323
The source code remains the ultimate source of information,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
324
free software systems in Quicklisp remain the best source of examples,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
325
326
327
and the mailing-list the best place to ask for help.


328
329
@node  Quick start summary, Loading ASDF, Introduction, Top
@chapter Quick start summary
330

331
@itemize
332
333
334
335
336

@item To load an ASDF system:

@itemize
@item
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
337
338
339
340
Load ASDF itself into your Lisp image, using
@code{(require "asdf")}.
Check that you have a recent version using @code{(asdf:asdf-version)}.
For more details, or if any of the above fails, @pxref{Loading ASDF}.
341
342

@item
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
343
344
Make sure software is installed where ASDF can find it.
The simplest way is to put all your Lisp code in subdirectories of
345
@file{~/common-lisp/} (starting with ASDF 3.1.2),
346
347
or @file{~/.local/share/common-lisp/source/}
(for ASDF 2 and later, or if you want to keep source in a hidden directory).
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
348
For more details, @pxref{Configuring ASDF to find your systems}.
349
350

@item
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
351
352
Load your system with @code{(asdf:load-system "@var{my-system}")}.
@xref{Using ASDF}.
353
354
355
356
357
358
359
360
361
362

@end itemize

@item To make your own ASDF system:

@itemize
@item
As above, load and configure ASDF.

@item
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
363
364
Make a new directory for your system, @code{@var{my-system}/},
again in a location where ASDF can find it.
365
366
All else being equal, the easiest location is probably
@file{~/common-lisp/my-system/}.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
367
@xref{Configuring ASDF to find your systems}.
368

369
370

@item
371
372
Create an ASDF system definition listing the dependencies of
your system, its components, and their interdependencies,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
373
374
and put it in @file{@var{my-system}.asd}.
This file must have the same name as your system, all lowercase.
375
@xref{Defining systems with defsystem}.
376
377

@item
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
378
Use @code{(asdf:load-system "@var{my-system}")}
379
to make sure it's all working properly. @xref{Using ASDF}.
380
381
382
383

@end itemize
@end itemize

Robert P. Goldman's avatar
Robert P. Goldman committed
384
385
@c FIXME: (1) add a sample project that the user can cut and paste to
@c get started.  (2) discuss the option of starting with Quicklisp.
386
387
388
389
390
391





@node Loading ASDF, Configuring ASDF, Quick start summary, Top
392
@comment  node-name,  next,  previous,  up
393
@chapter Loading ASDF
394

395
396
397
398
@menu
* Loading a pre-installed ASDF::
* Checking whether ASDF is loaded::
* Upgrading ASDF::
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
399
* Replacing your implementation's ASDF::
400
* Loading ASDF from source::
401
@end menu
402

403
@node  Loading a pre-installed ASDF, Checking whether ASDF is loaded, Loading ASDF, Loading ASDF
404
405
@section Loading a pre-installed ASDF

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
406
407
408
409
410
411
412
The recommended way to load ASDF is via:
@lisp
(require "asdf")
@end lisp

All actively maintained Lisp implementations now include a copy of ASDF 3
that you can load this way using Common Lisp's @code{require} function.@footnote{
413
414
NB: all implementations except GNU CLISP also accept
@code{(require "ASDF")}, @code{(require 'asdf)} and @code{(require :asdf)}.
415
For portability's sake, you should use @code{(require "asdf")}.
416
}
417

418
If the implementation you are using doesn't provide a recent ASDF 3,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
419
420
421
422
423
424
we recommend you upgrade it.
If for some reason you would rather not upgrade it,
we recommend you replace your implementation's ASDF.
@xref{Replacing your implementation's ASDF}.
If all else fails, see @pxref{Loading ASDF from source} below.

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
425
426
If you use an actively maintained implementation that fails to provide
an up-to-date enough stable release of ASDF,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
427
428
429
you may also send a bug report to your Lisp vendor and complain about it
--- or you may fix the issue yourself if it's free software.

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
As of the writing of this manual,
the following implementations provide ASDF 3 this way:
ABCL, Allegro CL, CLASP, Clozure CL, CMUCL, ECL, GNU CLISP, LispWorks, MKCL, SBCL.
The following implementations only provide ASDF 2:
MOCL, XCL.
The following implementations don't provide ASDF:
Corman CL, GCL, Genera, MCL, SCL.
The latter implementations are not actively maintained (except maybe GCL);
if some of them are ever released again, they probably will include ASDF 3.

For maximum convenience you might want to have ASDF loaded
whenever you start your Lisp implementation,
for example by loading it from the startup script or dumping a custom core
--- check your Lisp implementation's manual for details.
SLIME notably sports a @code{slime-asdf} contrib that makes life easier with ASDF.

446

447
@node Checking whether ASDF is loaded, Upgrading ASDF, Loading a pre-installed ASDF, Loading ASDF
448
449
@section Checking whether ASDF is loaded

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
450
To check that ASDF is properly loaded, you can run this form:
451
452
453
454
455
456
457

@lisp
(asdf:asdf-version)
@end lisp

If it returns a string,
that is the version of ASDF that is currently installed.
458
459
If that version is suitably recent (say, 3.1.2 or later),
then you can skip directly to next chapter: @xref{Configuring ASDF}.
460
461
462

If it raises an error,
then either ASDF is not loaded, or
463
464
you are using a very old version of ASDF,
and need to install ASDF 3.
465

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
466
467
For more precision in detecting versions old and new,
@pxref{How do I detect the ASDF version?}.
468

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
469
470
471
472
If you are experiencing problems with ASDF,
please try upgrading to the latest released version,
using the method below,
before you contact us and raise an issue.
473

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
474
@node  Upgrading ASDF, Replacing your implementation's ASDF, Checking whether ASDF is loaded, Loading ASDF
475
@section Upgrading ASDF
476
477
478
@c FIXME: tighten this up a bit -- there's a lot of stuff here that
@c doesn't matter to almost anyone.  Move discussion of updating antique
@c versions of ASDF down, or encapsulate it.
479

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
480
481
482
If your implementation already provides ASDF 3 or later (and it should),
but you want a more recent ASDF version than your implementation provides,
then you just need to ensure the more recent ASDF is installed in a configured path, like any other system.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
483
484
We recommend you download an official tarball or checkout a release from git into
@file{~/common-lisp/asdf/}.
485
486
(@pxref{Configuring ASDF to find your systems}).

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
487
Once the source code for ASDF is installed,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
488
you don't need any extra step to load it beyond the usual @code{(require "asdf")}:
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
489
ASDF 3 will automatically look whether an updated version of itself is available
490
491
amongst the regularly configured systems, before it compiles anything else.

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
492
493
If your implementation fails to provide ASDF 3 or later,
@pxref{Replacing your implementation's ASDF}.
494

495

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
496
497
@node Replacing your implementation's ASDF, Loading ASDF from source, Upgrading ASDF, Loading ASDF
@section Replacing your implementation's ASDF
498
499

All maintained implementations now provide ASDF 3 in their latest release.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
500
If your doesn't, we recommend you upgrade it.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
501

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
502
Now, if you insist on using an old implementation that didn't provide ASDF or provided an old version,
503
we recommend installing a recent ASDF, as explained below,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
504
into your implementation's installation directory.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
505
Thus your modified implementation will now provide ASDF 3.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
506
This requires proper write permissions and may necessitate execution as a system administrator.
507
508
509
510
511
512
513

The ASDF source repository contains a tool to help you upgrade your implementation's ASDF.
You can invoke it from the shell command-line as
@code{tools/asdf-tools install-asdf lispworks}
(where you can replace @code{lispworks} by the name of the relevant implementation),
or you can @code{(load "tools/install-asdf.lisp")} from your Lisp REPL.

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
514
This script works on
515
516
517
518
519
Allegro CL, Clozure CL, CMU CL, ECL, GCL, GNU CLISP, LispWorks, MKCL, SBCL, SCL, XCL.
It doesn't work on ABCL, Corman CL, Genera, MCL, MOCL.
Happily, ABCL is usually pretty up to date and shouldn't need that script.
GCL requires a very recent version, and hasn't been tested much.
Corman CL, Genera, MCL are obsolete anyway.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
520
MOCL is incomplete.
521

522

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
523
@node Loading ASDF from source,  , Replacing your implementation's ASDF, Loading ASDF
524
@section Loading ASDF from source
525

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
526
527
528
If you write build scripts that must remain portable to old machines with old implementations
that you cannot ensure have been upgraded or modified to provide a recent ASDF,
you may have to install the file @file{asdf.lisp}
529
530
531
532
533
somewhere and load it with:

@lisp
(load "/path/to/your/installed/asdf.lisp")
@end lisp
534

535
The single file @file{asdf.lisp} is all you normally need to use ASDF.
536

537
You can extract this file from latest release tarball on the
538
@url{https://common-lisp.net/project/asdf/,ASDF website}.
539
If you are daring and willing to report bugs, you can get
540
the latest and greatest version of ASDF from its git repository.
541
542
@xref{Getting the latest version}.

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
543
544
545
546
For scripts that try to use ASDF simply via @code{require} at first, and
make heroic attempts to load it the hard way if at first they don't succeed,
see @file{tools/load-asdf.lisp} distributed with the ASDF source repository,
or the code of @url{https://cliki.net/cl-launch,@code{cl-launch}}.
547

548

549
550
@node Configuring ASDF, Using ASDF, Loading ASDF, Top
@comment  node-name,  next,  previous,  up
551
552
@chapter Configuring ASDF

553
554
555
556
557
558
For standard use cases, ASDF should work pretty much out of the box.
We recommend you skim the sections on configuring ASDF to find your systems
and choose the method of installing Lisp software that works best for you.
Then skip directly to @xref{Using ASDF}. That will probably be enough.
You are unlikely to have to worry about the way ASDF stores object files,
and resetting the ASDF configuration is usually only needed in corner cases.
Robert P. Goldman's avatar
Robert P. Goldman committed
559
560
561


@menu
562
* Configuring ASDF to find your systems::
Robert P. Goldman's avatar
Robert P. Goldman committed
563
* Configuring ASDF to find your systems --- old style::
564
* Configuring where ASDF stores object files::
Robert P. Goldman's avatar
Robert P. Goldman committed
565
* Resetting the ASDF configuration::
Robert P. Goldman's avatar
Robert P. Goldman committed
566
567
@end menu

Robert P. Goldman's avatar
Robert P. Goldman committed
568
@node Configuring ASDF to find your systems, Configuring ASDF to find your systems --- old style, Configuring ASDF, Configuring ASDF
569
570
@section Configuring ASDF to find your systems

Robert P. Goldman's avatar
Robert P. Goldman committed
571
In order to compile and load your systems, ASDF must be configured to find
572
573
the @file{.asd} files that contain system definitions.

Robert P. Goldman's avatar
Robert P. Goldman committed
574
575
576
577
There are a number of different techniques for setting yourself up with
ASDF, starting from easiest to the most complex:

@itemize @bullet
578

579
@item
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
580
581
Put all of your systems in one of the standard locations,
subdirectories of
582
@itemize
583
@item
584
@file{~/common-lisp/} or
585
@item
586
@file{~/.local/share/common-lisp/source/}.
587
@end itemize
588
If you install software there, you don't need further
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
589
590
591
592
593
594
595
596
configuration.@footnote{
  @file{~/common-lisp/} is only included in
  the default configuration
  starting with ASDF 3.1.2 or later.
  If your implementation provides an earlier variant of ASDF,
  you may need to explicitly configure it to use this path,
  as further explained.
}
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
597
You can then skip to the next section. @xref{Loading a system}.
Robert P. Goldman's avatar
Robert P. Goldman committed
598

599
@item
600
If you're using some tool to install software (e.g. Quicklisp),
601
602
the authors of that tool should already have configured ASDF.

603
@item
Robert P. Goldman's avatar
Robert P. Goldman committed
604
605
606
607
If you have more specific desires about how to lay out your software on
disk, the preferred way to configure where ASDF finds your systems is
the @code{source-registry} facility,
fully described in its own chapter of this manual.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
@xref{Controlling where ASDF searches for systems}.
Here is a quick recipe for getting started.

First create the directory
@file{~/.config/common-lisp/source-registry.conf.d/}@footnote{
  For Windows users, and starting with ASDF 3.1.5, start from your
  @file{%LOCALAPPDATA%}, which is usually @file{~/AppData/Local/}
  (but you can ask in a @code{CMD.EXE} terminal
  @code{echo %LOCALAPPDATA%} to make sure)
  and underneath create a subpath
  @file{config/common-lisp/source-registry.conf.d/}.
};
there create a file with any name of your choice
but with the type @file{conf}@footnote{
  By requiring the @file{.conf}
  extension, and ignoring other files, ASDF allows you to have disabled files,
  editor backups, etc. in the same directory with your active
  configuration files.

  ASDF will also ignore files whose names start with a @file{.} character.

  It is customary to start the filename with two digits, to control the
  sorting of the @code{conf} files in the source registry directory, and
  thus the order in which the directories will be scanned.
},
for instance @file{50-luser-lisp.conf};
in this file, add the following line
to tell ASDF to recursively scan all the subdirectories under @file{/home/luser/lisp/}
for @file{.asd} files:
@kbd{(:tree "/home/luser/lisp/")}
638

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
639
640
641
642
643
644
That's enough. You may replace @file{/home/luser/lisp/} by wherever you want to install your source code.
You don't actually need to specify anything if you use the default @file{~/common-lisp/} as above
and your implementation provides ASDF 3.1.2 or later.
If your implementation provides an earlier variant of ASDF 3,
you might want to specify @kbd{(:tree (:home "common-lisp/"))} for bootstrap purposes,
then install a recent source tree of ASDF under @file{~/common-lisp/asdf/}.
645

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
646
647
648
649
If you prefer to use a ``link farm'', which is faster to use but costlier to manage than a recursive traversal,
say at @file{/home/luser/.asd-link-farm/}, then
you may instead (or additionally) create a file @file{42-asd-link-farm.conf}, containing the line:
@kbd{(:directory "/home/luser/.asd-link-farm/")}
650
651
652

ASDF will automatically read your configuration
the first time you try to find a system.
Robert P. Goldman's avatar
Robert P. Goldman committed
653
If necessary, you can reset the source-registry configuration with:
654

655
656
657
658
@lisp
(asdf:clear-source-registry)
@end lisp

Robert P. Goldman's avatar
Robert P. Goldman committed
659
660
@item
In earlier versions of ASDF, the system source registry was configured
661
662
663
664
using a global variable, @code{asdf:*central-registry*}.
For more details about this, see the following section,
@ref{Configuring ASDF to find your systems --- old style}.
Unless you need to understand this,
Robert P. Goldman's avatar
Robert P. Goldman committed
665
skip directly to @ref{Configuring where ASDF stores object files}.
666

Robert P. Goldman's avatar
Robert P. Goldman committed
667
668
669
670
671
672
673
@end itemize

Note that your Operating System distribution or your system administrator
may already have configured system-managed libraries for you.



674
@node Configuring ASDF to find your systems --- old style, Configuring where ASDF stores object files, Configuring ASDF to find your systems, Configuring ASDF
Robert P. Goldman's avatar
Robert P. Goldman committed
675
676
@section Configuring ASDF to find your systems --- old style

677
678
679

@c FIXME: this section should be moved elsewhere.  The novice user
@c should not be burdened with it. [2014/02/27:rpg]
Robert P. Goldman's avatar
Robert P. Goldman committed
680

681
682
683
684
685
Novices may skip this section.
@c ``Experts may read it then proceed to ...''
@c some better section explaining
@c *central-registry* vs source-registry vs *system-definition-search-functions*,
@c and .../asdf/tools/cl-source-registry-cache.lisp
686
687
688
689
690
691
692
693
694
695
696
697

The old way to configure ASDF to find your systems is by
@code{push}ing directory pathnames onto the variable
@code{asdf:*central-registry*}.

You must configure this variable between the time you load ASDF
and the time you first try to use it.
Loading and configuring ASDF presumably happen
as part of some initialization script that builds or starts
your Common Lisp software system.
(For instance, some SBCL users used to put it in their @file{~/.sbclrc}.)

698
The @code{asdf:*central-registry*} is empty by default in ASDF 2 or ASDF 3,
699
but is still supported for compatibility with ASDF 1.
700
When used, it takes precedence over the above source-registry.@footnote{
701
702
703
704
705
It is possible to further customize
the system definition file search.
That's considered advanced use, and covered later:
search forward for
@code{*system-definition-search-functions*}.
706
@xref{Defining systems with defsystem}.}
707

708
709
For example, let's say you want ASDF to find the @file{.asd} file
@file{/home/me/src/foo/foo.asd}.
710
In your Lisp initialization file, you could have the following:
711
712

@lisp
713
(require "asdf")
714
715
716
717
718
(push "/home/me/src/foo/" asdf:*central-registry*)
@end lisp

Note the trailing slash: when searching for a system,
ASDF will evaluate each entry of the central registry
719
and coerce the result to a pathname.@footnote{
720
ASDF will indeed call @code{eval} on each entry.
721
It will skip entries that evaluate to @code{nil}.
722
723

Strings and pathname objects are self-evaluating,
724
in which case the @code{eval} step does nothing;
725
726
727
but you may push arbitrary s-expressions onto the central registry.
These s-expressions may be evaluated to compute context-dependent
entries, e.g. things that depend
728
729
730
731
732
733
on the value of shell variables or the identity of the user.

The variable @code{asdf:*central-registry*} is thus a list of
``system directory designators''.
A @dfn{system directory designator} is a form
which will be evaluated whenever a system is to be found,
734
and must evaluate to a directory to look in (or @code{nil}).
735
736
By ``directory'', we mean
``designator for a pathname with a non-empty DIRECTORY component''.
737
}
738
The trailing directory name separator
739
is necessary to tell Lisp that you're discussing a directory
740
741
742
rather than a file.  If you leave it out, ASDF is likely to look in
@code{/home/me/src/} instead of @code{/home/me/src/foo/} as you
intended, and fail to find your system definition.
743

744
745
746
Typically there are a lot of @file{.asd} files, and
a common idiom was to put
@emph{symbolic links} to all of one's @file{.asd} files
747
748
in a common directory
and push @emph{that} directory (the ``link farm'')
749
750
751
752
753
754
onto
@code{asdf:*central-registry*},
instead of pushing each individual system directory.

ASDF knows to follow @emph{symlinks}
to the actual location of the systems.@footnote{
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
755
756
757
  On Windows, you can use Windows shortcuts instead of POSIX symlinks.
  if you try aliases under MacOS, we are curious to hear about your experience.
}
758

759
For example, if @code{#p"/home/me/cl/systems/"}
760
761
is an element of @code{*central-registry*}, you could set up the
system @var{foo} as follows:
762
763
764
765
766
767

@example
$ cd /home/me/cl/systems/
$ ln -s ~/src/foo/foo.asd .
@end example

768
This old style for configuring ASDF is not recommended for new users,
769
770
but it is supported for old users, and for users who want a simple way to
programmatically control what directories are added to the ASDF search path.
771

772

Robert P. Goldman's avatar
Robert P. Goldman committed
773
@node Configuring where ASDF stores object files, Resetting the ASDF configuration, Configuring ASDF to find your systems --- old style, Configuring ASDF
774
@section Configuring where ASDF stores object files
775
@findex clear-output-translations
776
777
778
779
780

ASDF lets you configure where object files will be stored.
Sensible defaults are provided and
you shouldn't normally have to worry about it.

781
This allows the same source code repository to be shared
782
between several versions of several Common Lisp implementations,
783
784
785
786
between several users using different compilation options,
with users who lack write privileges on shared source directories, etc.
This also keeps source directories from being cluttered
with object/fasl files.
787

788
Starting with ASDF 2, the @code{asdf-output-translations} facility
789
was added to ASDF itself.  This facility controls where object files will be stored.
790
This facility is fully described in a chapter of this manual,
791
@ref{Controlling where ASDF saves compiled files}.
792

793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
@c FIXME: possibly this should be moved elsewhere.  It's redundant here,
@c and makes this section of the manual too long and daunting for the
@c new user. [2014/02/27:rpg]
@c The simplest way to add a translation to your search path,
@c say from @file{/foo/bar/baz/quux/}
@c to @file{/where/i/want/my/fasls/}
@c is to create the directory
@c @file{~/.config/common-lisp/asdf-output-translations.conf.d/}
@c and there create a file with any name of your choice and the type @file{conf},
@c for instance @file{42-bazquux.conf}
@c containing the line:

@c @kbd{("/foo/bar/baz/quux/" "/where/i/want/my/fasls/")}

@c To disable output translations for source under a given directory,
@c say @file{/toto/tata/}
@c you can create a file @file{40-disable-toto.conf}
@c with the line:

@c @kbd{("/toto/tata/")}

@c To wholly disable output translations for all directories,
@c you can create a file @file{00-disable.conf}
@c with the line:

@c @kbd{(t t)}

@c Note that your Operating System distribution or your system administrator
@c may already have configured translations for you.
@c In absence of any configuration, the default is to redirect everything
@c under an implementation-dependent subdirectory of @file{~/.cache/common-lisp/}.
@c @xref{Controlling where ASDF searches for systems}, for full details.

@c The required @file{.conf} extension allows you to have disabled files
@c or editor backups (ending in @file{~}), and works portably
@c (for instance, it is a pain to allow both empty and non-empty extension on CLISP).
@c Excluded are files the name of which start with a @file{.} character.
@c It is customary to start the filename with two digits
@c that specify the order in which the directories will be scanned.

@c ASDF will automatically read your configuration
@c the first time you try to find a system.
@c You can reset the source-registry configuration with:

@c @lisp
@c (asdf:clear-output-translations)
@c @end lisp
840

841
842
843
844
845
846
@c And you probably should do so before you dump your Lisp image,
@c if the configuration may change
@c between the machine where you save it at the time you save it
@c and the machine you resume it at the time you resume it.
@c (Once again, you should use @code{(asdf:clear-configuration)}
@c before you dump your Lisp image, which includes the above.)
847

848
Note that before ASDF 2,
849
850
851
852
other ASDF add-ons offered the same functionality,
each in subtly different and incompatible ways:
ASDF-Binary-Locations, cl-launch, common-lisp-controller.
ASDF-Binary-Locations is now not needed anymore and should not be used.
853
cl-launch 3.000 and common-lisp-controller 7.2 have been updated
854
to delegate object file placement to ASDF.
855

856
@node Resetting the ASDF configuration,  , Configuring where ASDF stores object files, Configuring ASDF
Robert P. Goldman's avatar
Robert P. Goldman committed
857
858
@section Resetting the ASDF configuration

859
860
@c FIXME: this should probably be moved out of the "quickstart" part of
@c the manual. [2014/02/27:rpg]
Robert P. Goldman's avatar
Robert P. Goldman committed
861

862
863
864
865
866
867

When you dump and restore an image, or when you tweak your configuration,
you may want to reset the ASDF configuration.
For that you may use the following function:

@defun clear-configuration
868
   Undoes any ASDF configuration
869
870
871
   regarding source-registry or output-translations.
@end defun

872
@vindex *image-dump-hook*
873
874
875
876
877
878
879
880
881
This function is pushed onto the @code{uiop:*image-dump-hook*} by default,
which means that if you save an image using @code{uiop:dump-image},
or via @code{asdf:image-op} and @code{asdf:program-op},
it will be automatically called to clear your configuration.
If for some reason you prefer to call your implementation's underlying functionality,
be sure to call @code{clear-configuration} manually,
or push it into your implementation's equivalent of @code{uiop:*image-dump-hook*},
e.g. @code{sb-ext:*save-hooks*} on SBCL, or @code{ext:*before-save-initializations*}
on CMUCL and SCL, etc.
882

883
@node  Using ASDF, Defining systems with defsystem, Configuring ASDF, Top
884
885
@chapter Using ASDF

Robert P. Goldman's avatar
Robert P. Goldman committed
886
887
@menu
* Loading a system::
888
* Convenience Functions::
Robert P. Goldman's avatar
Robert P. Goldman committed
889
890
891
* Moving on::
@end menu

892
@node Loading a system, Convenience Functions, Using ASDF, Using ASDF
893
894
895
896
@section Loading a system

The system @var{foo} is loaded (and compiled, if necessary)
by evaluating the following Lisp form:
897
898

@example
899
(asdf:load-system :@var{foo})
900
901
@end example

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
902
903
On some implementations (@pxref{Convenience Functions}),
ASDF hooks into the @code{cl:require} facility and you can just use:
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
904
905
906
907
908

@example
(require :@var{foo})
@end example

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
909
910
911
Note that the canonical name of a system is a string, conventionally lowercase.
A system name can also be specified as a symbol (including a keyword),
in which case its @code{symbol-name} is taken and lowercased.
912
The name must be a suitable value for the @code{:name} initarg
913
to @code{make-pathname} in whatever filesystem the system is to be found.
914

915
916
The lower-casing-symbols behaviour is unconventional,
but was selected after some consideration.
917
918
919
920
921
The type of systems we want to support
either have lowercase as customary case (Unix, Mac, Windows)
or silently convert lowercase to uppercase (lpns).
@c so this makes more sense than attempting to use @code{:case :common},
@c which is reported not to work on some implementations
922

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
923

924
925
@node Convenience Functions, Moving on, Loading a system, Using ASDF
@section Convenience Functions
Robert Goldman's avatar
Robert Goldman committed
926

927
928
929
930
931
932
933
@c I believe thes are all unnecessary because of the function macros
@c below [2016/01/30:rpg]
@c @findex load-system
@c @findex compile-system
@c @findex test-system
@c @findex require-system
@c @findex make
934

935
ASDF provides three commands for the most common system operations:
936
@code{load-system}, @code{compile-system}, and @code{test-system}.
937
938
939
940
941
942
943
944
945
946
947
948

ASDF also provides @code{require-system}, a variant of @code{load-system}
that skips loading systems that are already loaded.  This is sometimes
useful, for example, in order to avoid re-loading libraries that come
pre-loaded into your  lisp implementation.

ASDF also provides @code{make}, a way of allowing system developers to
choose a default operation for their systems.  For example, a developer
who has created a system intended to format a specific document, might
make document-formatting the default operation invoked by @code{make},
instead of loading.  If the system developer doesn't specify in the
system definition, the default operation will be loading.
949

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
950
951
@c FIXME: We seem to export @findex bundle-system also, that some ECL users seem to rely on.
@c But it's probably better that bundle operations have their own manual chapter at some point.
952

953
954
955
956

@c FIXME: There should be a @defun for OPERATE, but there isn't.  Not
@c sure where it belongs...  The discussion here is just confusing if
@c the reader doesn't understand how ASDF works. [2016/01/30:rpg]
957
958
959
@findex operate
@findex oos

960
961
Because ASDF is an extensible system
for defining @emph{operations} on @emph{components},
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
962
963
it also provides a generic function @code{operate},
so you may arbitrarily operate on your systems beyond the default operations.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
964
965
966
(At the interactive REPL, users often use its shorter alias @code{oos},
which stands for operate-on-system, a name inherited from @code{mk-defsystem}.)
You'll use @code{operate} whenever you want to do something beyond
967
compiling, loading and testing.
968

969
970
@c Reminder: before ASDF can operate on a system, however,
@c it must be able to find and load that system's definition.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
971
@c @xref{Configuring ASDF to find your systems}.
972

973
974
@c FIXME: the following is too complicated for here, especially since
@c :force hasn't been defined yet.  Move it. [2014/02/27:rpg]
975

976
@vindex *load-system-operation*
977
@findex already-loaded-systems
978
979
980

@defun load-system system @Arest{} keys @Akey{} force force-not verbose version @AallowOtherKeys{}
Apply @code{operate} with the operation from
981
@code{*load-system-operation*}
982
the @var{system}, and any provided keyword arguments.
983
@code{*load-system-operation*} by default is @code{load-op};
984
985
986
987
988
it would be @code{load-bundle-op} by default on ECL,
if only an implementation bug were fixed.
Calling @code{load-system} is the regular, recommended way
to load a system into the current image.
@end defun
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
989

990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
@defun compile-system system @Arest{} keys @Akey{} force force-not verbose version @AallowOtherKeys{}
Apply @code{operate} with the operation @code{compile-op},
the @var{system}, and any provided keyword arguments.
This will make sure all the files in the system are compiled,
but not necessarily load any of them in the current image;
on most systems, it will @emph{not} load all compiled files in the current image.
This function exists for symmetry with @code{load-system} but is not recommended
unless you are writing build scripts and know what you're doing.
But then, you might be interested in @code{program-op} rather than @code{compile-op}.
@end defun

@defun test-system system @Arest{} keys @Akey{} force force-not verbose version @AallowOtherKeys{}
Apply @code{operate} with the operation @code{test-op},
the @var{system}, and any provided keyword arguments.
@xref{test-op}.
@end defun

@defun make system @Arest{} keys @Akey{} @AallowOtherKeys{}
Do ``The Right Thing'' with your system.
Starting with ASDF 3.1, this function @code{make} is also available.
The default behaviour is to load the system as if by @code{load-system};
but system authors can override this default in their system definition
they may specify an alternate operation as the intended use of their system,
1013
1014
1015
1016
with a @code{:build-operation} option in the @code{defsystem} form
(@pxref{The defsystem grammar, build-operation}),
and an intended output pathname for that operation with
@code{:build-pathname}.
1017
1018
@c Document :build-operation in the defsystem section.
@c Document in the extension section that for richer programmatic access, you may instead use an overriding
1019
1020
1021
@c @code{(defmethod component-depends-on ((o build-op) (s system))
@c ...)}.
This function is experimental and largely untested.  Use at your own risk.
1022
@end defun
1023
@cindex build-operation
1024

1025
@defun require-system system @Arest{} keys @Akey{} @AallowOtherKeys{}
1026
@code{require-system} skips any update to systems that have already been loaded,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1027
in the spirit of @code{cl:require}.
1028
1029
It does it by calling @code{load-system} with a keyword option
excluding already loaded systems.@footnote{
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1030
1031
  For the curious, the option is @code{:force-not (already-loaded-systems)}.
}.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1032
1033
1034
1035
1036
On actively maintained free software implementations
(namely recent versions of ABCL, Clozure CL, CMUCL, ECL, GNU CLISP, MKCL and SBCL),
once ASDF itself is loaded, @code{cl:require} too can load ASDF systems,
by falling back on @code{require-system}
for module names not recognized by the implementation.
1037
1038
(Note however that @code{require-system} does @emph{not} fall back on @code{cl:require};
that would introduce an ``interesting'' potential infinite loop to break somehow.)
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1039

1040
@code{cl:require} and @code{require-system} are appropriate to load code
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1041
that is not being modified during the current programming session.
1042
1043
1044
1045
1046
1047
1048
1049
@code{cl:require} will notably load the implementation-provided extension modules;
@code{require-system} won't, unless they are also defined as systems somehow,
which SBCL and MKCL do.
@code{require-system} may also be used to load any number of ASDF systems
that the user isn't either developing or debugging,
for which a previously installed version is deemed to be satisfactory;
@code{cl:require} on the above-mentioned implementations will delegate to @code{require-system}
and may load them as well.
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1050
But for code that you are actively developing, debugging, or otherwise modifying,
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
1051
you should use @code{load-system}, so ASDF will pick on your modifications
1052
1053
1054
1055
and transitively re-build the modified files and everything that depends on them
(that the requested @var{system} itself depends on ---
ASDF itself never builds anything unless
it's an explicitly requested system or the dependencies thereof).
1056
1057
@end defun

1058
1059

@node Moving on,  , Convenience Functions, Using ASDF
1060
@section Moving on
1061

1062
1063
1064
1065
1066
That's all you need to know to use ASDF to load systems written by others.
The rest of this manual deals with writing system definitions
for Common Lisp software you write yourself,
including how to extend ASDF to define new operation and component types.

1067

1068
@node Defining systems with defsystem, The object model of ASDF, Using ASDF, Top
1069
1070
1071
@comment  node-name,  next,  previous,  up
@chapter Defining systems with defsystem

1072
This chapter describes how to use ASDF to define systems and develop
1073
1074
1075
1076
software.


@menu
1077
1078
1079
1080
* The defsystem form::
* A more involved example::
* The defsystem grammar::
* Other code in .asd files::
1081
* The package-inferred-system extension::
1082
1083
1084
1085
1086
@end menu

@node  The defsystem form, A more involved example, Defining systems with defsystem, Defining systems with defsystem
@comment  node-name,  next,  previous,  up
@section The defsystem form
1087
@findex defsystem
1088
1089
@cindex asdf-user
@findex load-asd
1090