Define a Simple Echo-Op

zacque technical+asdf-devel at zacque.tk
Tue Apr 26 07:40:47 UTC 2022


Hi,

I'm trying to learn how ASDF object model works by defining a simple
operation "echo-op". I want it to print out pathnames of all loaded lisp
files to *standard-output*. It sounds like a simple task, but I couldn't
get it to work. Thus I'm asking for help here.

To do that, I define a project:
----------- file: echo-op.asd -------------------
(defsystem #:echo-op
  :components
  ((:file "package")
   (:file "echo-op")))
-------------------------------------------------

----------- file: package.lisp -------------------
(defpackage #:echo-op
  (:use #:cl #:asdf)
  (:export
   #:selfward-echo-op))
-------------------------------------------------

----------- file: echo-op.lisp -------------------
(in-package #:echo-op)

(defclass selfward-echo-op (selfward-operation)
  ())

(defmethod asdf:component-depends-on ((op selfward-echo-op) c)
  `((selfward-echo-op ,c) ,@(call-next-method)))

(defmethod asdf:output-files ((op selfward-echo-op) c)
  nil)

(defmethod asdf:perform :around ((op selfward-echo-op) c)
  (let ((input-files (asdf:input-files op c)))
    (loop for file in input-files
	  do (format t "~s" file))))

(setf (find-class 'asdf::selfward-echo-op) (find-class 'selfward-echo-op))
-------------------------------------------------

Then, if I run these from the REPL:
----------- REPL -------------------
CL-USER> (asdf:load-system :echo-op :force t)
					; compiling file 
					; compilation finished in 0:00:00.004
					; compiling file 
					; wrote 
					; compilation finished in 0:00:00.036
T
CL-USER> (asdf:operate 'asdf::selfward-echo-op :echo-op-test)
					; Evaluation aborted on #<SB-PCL::NO-APPLICABLE-METHOD-ERROR {1002341273}>.
-------------------------------------------------

I got the error:
----------- SLIME *sldb* -------------------
The slot ASDF/ACTION:SELFWARD-OPERATION is unbound in the object
#<SELFWARD-ECHO-OP >.
   [Condition of type UNBOUND-SLOT]
-------------------------------------------------

The "echo-op-test" system is simply:
----------- file: echo-op-test.lisp -------------------
(defsystem #:echo-op-test
  :defsystem-depends-on (#:echo-op)
  :components
  ((:file "package")
   (:file "example")
   (:file "main")))
-------------------------------------------------
with empty files package.lisp, example.lisp, and main.lisp.

Now, if I redefine selfward-echo-op to subclass load-op, I got this
error instead: 
----------- SLIME *sldb* -------------------
Circular dependency of
#1=(#<ECHO-OP:SELFWARD-ECHO-OP >
    . #<ASDF/SYSTEM:SYSTEM "echo-op-test">)
on:
   (#1#)
   [Condition of type ASDF/ACTION:CIRCULAR-DEPENDENCY]
-------------------------------------------------
which I have no idea what is going on.

I'm still learning about ASDF, so any help to achieve what I want to do
would be very much appreciated.

Thanks!

-- 
Regards,
zacque



More information about the asdf-devel mailing list