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

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

The Bear gets medieval with JNA.

If jna.jar is in your path, we should count as having required.

File size: 1.7 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 (jss 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  (when (jss:find-java-class "com.sun.jna.Native")
11    (provide :jna)))
12
13(defmethod asdf:perform :before ((o asdf:load-op) (c (eql (asdf:find-system :jna))))
14  ;; Theoretically this should be the same thing as the MVN component.
15  (handler-case
16      (unless (jss:find-java-class "com.sun.jna.Native")
17        (unless
18            (flet ((match-jna-jar (p)
19                     "Match `jna.jar`,`jna-3.0.9.jar`, or `jna-3.4.0.jar`."
20                     (and (pathnamep p)
21                          (equal (pathname-type p) "jar")
22                          (java:jstatic "matches"
23                                        "java.util.regex.Pattern"
24                                        "jna(-[0-9]\\.[0-9]\\.[0-9](-.+)?)?"
25                                        (pathname-name p))
26                          p)))
27              (dolist (loader (java:dump-classpath))
28                (let ((jna-jar (some #'match-jna-jar loader)))
29                  (when jna-jar
30                    (return abcl-jar)))))
31          (unless
32              (java:add-to-classpath (abcl-asdf:resolve
33                                      "net.java.dev.jna:jna:3.4.0"))
34            (java:add-to-classpath "http://repo1.maven.org/maven2/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar"))))
35    (t (e)
36      (error "Failed to resolve 'jna.jar' because~&~A." e))))
37
38                         
Note: See TracBrowser for help on using the repository browser.