An example software project might contain four files; an ASDF file, a package definition file, an implementation file, and a CFFI-Grovel specification file.
The ASDF file defines the system and its dependencies.
Notice the use of
eval-when to ensure CFFI-Grovel is present
and the use of
(cffi-grovel:grovel-file name &key cc-flags)
;;; CFFI-Grovel is needed for processing grovel-file components (cl:eval-when (:load-toplevel :execute) (asdf:operate 'asdf:load-op 'cffi-grovel)) (asdf:defsystem example-software :depends-on (cffi) :serial t :components ((:file "package") (cffi-grovel:grovel-file "example-grovelling") (:file "example")))
The “package.lisp” file would contain several
forms, to remove circular dependencies and make building the project
easier. Note that you may or may not want to
Implementor’s note: Mention that it’s a not a good idea to :USE when names may clash with, say, CL symbols.
(defpackage #:example-internal (:use) (:nicknames #:exampleint)) (defpackage #:example-software (:export ...) (:use #:cl #:cffi #:exampleint))
The internal package is created by Lisp code output from the C program written by CFFI-Grovel; if your specification file is exampleint.lisp, the exampleint.cffi.lisp file will contain the CFFI definitions needed by the rest of your project. See Groveller Syntax.