61
@node Top, Using asdf to load systems, (dir), (dir)
62
@node Top, Introduction, (dir), (dir)
62
63
@top asdf: another system definition facility
67
* Using asdf to load systems::
68
* Defining systems with defsystem::
69
* The object model of asdf::
71
* Compilation error and warning handling::
69
* Using asdf to load systems::
70
* Defining systems with defsystem::
71
* The object model of asdf::
72
* Controlling where ASDF saves compiled files::
74
* Compilation error and warning handling::
72
75
* Miscellaneous additional functionality::
73
* Getting the latest version::
75
* missing bits in implementation::
78
* Function and Class Index::
76
* Getting the latest version::
78
* missing bits in implementation::
81
* Function and Class Index::
82
85
--- The Detailed Node Listing ---
89
@c * Installing ASDF::
84
91
Defining systems with defsystem
86
* The defsystem form::
87
* A more involved example::
88
* The defsystem grammar::
93
* The defsystem form::
94
* A more involved example::
95
* The defsystem grammar::
96
* Other code in .asd files::
90
98
The object model of asdf
97
* Predefined operations of asdf::
98
* Creating new operations::
105
* Predefined operations of asdf::
106
* Creating new operations::
102
* Common attributes of components::
103
* Pre-defined subclasses of component::
104
* Creating new component types::
110
* Common attributes of components::
111
* Pre-defined subclasses of component::
112
* Creating new component types::
108
* Pre-defined subclasses of component::
109
* Creating new component types::
116
* Pre-defined subclasses of component::
117
* Creating new component types::
116
124
@c -------------------
119
@node Using asdf to load systems, Defining systems with defsystem, Top, Top
120
@comment node-name, next, previous, up
121
@chapter Using asdf to load systems
126
@node Introduction, Using asdf to load systems, Top, Top
127
@comment node-name, next, previous, up
128
@chapter Introduction
130
ASDF is Another System Definition Facility: a tool for describing the
131
sub-systems and files that comprise a system and for operating on these
132
components in the right order so that they can be compiled, loaded,
135
ASDF presents two faces: one for system implementors who need to be able
136
to describe their systems and one for Lisp programmers who want to use
137
those systems. @xref{Using asdf to load systems,the getting started guide}, to learn how to use ASDF to
138
load a system. @xref{Defining systems with defsystem}, to learn how to
139
define a system of your own. Later chapters describe the ASDF internals
140
and how to extend ASDF.
143
@node Using asdf to load systems, Defining systems with defsystem, Introduction, Top
144
@comment node-name, next, previous, up
146
@vindex *central-registry*
149
@findex compile-system
122
151
@cindex system directory designator
123
@vindex *central-registry*
125
This chapter describes how to use asdf to compile and load ready-made
126
Lisp programs and libraries.
128
@section Downloading asdf
130
Some Lisp implementations (such as SBCL and OpenMCL) come with asdf
131
included already, so you don't need to download it separately.
132
Consult your Lisp system's documentation. If you need to download
133
asdf and install it by hand, the canonical source is the cCLan CVS
135
@url{http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cclan/asdf/}.
137
@section Setting up asdf
156
@c * Installing ASDF::
159
@section Installing ASDF
161
Many Lisp implementations include a copy of ASDF. You can
162
usually load this copy using Common-Lisp's @code{require}
165
@kbd{(require 'asdf)}
167
Consult your Lisp implementation's documentation for details. If ASDF
168
doesn't come bundled with your Lisp or if you want to make
169
sure that you have the most recent version, then you'll want
170
to download it from the
171
@url{http://common-lisp.net/project/asdf/,asdf-home} website.
173
Note to SBCL users: you are cautioned that installing ASDF yourself may
174
break some SBCL contribs. We are working to provide instructions for
177
If you want to get the latest and greatest version of ASDF from its VCS
178
repository, @xref{Getting the latest version}.
180
@section Loading ASDF
182
If your CL implementation does @emph{not} provide ASDF through the
183
@code{require} feature, then you need to download ASDF and load it
139
186
The single file @file{asdf.lisp} is all you need to use asdf normally.
140
187
Once you load it in a running Lisp, you're ready to use asdf. For
143
190
startup script or dumping a custom core -- check your Lisp
144
191
implementation's manual for details.
193
@section Setting up a system to be loaded
195
To compile and load a system, you need to ensure that its
196
system definition can be found in one of the directories in
197
@code{*central-registry*}@footnote{It is possible to customize the
198
system definition file search. That's considered advanced use, and
199
covered later: search forward for
200
@code{*system-definition-search-functions*}. @xref{Defining systems
203
There are two ways that you can make a system definition findable
204
through @code{*central-registry*}. One is to simply insert into
205
@code{*central-registry*} an entry that specifies the pathname of for
206
the directory containing the system definition file (a file whose name
207
is of the form @code{*.asd}).
208
For example, if we had a
209
system @var{foo} that is stored in a directory
210
@file{/home/me/src/foo/}, containing @file{/home/me/src/foo/}, we could
211
make the foo system asdf-operable by doing @kbd{(push
212
"/home/me/src/foo/" asdf:*central-registry*)}.
214
ASDF will also properly handle the case where the
215
@code{*central-registry*} points to a directory containing a
216
@emph{symbolic link} to the system definition file.
218
For example, if @code{#p"/home/me/cl/systems/"} (note the trailing
219
slash) is a member of @code{*central-registry*}, you could set up the
220
system @var{foo} for loading with asdf with the following
221
commands at the shell:
224
$ cd /home/me/cl/systems/
225
$ ln -s ~/src/foo/foo.asd .
228
Previous versions of the ASDF manual suggested that users create a
229
directory in their @code{*central-registry*} that would act as a ``link
230
farm.'' However, this method may cause problems if you work on multiple
231
lisp projects that contain different mixes of ASDF libraries.
146
233
The variable @code{asdf:*central-registry*} is a list of ``system
147
234
directory designators''@footnote{When we say ``directory'' here, we
148
235
mean ``designator for a pathname with a supplied DIRECTORY
159
246
asdf:*central-registry*))
162
@section Setting up a system to be loaded
164
To compile and load a system, you need to ensure that a symbolic link to its
165
system definition is in one of the directories in
166
@code{*central-registry*}@footnote{It is possible to customize the
167
system definition file search. That's considered advanced use, and
168
covered later: search forward for
169
@code{*system-definition-search-functions*}. @xref{Defining systems
172
For example, if @code{#p"/home/me/cl/systems/"} (note the trailing
173
slash) is a member of @code{*central-registry*}, you would set up a
174
system @var{foo} that is stored in a directory
175
@file{/home/me/src/foo/} for loading with asdf with the following
176
commands at the shell (this has to be done only once):
179
$ cd /home/me/cl/systems/
180
$ ln -s ~/src/foo/foo.asd .
183
249
@section Loading a system
251
@c{FIXME: Add Gary's material about loading system definitions by hand.}
252
@c{FIXME: Introduce ASDF-binary-locations.}
185
254
The system @var{foo} is loaded (and compiled, if necessary) by
186
255
evaluating the following form in your Lisp implementation:
189
(asdf:operate 'asdf:load-op '@var{foo})
258
(asdf:load-system '@var{foo})
261
(In older versions of ASDF, you may need to use @code{(asdf:oos
262
'asdf:load-op 'foo)}, instead.)
192
264
Output from asdf and asdf extensions are supposed to be sent to the CL
193
265
stream @code{*standard-output*}, and so rebinding that stream around
194
266
calls to @code{asdf:operate} should redirect all output from asdf
269
ASDF provides three commands for the most common system
270
operations: @code{load-system}, @code{compile-system} or @code{test-system}.
272
Because ASDF is an extensible system for defining
273
@emph{operations} on @emph{components} also provides a generic
274
function: @code{operate} (which is usually abbreviated by
275
@code{oos}). You'll use @code{oos} whenever you want to do something
276
beyond compiling, loading and testing.
278
Reminder: before ASDF can operate on a system, however, it must be able
279
to find and load that system's definition.
281
@section Placement of compiled files
283
By default, ASDF will place the compiled files it creates in the same
284
directory as the source files. This works for most simple use cases.
285
However, if you use multiple Common Lisp implementations, or for some
286
other reason need to place your compiled files elsewhere, you will want
287
to enable ASDF-BINARY-LOCATIONS. @xref{Controlling where ASDF saves
296
load @file{asdf.lisp} into your Lisp image, either through
297
@code{require} or @code{load}.
300
make sure ASDF can find system definitions by loading them
301
yourself or setting up @code{*central-registry*}.
304
use @code{operate} (or shorthand @code{oos})
305
to tell ASDF what you'd like to do to what systems.
306
For simple operations, you can use @code{load-system}, @code{compile-system} or @code{test-system}
197
313
That's all you need to know to use asdf to load systems written by
198
314
others. The rest of this manual deals with writing system
199
definitions for Lisp software you write yourself.
315
definitions for Lisp software you write yourself, including how to
316
extend ASDF to define new operation and component types.
201
318
@node Defining systems with defsystem, The object model of asdf, Using asdf to load systems, Top
202
319
@comment node-name, next, previous, up
558
678
operation - at least, where meaningful.
561
@deffn Operation test-system-version &key minimum
563
Asks the system whether it satisfies a version requirement.
565
The default method accepts a string, which is expected to contain of a
566
number of integers separated by #\. characters. The method is not
567
recursive. The component satisfies the version dependency if it has
568
the same major number as required and each of its sub-versions is
569
greater than or equal to the sub-version number required.
572
(defun version-satisfies (x y)
573
(labels ((bigger (x y)
576
((> (car x) (car y)) t)
578
(bigger (cdr x) (cdr y))))))
579
(and (= (car x) (car y))
580
(or (not (cdr y)) (bigger (cdr x) (cdr y))))))
583
If that doesn't work for your system, you can override it. I hope
584
you have as much fun writing the new method as @verb{|#lisp|} did
585
reimplementing this one.
588
@deffn Operation feature-dependent-op
590
An instance of @code{feature-dependent-op} will ignore any components
591
which have a @code{features} attribute, unless the feature combination
592
it designates is satisfied by @code{*features*}. This operation is
593
not intended to be instantiated directly, but other operations may
681
@deffn Operation test-op
683
This operation will perform some tests on the module. The default
684
method will do nothing. The default dependency is to require
685
@code{load-op} to be performed on the module first. The default
686
@code{operation-done-p} is that the operation is @emph{never} done ---
687
we assume that if you invoke the @code{test-op}, you want to test the
688
system, even if you have already done so.
690
The results of this operation are not defined by ASDF. It has proven
691
difficult to define how the test operation should signal its results to
692
the user in a way that is compatible with all of the various test
693
libraries and test techniques in use in the community.
696
@c @deffn Operation test-system-version &key minimum
698
@c Asks the system whether it satisfies a version requirement.
700
@c The default method accepts a string, which is expected to contain of a
701
@c number of integers separated by #\. characters. The method is not
702
@c recursive. The component satisfies the version dependency if it has
703
@c the same major number as required and each of its sub-versions is
704
@c greater than or equal to the sub-version number required.
707
@c (defun version-satisfies (x y)
708
@c (labels ((bigger (x y)
711
@c ((> (car x) (car y)) t)
712
@c ((= (car x) (car y))
713
@c (bigger (cdr x) (cdr y))))))
714
@c (and (= (car x) (car y))
715
@c (or (not (cdr y)) (bigger (cdr x) (cdr y))))))
718
@c If that doesn't work for your system, you can override it. I hope
719
@c you have as much fun writing the new method as @verb{|#lisp|} did
720
@c reimplementing this one.
723
@c @deffn Operation feature-dependent-op
725
@c An instance of @code{feature-dependent-op} will ignore any components
726
@c which have a @code{features} attribute, unless the feature combination
727
@c it designates is satisfied by @code{*features*}. This operation is
728
@c not intended to be instantiated directly, but other operations may
598
733
@node Creating new operations, , Predefined operations of asdf, Operations
599
734
@comment node-name, next, previous, up
984
@node Error handling, Compilation error and warning handling, The object model of asdf, Top
1124
@node Controlling where ASDF saves compiled files, Error handling, The object model of asdf, Top
1125
@comment node-name, next, previous, up
1126
@chapter Controlling where ASDF saves compiled files
1127
@cindex ASDF-binary-locations
1129
Each Common Lisp implementation has its own format for
1130
compiled files (fasls for short). If you use multiple
1131
implementations (or multiple versions of the same
1132
implementation), you'll soon find your source directories
1133
littered with various `DFSL`s, `FASL`s, `CFSL`s and so on.
1134
Worse yet, some implementations use the same file extension
1135
or change formats from version to version which means that
1136
you'll have to recompile binaries as you switch from one
1137
implementation to the next.
1139
As of version 1.365, ASDF includes @emph{ASDF-binary-locations} to
1140
mitigate the problem.
1142
@section Default locations
1143
@findex output-files-for-system-and-operation
1145
The default binary location for each Lisp implementation is a
1146
subdirectory of each source directory. To account for different Lisps,
1147
Operating Systems, Implementation versions, and so on, ASDF borrows code
1148
from SLIME to create reasonable custom directory names. Here are
1152
@item SBCL, version 1.0 on Mac OS X for intel: @code{sbcl-1.0-darwin-x86}
1154
@item Franz Allegro, version 8.0, ANSI Common Lisp: @code{allegro-8.0a-macosx-x86}
1156
@item Franz Allegro, version 8.1, Modern (case sensitive) Common Lisp: @code{allegro-8.1m-macosx-x86}
1159
If you want to keep compiled files out of the source tree entirely, use
1160
@code{*centralize-lisp-binaries*} to put compiled files into
1161
sub-directories of a single central location (see below).
1163
Here is a summary of the variables that control ASDF's source-to-binary
1164
mappings. All of them are in the ASDF package, so must be set
1165
@emph{after} loading ASDF.
1167
@defvar *enable-asdf-binary-locations*
1168
If false, then ASDF will place binaries in the same directory as the
1169
source. If true, then ASDF will move the binaries using the rest of
1170
the configuration. Defaults to @code{nil}.
1173
@defvar *centralize-lisp-binaries*
1174
If true, compiled lisp files
1175
without an explicit mapping (see @code{*source-to-target-mappings*})
1176
will be placed in subdirectories of
1177
@code{*default-toplevel-directory*}. If false, then compiled lisp
1178
files without an explicit mapping will be placed in subdirectories
1179
of their sources. Defaults to @code{nil}.
1182
@defvar *default-toplevel-directory*
1184
@code{*centralize-lisp-binaries*} is true, then compiled lisp files
1185
without an explicit mapping (see @code{*source-to-target-mappings*})
1186
will be placed in subdirectories of
1187
@code{*default-toplevel-directory*}. Defaults to a sub-directory
1188
named `.fasls` in the current user's home directory.
1191
@defvar *include-per-user-information*
1192
specifies whether or not
1193
to include user information in the directory. Only used when
1194
@code{*centralize-lisp-binaries*} is true. Defaults to @code{nil}.
1197
@defvar *map-all-source-files*
1198
If true, then all source files
1199
will be mapped by ASDF. If @code{nil}, then only Common Lisp Source
1200
Files (i.e., instances of cl-source-file or its subclasses) will
1201
be. Defaults to @code{nil}.
1204
@defvar *source-to-target-mappings*
1205
This specifies mappings
1206
from source to target. If the target is nil, then it
1207
means to *not* map the source to anything. I.e., to leave
1208
it as is. This has the effect of turning off
1209
ASDF-Binary-Locations for the given source directory. The
1210
default depends on the Lisp implementation.
1213
These variables are used by
1214
@code{output-files-for-system-and-operation} to determine where to
1215
place a source file's binary. You can further customize asdf-binary-locations
1216
by writing additional methods on the generic function
1217
@code{output-files-for-system-and-operation}.
1219
@c See the [manual][binary-locations] for more details.
1221
@subsection Notes and Issues
1223
SBCL ships with several included ASDF libraries which used to confuse
1224
ABL because it would try to recompile the FASLs and then run into
1225
directory permission problems. ASDF knows about these and uses a mapping
1226
like @file{/usr/local/lib/sbcl} to @code{nil} so that the FASLs are not
1229
@node Error handling, Compilation error and warning handling, Controlling where ASDF saves compiled files, Top
985
1230
@comment node-name, next, previous, up
986
1231
@chapter Error handling
987
1232
@findex SYSTEM-DEFINITION-ERROR
1033
1280
@comment node-name, next, previous, up
1034
1281
@chapter Getting the latest version
1283
@emph{FIXME: Need to revise this to give information about the git repository.}
1038
1285
Decide which version you want. HEAD is the newest version and
1039
1286
usually OK, whereas RELEASE is for cautious people (e.g. who already
1040
1287
have systems using asdf that they don't want broken), a slightly older
1041
1288
version about which none of the HEAD users have complained.
1044
Check it out from sourceforge cCLan CVS:
1046
@kbd{cvs -d:pserver:anonymous@@cvs.cclan.sourceforge.net:/cvsroot/cclan login}
1048
(no password: just press @key{Enter})
1050
@kbd{cvs -z3 -d:pserver:anonymous@@cvs.cclan.sourceforge.net:/cvsroot/cclan co -r RELEASE asdf}
1052
or for the bleeding edge, instead
1054
@kbd{cvs -z3 -d:pserver:anonymous@@cvs.cclan.sourceforge.net:/cvsroot/cclan co -A asdf}
1058
If you are tracking the bleeding edge, you may want to subscribe to
1059
the cclan-commits mailing list (see
1060
@url{http://sourceforge.net/mail/?group_id=28536}) to receive commit
1061
messages and diffs whenever changes are made.
1063
For more CVS information, look at
1064
@url{http://sourceforge.net/cvs/?group_id=28536}.
1289
There is also a STABLE version, which is earlier than release.
1291
You may get the ASDF source repository using git:
1292
@kbd{git clone http://common-lisp.net/project/asdf/asdf.git}
1294
You will find the above referenced tags in this repository.
1296
Discussion of ASDF development is conducted on the mailing list
1297
@kbd{asdf-devel@@common-lisp.net}.
1069
1299
@node TODO list, missing bits in implementation, Getting the latest version, Top
1070
1300
@comment node-name, next, previous, up