[13303] | 1 | (in-package :system) |
---|
| 2 | |
---|
| 3 | (require :asdf) |
---|
| 4 | |
---|
| 5 | (defun find-system-jar () |
---|
[14296] | 6 | "Return the pathname of the system jar, one of `abcl.jar` or `abcl-m.n.p.jar` or `abcl-m.n.p-something.jar`." |
---|
[13730] | 7 | (flet ((match-system-jar (p) |
---|
| 8 | (and (pathnamep p) |
---|
| 9 | (equal (pathname-type p) "jar") |
---|
| 10 | (java:jstatic "matches" |
---|
| 11 | "java.util.regex.Pattern" |
---|
[14232] | 12 | "abcl(-[0-9]\\.[0-9]\\.[0-9]([+~-].+)?)?" |
---|
[13730] | 13 | (pathname-name p)) |
---|
| 14 | p))) |
---|
| 15 | (dolist (loader (java:dump-classpath)) |
---|
| 16 | (let ((abcl-jar (some #'match-system-jar loader))) |
---|
| 17 | (when abcl-jar |
---|
| 18 | (return abcl-jar)))))) |
---|
[13303] | 19 | |
---|
| 20 | (defvar *abcl-jar* nil |
---|
| 21 | "Pathname of the jar that ABCL was loaded from. |
---|
| 22 | Initialized via SYSTEM::FIND-SYSTEM-JAR.") |
---|
| 23 | |
---|
| 24 | (defvar *abcl-contrib* nil |
---|
| 25 | "Pathname of the ABCL contrib. |
---|
| 26 | Initialized via SYSTEM:FIND-CONTRIB") |
---|
| 27 | |
---|
[13730] | 28 | (defun find-contrib (&key (verbose nil)) |
---|
[14296] | 29 | "Attempt to find the ABCL contrib jar and add its contents to ASDF. |
---|
| 30 | Returns the pathname of the contrib if it can be found." |
---|
[13303] | 31 | (unless *abcl-contrib* |
---|
| 32 | (unless *abcl-jar* |
---|
| 33 | (setf *abcl-jar* (find-system-jar))) |
---|
| 34 | (when *abcl-jar* |
---|
[13730] | 35 | (let* ((abcl-contrib-name |
---|
| 36 | (concatenate 'string "abcl-contrib" |
---|
| 37 | (subseq (pathname-name *abcl-jar*) 4))) |
---|
| 38 | (abcl-contrib (make-pathname :defaults *abcl-jar* |
---|
| 39 | :name abcl-contrib-name))) |
---|
| 40 | (if (probe-file abcl-contrib) |
---|
| 41 | (progn |
---|
| 42 | (setf *abcl-contrib* abcl-contrib) |
---|
| 43 | (dolist (asdf-file |
---|
| 44 | (directory (make-pathname :device (list *abcl-contrib*) |
---|
| 45 | :directory '(:absolute :wild) |
---|
| 46 | :name :wild |
---|
| 47 | :type "asd"))) |
---|
[14065] | 48 | (let ((asdf-directory (make-pathname :defaults asdf-file :name nil :type nil))) |
---|
| 49 | (unless (find asdf-directory asdf:*central-registry* :test #'equal) |
---|
| 50 | (push asdf-directory asdf:*central-registry*) |
---|
| 51 | (format verbose "~&Added ~A to ASDF.~&" asdf-directory)))) |
---|
[13730] | 52 | *abcl-contrib*) |
---|
[14296] | 53 | (error "Failed to find abcl-contrib at '~A'." abcl-contrib)))))) |
---|
[13303] | 54 | |
---|
[13730] | 55 | (when (find-contrib :verbose t) |
---|
[13303] | 56 | (provide :abcl-contrib)) |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | |
---|
[13730] | 60 | |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
[13303] | 64 | |
---|
| 65 | |
---|