[armedbear-cvs] r13732 - branches/1.0.x/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Mon Jan 9 10:58:12 UTC 2012


Author: mevenson
Date: Mon Jan  9 02:58:11 2012
New Revision: 13732

Log:
backport r13730: make logic for finding abcl-contrib more robust.

Modified:
   branches/1.0.x/abcl/src/org/armedbear/lisp/abcl-contrib.lisp

Modified: branches/1.0.x/abcl/src/org/armedbear/lisp/abcl-contrib.lisp
==============================================================================
--- branches/1.0.x/abcl/src/org/armedbear/lisp/abcl-contrib.lisp	Mon Jan  9 02:53:47 2012	(r13731)
+++ branches/1.0.x/abcl/src/org/armedbear/lisp/abcl-contrib.lisp	Mon Jan  9 02:58:11 2012	(r13732)
@@ -2,17 +2,21 @@
 
 (require :asdf)
 
-;;; XXX make less sensitive to ABCL jar being called "abcl.jar"
-;;;     allow being called "abcl-x.y.z.jar for semantic versioning 
-;;;     allow customization in system.lisp
+;;; TODO possibly allow customization in system.lisp?
 (defun find-system-jar () 
-  (dolist (loader (java:dump-classpath))
-    (let ((abcl-jar
-	   (find-if (lambda (p) (and (equal (pathname-name p) "abcl")
-				     (equal (pathname-type p) "jar")))
-		    (rest loader))))
-      (when abcl-jar
-	(return abcl-jar)))))
+  (flet ((match-system-jar (p)
+           "Match `abcl.jar` or `abcl-1.0.1.jar` or `abcl-1.0.1-something.jar`"
+           (and (pathnamep p)
+                (equal (pathname-type p) "jar")
+                (java:jstatic "matches"
+                              "java.util.regex.Pattern" 
+                              "abcl(-[0-9]\\.[0-9]\\.[0-9](-.+)?)?" 
+                              (pathname-name p))
+                p)))
+    (dolist (loader (java:dump-classpath))
+      (let ((abcl-jar (some #'match-system-jar loader)))
+        (when abcl-jar
+          (return abcl-jar))))))
 
 (defvar *abcl-jar* nil
   "Pathname of the jar that ABCL was loaded from.
@@ -22,32 +26,41 @@
   "Pathname of the ABCL contrib.
 Initialized via SYSTEM:FIND-CONTRIB")
 
-(defun find-contrib (&optional (verbose nil))
+(defun find-contrib (&key (verbose nil))
 "Attempt to find the ABCL contrib jar and add its contents to ASDF."
   (unless *abcl-contrib*
     (unless *abcl-jar*
       (setf *abcl-jar* (find-system-jar)))
     (when *abcl-jar*
-      (let ((abcl-contrib (make-pathname :defaults *abcl-jar*
-					 :name "abcl-contrib")))
-	(when (probe-file abcl-contrib)
-	  (setf *abcl-contrib* abcl-contrib)
-	  (dolist (asdf-file
-		    (directory (make-pathname :device (list *abcl-contrib*)
-					      :directory '(:absolute :wild)
-					      :name :wild
-					      :type "asd")))
-	    (let ((asdf-directory 
-		   (make-pathname :defaults asdf-file :name nil :type nil)))
-	      (when verbose
-		(format t "Adding ~A to ASDF.~%" asdf-directory))
-	      (push asdf-directory asdf:*central-registry*)))
-	  *abcl-contrib*)))))
+      (let* ((abcl-contrib-name
+              (concatenate 'string "abcl-contrib"
+                           (subseq (pathname-name *abcl-jar*) 4)))
+             (abcl-contrib (make-pathname :defaults *abcl-jar*
+                                          :name abcl-contrib-name)))
+	(if (probe-file abcl-contrib)
+            (progn
+              (setf *abcl-contrib* abcl-contrib)
+              (dolist (asdf-file
+                        (directory (make-pathname :device (list *abcl-contrib*)
+                                                  :directory '(:absolute :wild)
+                                                  :name :wild
+                                                  :type "asd")))
+                (let ((asdf-directory 
+                       (make-pathname :defaults asdf-file :name nil :type nil)))
+                  (format verbose "Adding ~A to ASDF.~%" asdf-directory)
+                  (push asdf-directory asdf:*central-registry*)))
+              *abcl-contrib*)
+        (format verbose "Failed to find abcl-contrib at '~A'." abcl-contrib))))))
 
-(when (find-contrib)
+
+(when (find-contrib :verbose t)
   (provide :abcl-contrib))
 
 
 
+
+
+
+
 		   
   




More information about the armedbear-cvs mailing list