[armedbear-cvs] r13303 - in trunk/abcl: . src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Sat Jun 4 20:27:11 UTC 2011


Author: mevenson
Date: Fri May 27 07:13:18 2011
New Revision: 13303

Log:
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.

Added:
   trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp
Modified:
   trunk/abcl/build.xml
   trunk/abcl/src/org/armedbear/lisp/compile-system.lisp
   trunk/abcl/src/org/armedbear/lisp/require.lisp

Modified: trunk/abcl/build.xml
==============================================================================
--- trunk/abcl/build.xml	Fri May 27 06:06:26 2011	(r13302)
+++ trunk/abcl/build.xml	Fri May 27 07:13:18 2011	(r13303)
@@ -469,40 +469,30 @@
       <property name="abcl.wrapper.in.file" value="abcl.bat.in"/>
     </target>
 
-    <!-- XXX Generalize when (if?) we get more contribs --> 
-    <target name="abcl.contrib.compile" depends="abcl.jar">
-      <java fork="true"
-            failonerror="true"
-            classpathref="abcl.classpath.dist"
-            inputstring="(require 'asdf) (handler-case (progn (setf *default-pathname-defaults* "${basedir}/contrib/asdf-install/") (asdf:operate 'asdf:compile-op :asdf-install)) (t (x) (progn (format t "~A: ~A~%" (type-of x) x) (exit :status -1))))"
-            classname="org.armedbear.lisp.Main">
-        <arg value="--noinit"/>
-      </java>
-    </target>
-    
-    <target name="abcl.contrib" depends="abcl.contrib.compile">
+    <target name="abcl.contrib">
       <jar destfile="dist/abcl-contrib.jar"
            compress="true"
            basedir="contrib">
         <patternset>
           <include name="**/*.asd"/>
           <include name="**/*.lisp"/>
-          <include name="**/*.abcl"/>
         </patternset>
       </jar>
       <echo>
 Packaged contribs in ${dist.dir}/abcl-contrib.jar. 
 
-To use ASDF-INSTALL, use the following in your ~/.abclrc:
+To use contribs, ensure that 'abcl-contrib.jar' is in the same
+directory as 'abcl.jar', then
+
+  CL-USER> (require 'abcl-contrib)
 
-  (require 'asdf)
-  (pushnew "jar:file:${dist.dir}/abcl-contrib.jar!/asdf-install/" asdf:*central-registry*)
+will place all the contribs in the ASDF registry path. 
 
-Then issuing
+To load a contrib, something like
 
-  CL-USER> (require 'asdf-install) 
+  CL-USER> (require 'jss) 
 
-will load ASDF-INSTALL.
+will compile (if necessary) and load JSS.
 </echo>
     </target>
 

Added: trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp	Fri May 27 07:13:18 2011	(r13303)
@@ -0,0 +1,53 @@
+(in-package :system)
+
+(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
+(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)))))
+
+(defvar *abcl-jar* nil
+  "Pathname of the jar that ABCL was loaded from.
+Initialized via SYSTEM::FIND-SYSTEM-JAR.")
+
+(defvar *abcl-contrib* nil
+  "Pathname of the ABCL contrib.
+Initialized via SYSTEM:FIND-CONTRIB")
+
+(defun find-contrib (&optional (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*)))))
+
+(when (find-contrib)
+  (provide :abcl-contrib))
+
+
+
+		   
+  

Modified: trunk/abcl/src/org/armedbear/lisp/compile-system.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/compile-system.lisp	Fri May 27 06:06:26 2011	(r13302)
+++ trunk/abcl/src/org/armedbear/lisp/compile-system.lisp	Fri May 27 07:13:18 2011	(r13303)
@@ -126,7 +126,8 @@
       (load (do-compile "destructuring-bind.lisp"))
       (load (do-compile "asdf.lisp"))
       ;; But not for these.
-      (mapc #'do-compile '("adjoin.lisp"
+      (mapc #'do-compile '("abcl-contrib.lisp"
+			   "adjoin.lisp"
                            "and.lisp"
                            "apropos.lisp"
                            "arrays.lisp"

Modified: trunk/abcl/src/org/armedbear/lisp/require.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/require.lisp	Fri May 27 06:06:26 2011	(r13302)
+++ trunk/abcl/src/org/armedbear/lisp/require.lisp	Fri May 27 07:13:18 2011	(r13303)
@@ -47,6 +47,7 @@
           (format *error-output* "Failed to require  ~A because '~A'~%" 
                   module e))
         nil))))
+
     
 (defvar *module-provider-functions* nil)
 




More information about the armedbear-cvs mailing list