[armedbear-cvs] r13350 - in trunk/abcl: . contrib/asdf-jar

mevenson at common-lisp.net mevenson at common-lisp.net
Mon Jun 20 14:37:12 UTC 2011


Author: mevenson
Date: Mon Jun 20 07:37:10 2011
New Revision: 13350

Log:
Document the use of the ASDF-JAR contrib.

ASDF:ADD-TO-ASDF provides a mechanism to add the contents of a
pathname specifying an jar package to be subequently loaded by ASDF.

Generalize mechanism to specifiy contrib contents while including
"README.markdown" files.

Added:
   trunk/abcl/contrib/asdf-jar/README.markdown
Modified:
   trunk/abcl/build.xml
   trunk/abcl/contrib/asdf-jar/asdf-jar.asd
   trunk/abcl/contrib/asdf-jar/asdf-jar.lisp

Modified: trunk/abcl/build.xml
==============================================================================
--- trunk/abcl/build.xml	Mon Jun 20 05:01:18 2011	(r13349)
+++ trunk/abcl/build.xml	Mon Jun 20 07:37:10 2011	(r13350)
@@ -469,13 +469,18 @@
       <property name="abcl.wrapper.in.file" value="abcl.bat.in"/>
     </target>
 
+    <patternset id="abcl.contrib.source">
+          <include name="**/*.asd"/>
+          <include name="**/*.lisp"/>
+          <include name="**/README.markdown"/>
+    </patternset>
+
     <property name="abcl-contrib.jar"
               value="${dist.dir}/abcl-contrib.jar"/>
     <condition property="abcl.contrib.uptodate.p">
       <uptodate targetfile="${abcl-contrib.jar}">
         <srcfiles dir="contrib">
-          <include name="**/*.asd"/>
-          <include name="**/*.lisp"/>
+          <patternset refid="abcl.contrib.source"/>
         </srcfiles>
       </uptodate>
     </condition>
@@ -484,10 +489,7 @@
       <jar destfile="${abcl-contrib.jar}"
            compress="true"
            basedir="contrib">
-        <patternset>
-          <include name="**/*.asd"/>
-          <include name="**/*.lisp"/>
-        </patternset>
+        <patternset refid="abcl.contrib.source"/>
       </jar>
       <echo>
 Packaged contribs in ${abcl-contrib.jar}. To use contribs, ensure that

Added: trunk/abcl/contrib/asdf-jar/README.markdown
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/abcl/contrib/asdf-jar/README.markdown	Mon Jun 20 07:37:10 2011	(r13350)
@@ -0,0 +1,59 @@
+ASDF-JAR
+========
+
+    Mark Evenson
+    Created: 20-JUN-2011
+    Modified: 20-JUN-2011
+
+ASDF-JAR provides a system for packaging ASDF systems into jar
+archives for ABCL.  Given a running ABCL image with loadable ASDF
+systems the code in this package will recursively package all the
+required source and fasls in a jar archive .
+
+To install ASDF systems, [Quicklisp]() is probably the best
+contemporary solution, although a version of ASDF-INSTALL is also
+packaged in ABCL contribs.
+
+[Quicklisp]: http://www.quicklisp.org
+
+Once the requisite ASDF systems have been installed, ensure that this
+contrib is loaded via
+
+    CL-USER) (require :abcl-contrib)
+    CL-USER> (require :asdf-jar)
+
+Then, to say package the Perl regular expression system ("CL-PPCRE"),
+one uses the ASDF-JAR:PACKAGE as follows:
+
+    CL-USER> (asdf-jar:package :cl-ppcre)
+    ;  Loading #P"/home/evenson/quicklisp/dists/quicklisp/software/cl-ppcre-2.0.3/cl-ppcre.asd" ...
+    ;  Loaded #P"/home/evenson/quicklisp/dists/quicklisp/software/cl-ppcre-2.0.3/cl-ppcre.asd" (0.029 seconds)
+    Packaging ASDF definition of #<ASDF:SYSTEM "cl-ppcre">
+     as /var/tmp/cl-ppcre-all-2.0.3.jar.
+    Packaging contents in /var/tmp/cl-ppcre-all-2.0.3.jar
+     with recursive dependencies.
+    #P"/var/tmp/cl-ppcre-all-2.0.3.jar"
+
+The resulting jar contains all source and fasls required to run the
+ASDF system including any transitive ASDF dependencies.  Each asdf
+system is packaged under its own top level directory within the jar
+archive.  The jar archive itself is numbered with the version of the
+system that was specified in the packaging.
+
+To load the system from the jar one needs to add the ASDF file
+locations to the ASDF *CENTRAL-REGISTRY*.  If one wishes to load the
+fasls from the jar alone, one needs to tell ASDF not to override its
+output translation rules.  The function ASDF-JAR:ADD-TO-JAR does both
+of these options serving as the basis for customized load strategies
+tailored to end-user deployment needs.  So, after
+
+    CL-USER> (asdf-jar:add-to-asdf "/var/tmp/cl-ppcre-all-2.0.3.jar")
+
+a subsequent
+
+    CL-USER> (asdf:load-system :cl-ppcre)
+
+should load the ASDF system from the jar.
+
+Setting CL:*LOAD-VERBOSE* will allow one to verify that the subsequent
+load is indeed coming from the jar.

