Adding load-only source files to ASDF

Gary King <[email protected]>
Newsgroups gmane.lisp.cclan.general
Message-ID <[email protected]>
Load-only source files seems to be a perennial ASDF request. The  
patch below purports to add load-only Common Lisp source files to  
ASDF. One can create a system file with them either by using the new  
class "interpreted-cl-source-file" or by using the keyword :load-only- 
p. For example, both of the files in the below would only be loaded,  
not compiled:

(asdf:defsystem test5
   :components
   ((:module "deps"
	    :pathname "."
	    :components
	    ((:interpreted-cl-source-file "file1")
	     (:file "file2" :load-only-p t)))))

If no-one sees any problems with this, I'll commit it soon.

thanks,



Index: asdf.lisp
===================================================================
RCS file: /cvsroot/cclan/asdf/asdf.lisp,v
retrieving revision 1.105
diff -u -w -u -r1.105 asdf.lisp
--- asdf.lisp	6 Feb 2007 17:15:58 -0000	1.105
+++ asdf.lisp	13 Feb 2007 14:12:01 -0000
@@ -429,7 +429,16 @@
(defclass source-file (component) ())
-(defclass cl-source-file (source-file) ())
+(defclass cl-source-file (source-file)
+  ((load-only-p :initform nil :initarg :load-only-p :reader load- 
only-p))
+  (:default-initargs
+   :load-only-p nil))
+
+(defclass interpreted-cl-source-file (cl-source-file)
+  ()
+  (:default-initargs
+   :load-only-p t))
+
(defclass c-source-file (source-file) ())
(defclass java-source-file (source-file) ())
(defclass static-file (source-file) ())
@@ -647,6 +656,7 @@
;;; combinations, so let's keep it simple and aspire to portability
(defgeneric traverse (operation component))
+
(defmethod traverse ((operation operation) (c component))
    (let ((forced nil))
      (labels ((do-one-dep (required-op required-c required-v)
@@ -758,6 +768,8 @@
;;; perform is required to check output-files to find out where to put
;;; its answers, in case it has been overridden for site policy
(defmethod perform ((operation compile-op) (c cl-source-file))
+  (if (load-only-p c)
+      nil
    #-:broken-fasl-loader
    (let ((source-file (component-pathname c))
          (output-file (car (output-files operation c))))
@@ -770,21 +782,27 @@
            (:warn (warn
                    "~@<COMPILE-FILE warned while performing ~A on  
~A.~@:>"
                    operation c))
-          (:error (error 'compile-warned :component c :operation  
operation))
+	      (:error (error 'compile-warned
+			     :component c :operation operation))
            (:ignore nil)))
        (when failure-p
          (case (operation-on-failure operation)
            (:warn (warn
                    "~@<COMPILE-FILE failed while performing ~A on  
~A.~@:>"
                    operation c))
-          (:error (error 'compile-failed :component c :operation  
operation))
+	      (:error (error 'compile-failed
+			     :component c :operation operation))
            (:ignore nil)))
        (unless output
-        (error 'compile-error :component c :operation operation)))))
+	    (error 'compile-error :component c :operation operation))))))
(defmethod output-files ((operation compile-op) (c cl-source-file))
-  #-:broken-fasl-loader (list (compile-file-pathname (component- 
pathname c)))
-  #+:broken-fasl-loader (list (component-pathname c)))
+  (if (load-only-p c)
+      nil
+      #-:broken-fasl-loader
+      (list (compile-file-pathname (component-pathname c)))
+      #+:broken-fasl-loader
+      (list (component-pathname c))))
(defmethod perform ((operation compile-op) (c static-file))
    nil)
@@ -803,6 +821,7 @@
(defmethod perform ((operation load-op) (c static-file))
    nil)
+
(defmethod operation-done-p ((operation load-op) (c static-file))
    t)
Index: test/run-tests.sh
===================================================================
RCS file: /cvsroot/cclan/asdf/test/run-tests.sh,v
retrieving revision 1.8
diff -u -w -u -r1.8 run-tests.sh
--- test/run-tests.sh	21 Aug 2006 10:52:34 -0000	1.8
+++ test/run-tests.sh	13 Feb 2007 14:12:01 -0000
@@ -1,5 +1,7 @@
#!/bin/sh
+sok=1
+
do_tests() {
rm *.$2 || true
( cd .. && echo '(compile-file "asdf")' |$1  )
@@ -10,10 +12,11 @@
      echo "Using $1, $i passed" >&2
    else
      echo "Using $1, $i failed" >&2
+    sok=0
      exit 1
    fi
done
-echo "Using $1, all tests apparently successful" >&2
+echo "Using $1, all tests apparently successful ($sok)" >&2
}
# do_tests {lisp invocation} {fasl extension}

--
Gary Warren King, metabang.com
Cell: (413) 885 9127
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM





-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.