source: trunk/abcl/contrib/mvn/jna.asd @ 14189

Last change on this file since 14189 was 14189, checked in by Mark Evenson, 8 years ago

jna: introspect classpath for com.sun.jna.Native as per Anton's suggestion.

File size: 1.4 KB
Line 
1;;;; -*- Mode: LISP -*-
2
3;;;; Need to have jna.jar present for CFFI to have a chance of working.
4(asdf:defsystem :jna
5    :version "3.4.0"
6    :defsystem-depends-on (abcl-asdf))
7;; FIXME:  install a better handler in abcl-asdf  :components ((:mvn "net.java.dev.jna/jna/3.4.0")))
8
9(defmethod asdf:perform :after ((o asdf:load-op) (c (eql (asdf:find-system :jna))))
10  ;; Theoretically this should be the same thing as the MVN component.
11  (handler-case
12      (unless
13          (flet ((match-jna-jar (p)
14                   "Match `jna.jar`,`jna-3.0.9.jar`, or `jna-3.4.0.jar`."
15                   (and (pathnamep p)
16                        (equal (pathname-type p) "jar")
17                        (java:jstatic "matches"
18                                      "java.util.regex.Pattern"
19                                      "jna(-[0-9]\\.[0-9]\\.[0-9](-.+)?)?"
20                                      (pathname-name p))
21                        p)))
22            (dolist (loader (java:dump-classpath))
23              (let ((jna-jar (some #'match-jna-jar loader)))
24                (when jna-jar
25                  (return abcl-jar)))))
26        (java:add-to-classpath (abcl-asdf:resolve
27                                "net.java.dev.jna:jna:3.4.0")))
28    (t (e)
29      (progn
30        (unless (jss:find-java-class "com.sun.jna.Native")
31          (error "Failed to resolve 'jna.jar' because~&~A." e))))))
32
33                         
Note: See TracBrowser for help on using the repository browser.