1 README,v 1.38 2004/07/19 21:18:07 crhodes Exp -*- Text -*-
3 The canonical documentation for asdf is in the file asdf.texinfo.
4 The significant overlap between this file and that will one day be
5 resolved by deleting text from this file; in the meantime, please look
10 asdf: another system definition facility
11 ========================================
13 * Getting the latest version
15 0) Decide which version you want. HEAD is the newest version and
16 usually OK, whereas RELEASE is for cautious people (e.g. who already
17 have systems using asdf that they don't want broken), a slightly older
18 version about which none of the HEAD users have complained.
20 1) Check it out from sourceforge cCLan CVS:
22 1a) cvs -d:pserver:anonymous@cvs.cclan.sourceforge.net:/cvsroot/cclan login
23 (no password: just press Enter)
25 1a.1) cvs -z3 -d:pserver:anonymous@cvs.cclan.sourceforge.net:/cvsroot/cclan
28 or for the bleeding edge, instead
30 1a.2) cvs -z3 -d:pserver:anonymous@cvs.cclan.sourceforge.net:/cvsroot/cclan
33 If you are tracking the bleeding edge, you may want to subscribe to
34 the cclan-commits mailing list (see
35 <URL:http://sourceforge.net/mail/?group_id=28536>) to receive commit
36 messages and diffs whenever changes are made.
38 For more CVS information, look at http://sourceforge.net/cvs/?group_id=28536
43 - The single file asdf.lisp is all you need to use asdf normally. For
44 maximum convenience you want to have it loaded whenever you start your
45 Lisp implementation, by loading it from the startup script, or dumping
46 a custom core, or something.
48 - The variable asdf:*central-registry* is a list of system directory
49 designators. A system directory designator is a form which will be
50 evaluated whenever a system is to be found, and must evaluate to a
51 directory to look in. For example, you might have
53 (*default-pathname-defaults* "/home/me/cl/systems/"
54 "/usr/share/common-lisp/systems/")
56 (When we say "directory" here, we mean "designator for a pathname
57 with a supplied DIRECTORY component")
59 It is possible to customize the system definition file search.
60 That's considered advanced use, and covered later: search forward
61 for *system-definition-search-functions*
63 - To compile and load a system 'foo', you need to (1) ensure that
64 foo.asd is in one of the directories in *central-registry* (a
65 symlink to the real location of foo.asd is preferred), (2) execute
66 ``(asdf:operate 'asdf:load-op 'foo)''
68 $ cd /home/me/cl/systems/
69 $ ln -s ~/src/foo/foo.asd .
71 * (asdf:operate 'asdf:load-op 'foo)
73 - To write your own system definitions, look at the test systems in
74 test/ , and read the rest of this. Ignore systems/ which is old
75 and may go away when next I clean up
77 - Syntax is similar to mk-defsystem 3 for straightforward systems, you
78 may only need to remove the :source-pathname option (and replace it
79 with :pathname if the asd file is not in the same place as the
82 - Join cclan-list@lists.sf.net for discussion, bug reports, questions, etc
84 - cclan.asd and the source files listed therein contain useful extensions
85 for maintainers of systems in the cCLan. If this isn't you, you
86 don't need them - although you may want to look at them anyway
88 - For systems that do complicated things (e.g. compiling C files to
89 load as foreign code), the packages in vn-cclan may provide some
90 guidance. db-sockets, for example, is known to do outlandish things
93 http://ww.telent.net/cliki/vn-cclan
99 This system definition utility talks in terms of 'components' and
102 Components form systems: a component represents a source file, or a
103 collection of components. A system is therefore a component,
104 recursively formed of a tree of subcomponents.
106 Operations are instantiated then performed on the nodes of a tree to
109 - compile all its files
110 - load the files into a running lisp environment
111 - copy its source files somewhere else
113 Operations can be invoked directly, or examined to see what their
114 effects would be without performing them. There are a bunch of
115 methods specialised on operation and component type which actually do
118 asdf is extensible to new operations and to new component types. This
119 allows the addition of behaviours: for example, a new component could
120 be added for Java JAR archives, and methods specialised on
121 compile-op added for it that would accomplish the relevant
126 ** mk-defsystem (defsystem-3.x)
128 We aim to solve basically the same problems as mk-defsystem does.
129 However, our architecture for extensibility better exploits CL
130 language features (and is documented), and we intend to be portable
131 rather than just widely-ported. No slight on the mk-defsystem authors
132 and maintainers is intended here; that implementation has the
133 unenviable task of supporting non-ANSI implementations, which I
136 The surface defsystem syntax of asdf is more-or-less compatible with
139 The mk-defsystem code for topologically sorting a module's dependency
140 list was very useful.
142 ** defsystem-4 proposal
144 Marco and Peter's proposal for defsystem 4 served as the driver for
145 many of the features in here. Notable differences are
147 - we don't specify output files or output file extensions as part of
150 If you want to find out what files an operation would create, ask
153 - we don't deal with CL packages
155 If you want to compile in a particular package, use an in-package
156 form in that file (ilisp will like you more if you do this anyway)
158 - there is no proposal here that defsystem does version control.
160 A system has a given version which can be used to check
161 dependencies, but that's all.
163 The defsystem 4 proposal tends to look more at the external features,
164 whereas this one centres on a protocol for system introspection.
166 ** kmp's "The Description of Large Systems", MIT AI Memu 801
168 Available in updated-for-CL form on the web at
169 http://world.std.com/~pitman/Papers/Large-Systems.html
171 In our implementation we borrow kmp's overall PROCESS-OPTIONS and
172 concept to deal with creating component trees from defsystem surface
173 syntax. [ this is not true right now, though it used to be and
174 probably will be again soon ]
181 *** Component Attributes
183 **** A name (required)
185 This is a string or a symbol. If a symbol, its name is taken and
186 lowercased. The name must be a suitable value for the :name initarg
187 to make-pathname in whatever filesystem the system is to be found.
189 The lower-casing-symbols behaviour is unconventional, but was selected
190 after some consideration. Observations suggest that the type of
191 systems we want to support either have lowercase as customary case
192 (Unix, Mac, windows) or silently convert lowercase to uppercase
193 (lpns), so this makes more sense than attempting to use :case :common,
194 which is reported not to work on some implementations
196 **** a version identifier (optional)
198 This is used by the test-system-version operation (see later).
200 **** *features* required
202 Traditionally defsystem users have used reader conditionals to include
203 or exclude specific per-implementation files. This means that any
204 single implementation cannot read the entire system, which becomes a
205 problem if it doesn't wish to compile it, but instead for example to
206 create an archive file containing all the sources, as it will omit to
207 process the system-dependent sources for other systems.
209 Each component in an asdf system may therefore specify features using
210 the same syntax as #+ does, and it will (somehow) be ignored for
211 certain operations unless the feature conditional matches
213 **** dependencies on its siblings (optional but often necessary)
215 There is an excitingly complicated relationship between the initarg
216 and the method that you use to ask about dependencies
218 Dependencies are between (operation component) pairs. In your
219 initargs, you can say
221 :in-order-to ((compile-op (load-op "a" "b") (compile-op "c"))
222 (load-op (load-op "foo")))
224 - before performing compile-op on this component, we must perform
225 load-op on "a" and "b", and compile-op on c, - before performing
226 load-op, we have to load "foo"
228 The syntax is approximately
230 (this-op {(other-op required-components)}+)
232 required-components := component-name
233 | (required-components required-components)
235 component-name := string
236 | (:version string minimum-version-object)
238 [ This is on a par with what ACL defsystem does. mk-defsystem is less
239 general: it has an implied dependency
241 for all x, (load x) depends on (compile x)
243 and using a :depends-on argument to say that b depends on a _actually_
246 (compile b) depends on (load a)
248 This is insufficient for e.g. the McCLIM system, which requires that
249 all the files are loaded before any of them can be compiled ]
251 In asdf, the dependency information for a given component and
252 operation can be queried using (component-depends-on operation
253 component), which returns a list
255 ((load-op "a") (load-op "b") (compile-op "c") ...)
257 component-depends-on can be subclassed for more specific
258 component/operation types: these need to (call-next-method) and append
259 the answer to their dependency, unless they have a good reason for
260 completely overriding the default dependencies
262 (If it weren't for CLISP, we'd be using a LIST method combination to
263 do this transparently. But, we need to support CLISP. If you have
264 the time for some CLISP hacking, I'm sure they'd welcome your fixes)
268 This is optional and if absent will be inferred from name, type (the
269 subclass of source-file), and the location of parent.
271 The rules for this inference are:
274 - the host is taken from the parent
275 - pathname type is (source-file-type component system)
276 - the pathname case option is :local
277 - the pathname is merged against the parent
280 - the host is taken from the parent
281 - the name and type are NIL
282 - the directory is (:relative component-name)
283 - the pathname case option is :local
284 - the pathname is merged against the parent
286 Note that the DEFSYSTEM operator (used to create a "top-level" system)
287 does additional processing to set the filesystem location of the
288 top component in that system. This is detailed elsewhere
290 The answer to the frequently asked question "how do I create a system
291 definition where all the source files have a .cl extension" is thus
293 (defmethod source-file-type ((c cl-source-file) (s (eql (find-system 'my-sys))))
296 **** properties (optional)
298 Packaging systems often require information about files or systems
299 additional to that specified here. Programs that create vendor
300 packages out of asdf systems therefore have to create "placeholder"
301 information to satisfy these systems. Sometimes the creator of an
302 asdf system may know the additional information and wish to provide it
305 (component-property component property-name) and associated setf method
306 will allow the programmatic update of this information. Property
307 names are compared as if by EQL, so use symbols or keywords or something
309 ** Subclasses of component
313 A source file is any file that the system does not know how to
314 generate from other components of the system.
316 (Note that this is not necessarily the same thing as "a file
317 containing data that is typically fed to a compiler". If a file is
318 generated by some pre-processor stage (e.g. a ".h" file from ".h.in"
319 by autoconf) then it is not, by this definition, a source file.
320 Conversely, we might have a graphic file that cannot be automatically
321 regenerated, or a proprietary shared library that we received as a
322 binary: these do count as source files for our purposes. All
323 suggestions for better terminology gratefully received)
325 Subclasses of source-file exist for various languages.
327 *** 'module', a collection of sub-components
329 This has extra slots for
331 :components - the components contained in this module
333 :default-component-class - for child components which don't specify
334 their class explicitly
336 :if-component-dep-fails takes one of the values :fail, :try-next, :ignore
337 (default value is :fail). The other values can be used for implementing
338 conditional compilation based on implementation *features*, where
339 it is not necessary for all files in a module to be compiled
341 The default operation knows how to traverse a module, so most
342 operations will not need to provide methods specialised on modules.
344 The module may be subclassed to represent components such as
345 foreign-language linked libraries or archive files.
347 *** system, subclasses module
349 A system is a module with a few extra attributes for documentation
350 purposes. In behaviour, it's usually identical.
352 Users can create new classes for their systems: the default defsystem
353 macro takes a :classs keyword argument.
358 An operation is instantiated whenever the user asks that an operation
359 be performed, inspected, or etc. The operation object contains
360 whatever state is relevant to this purpose (perhaps a list of visited
361 nodes, for example) but primarily is a nice thing to specialise
362 operation methods on and easier than having them all be EQL methods.
364 There are no differences between standard operations and user-defined
365 operations, except that the user is respectfully requested to keep his
366 (or more importantly, our) package namespace clean
368 *** invoking operations
370 (operate operation system &rest keywords-args)
372 keyword-args are passed to the make-instance call when creating the
373 operation: valid keywords depend on the initargs that the operation is
374 defined to accept. Note that dependencies may cause the operation to
375 invoke other operations on the system or its components: the new
376 operation will be created with the same initargs as the original one.
378 oos is accepted as a synonym for operate
380 *** standard operations
382 **** feature-dependent-op
384 This is not intended to be instantiated directly, but other operations
385 may inherit from it. An instance of feature-dependent-op will ignore
386 any components which have a `features' attribute, unless the feature
387 combination it designates is satisfied by *features*
389 See the earlier explanation about the component features attribute for
392 **** compile-op &key proclamations
394 If proclamations are supplied, they will be proclaimed. This is a
395 good place to specify optimization settings
397 When creating a new component, you should provide methods for this.
399 If you invoke compile-op as a user, component dependencies often mean
400 you may get some parts of the system loaded. This may not necessarily
401 be the whole thing, though; for your own sanity it is recommended that
402 you use load-op if you want to load a system.
404 **** load-op &key proclamations
406 The default methods for load-op compile files before loading them.
407 For parity, your own methods on new component types should probably do
412 This method will load the source for the files in a module even if the
413 source files have been compiled. Systems sometimes have knotty
414 dependencies which require that sources are loaded before they can be
415 compiled. This is how you do that.
417 If you are creating a component type, you need to implement this
418 operation - at least, where meaningful.
420 **** test-system-version &key minimum
422 Asks the system whether it satisfies a version requirement.
424 The default method accepts a string, which is expected to contain of a
425 number of integers separated by #\. characters. The method is not
426 recursive. The component satisfies the version dependency if it has
427 the same major number as required and each of its sub-versions is
428 greater than or equal to the sub-version number required.
430 (defun version-satisfies (x y)
431 (labels ((bigger (x y)
434 ((> (car x) (car y)) t)
436 (bigger (cdr x) (cdr y))))))
437 (and (= (car x) (car y))
438 (or (not (cdr y)) (bigger (cdr x) (cdr y))))))
440 If that doesn't work for your system, you can override it. I hope
441 yoyu have as much fun writing the new method as #lisp did
442 reimplementing this one.
444 *** Creating new operations
446 subclass operation, provide methods for source-file for
450 The perform method must call output-files to find out where to
451 put its files, because the user is allowed to override output-files
454 - operation-done-p, if you don't like the default one
456 * Writing system definitions
458 ** System designators
460 System designators are strings or symbols and behave just like
461 any other component names (including case conversion)
465 Given a system designator, find-system finds an actual system - either
466 in memory, or in a file on the disk. It funcalls each element in the
467 *system-definition-search-functions* list, expecting a pathname to be
470 If a suitable file exists, it is loaded if
472 - there is no system of that name in memory,
473 - the file's last-modified time exceeds the last-modified time of the
476 When system definitions are loaded from .asd files, a new scratch
477 package is created for them to load into, so that different systems do
478 not overwrite each others operations. The user may also wish to (and
479 is recommended to) include defpackage and in-package forms in his
480 system definition files, however, so that they can be loaded manually
483 For convenience in the normal case, and for backward compatibility
484 with the spirit of mk-defsystem, the default contents of
485 *system-definition-search-functions* is a function called
486 sysdef-central-registry-search. This looks in each of the directories
487 given by evaluating members of *central-registry*, for a file whose
488 name is the name of the system and whose type is "asd". The first
489 such file is returned, whether or not it turns out to actually define
490 the appropriate system
496 Systems can always be constructed programmatically by instantiating
497 components using make-instance. For most purposes, however, it is
498 likely that people will want a static defystem form.
500 asdf is based around the principle that components should not have to
501 know defsystem syntax. That is, the initargs that a component accepts
502 are not necessarily related to the defsystem form which creates it.
504 A defsystem parser must implement a `defsystem' macro, which can
505 be named for compatibility with whatever other system definition
506 utility is being emulated. It should instantiate components in
507 accordance with whatever language it accepts, and register the topmost
508 component using REGISTER-SYSTEM
512 The native syntax is inspired by mk-defsystem, to the extent that it
513 should be possible to take most straightforward mk- system definitions
514 and run them with only light editing. For my convenience, this turns
515 out to be basically the same as the initargs to the various
516 components, with a few extensions for convenience
518 system-definition := ( defsystem system-designator {option}* )
520 option := :components component-list
522 | :default-component-class
523 | :perform method-form
524 | :explain method-form
525 | :output-files method-form
526 | :operation-done-p method-form
527 | :depends-on ( {simple-component-name}* )
528 | :serial [ t | nil ]
529 | :in-order-to ( {dependency}+ )
531 component-list := ( {component-def}* )
533 component-def := simple-component-name
534 | ( component-type name {option}* )
536 component-type := :module | :file | :system | other-component-type
538 dependency := (dependent-op {requirement}+)
539 requirement := (required-op {required-component}+)
540 | (feature feature-name)
541 dependent-op := operation-name
542 required-op := operation-name | feature
548 :components ((:module "foo" :components ((:file "bar") (:file"baz")
550 :perform (compile-op :after (op c)
552 :explain (compile-op :after (op c)
553 (explain-something c)))
557 The method-form tokens need explaining: esentially,
559 :perform (compile-op :after (op c)
561 :explain (compile-op :after (op c)
562 (explain-something c)))
565 (defmethod perform :after ((op compile-op) (c (eql ...)))
567 (defmethod explain :after ((op compile-op) (c (eql ...)))
568 (explain-something c))
570 where ... is the component in question; note that although this also
571 supports :before methods, they may not do what you want them to - a
572 :before method on perform ((op compile-op) (c (eql ...))) will run
573 after all the dependencies and sub-components have been processed, but
574 before the component in question has been compiled.
576 **** Serial dependencies
578 If the `:serial t' option is specified for a module, asdf will add
579 dependencies for each each child component, on all the children
580 textually preceding it. This is done as if by :depends-on
582 :components ((:file "a") (:file "b") (:file "c"))
586 :components ((:file "a")
587 (:file "b" :depends-on ("a"))
588 (:file "c" :depends-on ("a" "b")))
596 The :pathname option is optional in all cases for native-syntax
597 systems, and in the usual case the user is recommended not to supply
598 it. If it is not supplied for the top-level form, defsystem will set
601 - The host/device/directory parts of *load-truename*, if it is bound
602 - *default-pathname-defaults*, otherwise
604 If a system is being redefined, the top-level pathname will be
606 - changed, if explicitly supplied or obtained from *load-truename*
607 - changed if it had previously been set from *default-pathname-defaults*
608 - left as before, if it had previously been set from *load-truename*
609 and *load-truename* is not now bound
611 These rules are designed so that (i) find-system will load a system
612 from disk and have its pathname default to the right place, (ii)
613 this pathname information will not be overwritten with
614 *default-pathname-defaults* (which could be somewhere else altogether)
615 if the user loads up the .asd file into his editor and
616 interactively re-evaluates that form
620 It is an error to define a system incorrectly: an implementation may
621 detect this and signal a generalised instance of
622 SYSTEM-DEFINITION-ERROR.
624 Operations may go wrong (for example when source files contain
625 errors). These are signalled using generalised instances of
626 OPERATION-ERROR, with condition readers ERROR-COMPONENT and
627 ERROR-OPERATION for the component and operation which erred.
629 * Compilation error and warning handling
631 ASDF checks for warnings and errors when a file is compiled. The
632 variables *compile-file-warnings-behaviour* and
633 *compile-file-errors-behavior* controls the handling of any such
634 events. The valid values for these variables are :error, :warn, and
637 ----------------------------------------------------------
639 ----------------------------------------------------------
641 * Outstanding spec questions, things to add
645 *** manual page component?
647 ** style guide for .asd files
649 You should either use keywords or be careful with the package that you
650 evaluate defsystem forms in. Otherwise (defsystem partition ...)
651 being read in the cl-user package will intern a cl-user:partition
652 symbol, which will then collide with the partition:partition symbol.
654 Actually there's a hairier packages problem to think about too.
655 in-order-to is not a keyword: if you read defsystem forms in a package
656 that doesn't use ASDF, odd things might happen
658 ** extending defsystem with new options
660 You might not want to write a whole parser, but just to add options to
661 the existing syntax. Reinstate parse-option or something akin
663 ** document all the error classes
665 ** what to do with compile-file failure
667 Should check the primary return value from compile-file and see if
668 that gets us any closer to a sensible error handling strategy
672 lift unix-dso stuff from db-sockets
676 A "dry run" of an operation can be made with the following form:
678 (traverse (make-instance '<operation-name>)
679 (find-system <system-name>)
682 This uses unexported symbols. What would be a nice interface for this
687 Sometimes one wants to
690 * missing bits in implementation
693 ** reuse the same scratch package whenever a system is reloaded from disk
694 ** rules for system pathname defaulting are not yet implemented properly
695 ** proclamations probably aren't
696 ** when a system is reloaded with fewer components than it previously
697 had, odd things happen
699 we should do something inventive when processing a defsystem form,
700 like take the list of kids and setf the slot to nil, then transfer
701 children from old to new list as they're found
703 ** traverse may become a normal function
705 If you're defining methods on traverse, speak up.
708 ** a lot of load-op methods can be rewritten to use input-files
713 ** (stuff that might happen later)
715 *** david lichteblau's patch for symlink resolution?
717 *** Propagation of the :force option. ``I notice that
719 (oos 'compile-op :araneida :force t)
721 also forces compilation of every other system the :araneida system
722 depends on. This is rarely useful to me; usually, when I want to force
723 recompilation of something more than a single source file, I want to
724 recompile only one system. So it would be more useful to have
725 make-sub-operation refuse to propagate ":force t" to other systems, and
726 propagate only something like ":force :recursively". ''
728 Ideally what we actually want is some kind of criterion that says
729 to which systems (and which operations) a :force switch will propagate.
731 The problem is perhaps that 'force' is a pretty meaningless concept.
732 How obvious is it that "load :force t" should force _compilation_?
733 But we don't really have the right dependency setup for the user to
734 compile :force t and expect it to work (files will not be loaded after
735 compilation, so the compile environment for subsequent files will be
736 emptier than it needs to be)
738 What does the user actually want to do when he forces? Usually, for
739 me, update for use with a new version of the lisp compiler. Perhaps
740 for recovery when he suspects that something has gone wrong. Or else
741 when he's changed compilation options or configuration in some way
742 that's not reflected in the dependency graph.
744 Other possible interface: have a 'revert' function akin to 'make clean'
746 (asdf:revert 'asdf:compile-op 'araneida)
748 would delete any files produced by 'compile-op 'araneida. Of course, it
749 wouldn't be able to do much about stuff in the image itself.
755 There's a difference between a module's dependencies (peers) and its
756 components (children). Perhaps there's a similar difference in
757 operations? For example, (load "use") depends-on (load "macros") is a
758 peer, whereas (load "use") depends-on (compile "use") is more of a
759 `subservient' relationship.