Next: A more involved example, Previous: Defining systems with defsystem, Up: Defining systems with defsystem
Systems can be constructed programmatically
by instantiating components using make-instance
.
Most of the time, however, it is much more practical to use
a static defsystem
form.
This section begins with an example of a system definition,
then gives the full grammar of defsystem
.
Let's look at a simple system. This is a complete file that would usually be saved as hello-lisp.asd:
(in-package :asdf) (defsystem "hello-lisp" :description "hello-lisp: a sample Lisp system." :version "0.2.1" :author "Joe User <joe@example.com>" :licence "Public Domain" :components ((:file "packages") (:file "macros" :depends-on ("packages")) (:file "hello" :depends-on ("macros"))))
Some notes about this example:
in-package
form
to use package asdf
.
You could instead start your definition by using
a qualified name asdf:defsystem
.
defsystem
,
you are going to define functions,
create ASDF extension, globally bind symbols, etc.,
it is recommended that to avoid namespace pollution between systems,
you should create your own package for that purpose,
for instance replacing the above (in-package :asdf)
with:
(defpackage :foo-system (:use :cl :asdf)) (in-package :foo-system)
defsystem
form defines a system named hello-lisp
that contains three source files:
packages, macros and hello.
:version
numbers will be parsed!
They are parsed as period-separated lists of integers.
I.e., in the example, 0.2.1
is to be interpreted,
roughly speaking, as (0 2 1)
.
In particular, version 0.2.1
is interpreted the same as 0.0002.1
and
is strictly version-less-than version 0.20.1
,
even though the two are the same when interpreted as decimal fractions.
Instead of a string representing the version,
the :version
argument can be an expression that is resolved to
such a string using the following trivial domain-specific language:
in addition to being a literal string, it can be an expression of the form
(:read-file-form <pathname-or-string> :at <access-at-specifier>)
,
which will be resolved by reading a form in the specified pathname
(read as a subpathname of the current system if relative or a unix-namestring).
You may use a uiop:access-at
specifier
with the (optional) :at
keyword,
by default the specifier is 0
, meaning the first form is returned.