[asdf-devel] create temporary Lisp files in fasl directory

Stelian Ionescu sionescu at cddr.org
Fri Aug 6 05:24:25 UTC 2010

On Thu, 2010-08-05 at 18:58 -0400, Robert Brown wrote:
> I've defined a new component type that allows developers to include
> protobuf
> message definition files in their Lisp ASDF files:
>   (defclass protobuf-source-file (cl-source-file)
>     ((relative-proto-pathname ... )
>      (search-path ... )
>     (:documentation "A protocol buffer definition file."))
> When used like this in a system definition:
>   :components ((:protobuf-source-file "foo"))
> executing the ASDF:LOAD-OP operation causes the file called foo.proto
> to be
> translated into foo.lisp by a C++ program, and then compiled into
> foo.fasl
> and loaded.
> Note that foo.lisp is created in the same directory as the system
> definition, but I would prefer it to be created in the same directory
> as
> foo.fasl, which for me is in a subdirectory of ~/.cache/common-lisp.
> What's the easiest way to accomplish this?
> I initially tried overriding INPUT-FILES when applied to
> instances, but ASDF::PERFORM is defined like this:
>   (defmethod perform ((operation compile-op) (c cl-source-file))
>     (let ((source-file (component-pathname c)) ... ) ... )
> Since it calls COMPONENT-PATHNAME to find Lisp source, it will always
> look
> in the system definition directory.

Try something like this:

(defmethod asdf:perform ((op asdf:compile-op) (c protobuf-source-file))
  (let* ((output-defaults (pathname (car (asdf:output-files op c))))
         (generated-source-file (make-pathname :name (pathname-name (asdf:component-pathname c))
                                               :type "lisp"
                                               :defaults output-defaults)))

You need to call OUTPUT-FILES which will apply the output translations you've configured

Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/asdf-devel/attachments/20100806/0c1f4043/attachment.sig>

More information about the asdf-devel mailing list