ASDF全称是Another System Definition Facility,是Common Lisp重要的包管理工具。asdf可以构建、编译、加载Lisp程序,Quicklisp也依赖asdf。但是关于asdf的中文资料非常少,这里做一个简单记录。

asdf寻址

1
2
(require "asdf")
(push (truename ".") asdf:*central-registry*)

asdf加载包

1
(asdf:load-system :mypackage)

asdf定义系统

一般asdf文件命名与目录同名,例如:mypackage.asdf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(asdf:defsystem #:mypackage
:serial t
:name "mypackage"
:description "This is my lisp package."
:author "yourname"
:license "your license"
:depends-on (#:depmod-1
#:depmod-2
...
#:depmod-n)
:components
((:module "3rdpackage")
(:module "src"
:depends-on ("3rdpackage")
:components ((:file "package")
(:file "myfile-1")
(:file "myfile-2")
...
(:file "myfile-n")))))

asdf定义包

一般文件命名为:package.lisp

1
2
3
4
5
6
7
8
9
(defpackage #:mypackage
(:use #:mod-1
#:mod-2
...
#:mod-n)
(:export #:myfun-1
#:myfun-2
...
#:myfun-n))

参考资料

asdf手册