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 CL-SOURCE-FILE 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