1

Among other things you can set in an ASDF system is the :version property. Is there a way to read it at runtime? Something like (system-version :my-system-name)?

I know there are asdf:version-satisfies, and asdf:asdf-version, but neither do what I want in this case.

JJJ
  • 2,731
  • 1
  • 12
  • 23
Inaimathi
  • 13,853
  • 9
  • 49
  • 93
  • 1
    `(slot-value (asdf:find-system ) 'asdf:version)` – Vsevolod Dyomkin Jun 18 '12 at 15:44
  • 1
    Using `slot-value` is abstraction-breaking, unlike the approach based on `component-version`, so the latter is better. At least in theory, someone could write a method for `asdf:component-version` that does not access the slot, in which case code that directly examines the slot would lose. – Robert P. Goldman Jun 21 '12 at 21:30

1 Answers1

8

Here is the code:

(defun system-version (system-designator)
  (let ((system (asdf:find-system system-designator nil)))
    (when (and system (slot-boundp system 'asdf:version))
      (asdf:component-version system))))

it works like this:

CL-USER> (system-version :cffi)
"0.10.7.1"
CL-USER> (system-version :foo)
NIL
JJJ
  • 2,731
  • 1
  • 12
  • 23