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