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

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

Automagically find contrib via (REQUIRE :ABCL-CONTRIB).

REQUIREing :ABCL-CONTRIB will look for a 'abcl-contrib.jar' in the
same directory as 'abcl.jar'. If found, all the ASDF definitions one
level deep will be added to the ASDF search path, allowing contribs to
be loaded via REQUIRE or ASDF:LOAD-SYSTEM.

No longer compile contribs as ASDF will do this for us. Since we
moved to ASDF2, the contrib FASLs have been compiled but not packaged,
so this doesn't change any behavior except making packaging shorter.
When we figure out how to package FASLs with ASDF systems in jar
files, we will revisit this topic.

File size: 1.5 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 (equal (pathname-name p) "abcl")
12             (equal (pathname-type p) "jar")))
13        (rest loader))))
14      (when abcl-jar
15  (return abcl-jar)))))
16
17(defvar *abcl-jar* nil
18  "Pathname of the jar that ABCL was loaded from.
19Initialized via SYSTEM::FIND-SYSTEM-JAR.")
20
21(defvar *abcl-contrib* nil
22  "Pathname of the ABCL contrib.
23Initialized via SYSTEM:FIND-CONTRIB")
24
25(defun find-contrib (&optional (verbose nil))
26"Attempt to find the ABCL contrib jar and add its contents to ASDF."
27  (unless *abcl-contrib*
28    (unless *abcl-jar*
29      (setf *abcl-jar* (find-system-jar)))
30    (when *abcl-jar*
31      (let ((abcl-contrib (make-pathname :defaults *abcl-jar*
32           :name "abcl-contrib")))
33  (when (probe-file abcl-contrib)
34    (setf *abcl-contrib* abcl-contrib)
35    (dolist (asdf-file
36        (directory (make-pathname :device (list *abcl-contrib*)
37                :directory '(:absolute :wild)
38                :name :wild
39                :type "asd")))
40      (let ((asdf-directory 
41       (make-pathname :defaults asdf-file :name nil :type nil)))
42        (when verbose
43    (format t "Adding ~A to ASDF.~%" asdf-directory))
44        (push asdf-directory asdf:*central-registry*)))
45    *abcl-contrib*)))))
46
47(when (find-contrib)
48  (provide :abcl-contrib))
49
50
51
52       
53 
Note: See TracBrowser for help on using the repository browser.