Modified: trunk/abcl/contrib/asdf-jar/asdf-jar.asd
==============================================================================
--- trunk/abcl/contrib/asdf-jar/asdf-jar.asd	Mon Jun 20 05:01:18 2011	(r13349)
+++ trunk/abcl/contrib/asdf-jar/asdf-jar.asd	Mon Jun 20 07:37:10 2011	(r13350)
@@ -6,4 +6,5 @@
   :version "0.2.0"
   :components 
   ((:module base :pathname "" :components
-	    ((:file "asdf-jar")))))
\ No newline at end of file
+	    ((:file "asdf-jar")
+             (:static-file "README.markdown))))
\ No newline at end of file

Modified: trunk/abcl/contrib/asdf-jar/asdf-jar.lisp
==============================================================================
--- trunk/abcl/contrib/asdf-jar/asdf-jar.lisp	Mon Jun 20 05:01:18 2011	(r13349)
+++ trunk/abcl/contrib/asdf-jar/asdf-jar.lisp	Mon Jun 20 07:37:10 2011	(r13350)
@@ -1,6 +1,11 @@
+;;; This file is part of ABCL contrib
+;;;
+;;; Copyright 2011 Mark <evenson at panix.com>
+
 (defpackage #:asdf-jar
   (:use :cl)
-  (:export #:package))
+  (:export #:package 
+           #:add-to-asdf))
 
 (in-package :asdf-jar)
 
@@ -9,16 +14,18 @@
 (defun package (system-name 
                 &key (out #p"/var/tmp/") 
                      (recursive t)          ; whether to package dependencies
-                     (force nil)              ; whether to force ASDF compilation
+                     (force nil)             ; whether to force ASDF compilation
                      (verbose t))
 "Compile and package the asdf SYSTEM-NAME in a jar.
 
 When RECURSIVE is true (the default), recursively add all asdf
 dependencies into the same jar.
 
-Place the resulting packaging in the OUT directory.
+Place the resulting packaged jar in the OUT directory.
+
+If FORCE is true, force asdf to recompile all the necessary fasls.
 
-Returns the pathname of the created jar archive.
+Returns the pathname of the packaged jar archive.
 "
   (let* ((system 
           (asdf:find-system system-name))
@@ -106,6 +113,30 @@
      :directory (nconc (pathname-directory temp-path)
                        (list name)))))
 
+(defun add-to-asdf (jar &key (use-jar-fasls t))
+  "Make a given JAR output by the package mechanism loadable by asdf.
+
+The parameter passed to :USE-JAR-FASLS determines whether to instruct
+asdf to use the fasls packaged in the jar.  If this is nil, the fasls
+will be compiled with respect to the ususual asdf output translation
+conventions."
+  (when (not (typep jar 'pathname))
+    (setf jar (pathname jar)))
+  (when (null (pathname-device jar))
+    (setf jar (make-pathname :device (list jar))))
+
+  ;;; Inform ASDF of all the system definitions in the jar
+  (loop :for asd 
+     :in (directory (merge-pathnames "*/*.asd" jar))
+     :do (pushnew (make-pathname :defaults asd
+                                 :name nil :type nil)
+                  asdf:*central-registry*))
+
+  ;;; Load the FASLs directly from the jar
+  (when use-jar-fasls                    
+    (asdf:initialize-output-translations
+     `(:output-translations (,(merge-pathnames "/**/*.*" jar)) 
+                            :inherit-configuration))))
 
 
 




More information about the armedbear-cvs mailing list