source: trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp @ 13672

Last change on this file since 13672 was 13672, checked in by Mark Evenson, 10 years ago

Be a little smarter about finding the abcl-contrib archive.

A more optimal solution might rank possible canidates rather than
picking the first one which satisfies any clause of the named
conditional.

File size: 1.8 KB
Line 
1(in-package :system)
2
3(require :asdf)
4
5;;; XXX make less sensitive to ABCL jar being called "abcl.jar"
6;;;     allow being called "abcl-x.y.z.jar for semantic versioning
7;;;     allow customization in system.lisp
8(defun find-system-jar () 
9  (dolist (loader (java:dump-classpath))
10    (let ((abcl-jar
11     (find-if (lambda (p) (and 
12                                 (or (equal (pathname-name p) "abcl")
13                                     (equal (pathname-name p) 
14                                            (format nil "abcl-~A" 
15                                                    (lisp-implementation-version))))
16             (equal (pathname-type p) "jar")))
17        (rest loader))))
18      (when abcl-jar
19  (return abcl-jar)))))
20
21(defvar *abcl-jar* nil
22  "Pathname of the jar that ABCL was loaded from.
23Initialized via SYSTEM::FIND-SYSTEM-JAR.")
24
25(defvar *abcl-contrib* nil
26  "Pathname of the ABCL contrib.
27Initialized via SYSTEM:FIND-CONTRIB")
28
29(defun find-contrib (&optional (verbose nil))
30"Attempt to find the ABCL contrib jar and add its contents to ASDF."
31  (unless *abcl-contrib*
32    (unless *abcl-jar*
33      (setf *abcl-jar* (find-system-jar)))
34    (when *abcl-jar*
35      (let ((abcl-contrib (make-pathname :defaults *abcl-jar*
36           :name "abcl-contrib")))
37  (when (probe-file abcl-contrib)
38    (setf *abcl-contrib* abcl-contrib)
39    (dolist (asdf-file
40        (directory (make-pathname :device (list *abcl-contrib*)
41                :directory '(:absolute :wild)
42                :name :wild
43                :type "asd")))
44      (let ((asdf-directory 
45       (make-pathname :defaults asdf-file :name nil :type nil)))
46        (when verbose
47    (format t "Adding ~A to ASDF.~%" asdf-directory))
48        (push asdf-directory asdf:*central-registry*)))
49    *abcl-contrib*)))))
50
51(when (find-contrib)
52  (provide :abcl-contrib))
53
54
55
56       
57 
Note: See TracBrowser for help on using the repository browser.