Previous: Pre-defined subclasses of component, Up: Components [Contents][Index]
New component types are defined by subclassing one of the existing component classes and specializing methods on the new component class.
As an example, suppose we have some implementation-dependent
functionality that we want to isolate
in one subdirectory per Lisp implementation our system supports.
We create a subclass of
cl-source-file
:
(defclass unportable-cl-source-file (cl-source-file) ())
Function asdf:implementation-type
(exported since 2.014.14)
gives us the name of the subdirectory.
All that’s left is to define how to calculate the pathname
of an unportable-cl-source-file
.
(defmethod component-pathname ((component unportable-cl-source-file)) (merge-pathnames* (parse-unix-namestring (format nil "~(~A~)/" (asdf:implementation-type))) (call-next-method)))
The new component type is used in a defsystem
form in this way:
(defsystem :foo :components ((:file "packages") ... (:unportable-cl-source-file "threads" :depends-on ("packages" ...)) ... )