Proposed ASDF patch [1/2] - :weakly-depends-on

Alan Shields <[email protected]>
Newsgroups gmane.lisp.cclan.general
Message-ID <[email protected]>
Adds :weakly-depends-on, which allows a system
to depend upon another system if that system is present in the system
and to ignore the dependency if it is not.

This is nice for optional-functionality.

There was talk on #lisp (yeah, there's ALWAYS talk on #lisp) about
more sophisticated methods that relied upon predicates, that allowed
options to be passed to the loader, etc, etc, but this was quick, easy,
and instantly useful.

I hope you'll find it worthy of inclusion,
Alan

--- /home/shieldsa/code/asdf-cvs/asdf.lisp	2005-09-26 17:54:42.000000000 -0500
+++ asdf.lisp	2005-11-17 17:10:57.000000000 -0600
@@ -930,10 +930,11 @@
 	      ;; remove-keys form.  important to keep them in sync
 	      components pathname default-component-class
 	      perform explain output-files operation-done-p
+	      weakly-depends-on
 	      depends-on serial in-order-to
 	      ;; list ends
 	      &allow-other-keys) options
-    (check-component-input type name depends-on components in-order-to)
+    (check-component-input type name weakly-depends-on depends-on components in-order-to)
 
     (when (and parent
 	     (find-component parent name)
@@ -946,14 +947,17 @@
     (let* ((other-args (remove-keys
 			'(components pathname default-component-class
 			  perform explain output-files operation-done-p
+			  weakly-depends-on
 			  depends-on serial in-order-to)
 			rest))
 	   (ret
 	    (or (find-component parent name)
 		(make-instance (class-for-type parent type)))))
+      (when weakly-depends-on
+	(setf depends-on (append depends-on (remove-if (complement #'find-system) weakly-depends-on))))
       (when (boundp '*serial-depends-on*)
 	(setf depends-on
-	      (concatenate 'list *serial-depends-on* depends-on)))
+	      (concatenate 'list *serial-depends-on* depends-on)))      
       (apply #'reinitialize-instance
 	     ret
 	     :name (coerce-name name)
@@ -1009,11 +1013,15 @@
 		  (component-inline-methods ret))))
       ret)))
 
-(defun check-component-input (type name depends-on components in-order-to)
+(defun check-component-input (type name weakly-depends-on depends-on components in-order-to)
   "A partial test of the values of a component."
+  (when weakly-depends-on (warn "We got one! XXXXX"))
   (unless (listp depends-on)
     (sysdef-error-component ":depends-on must be a list."
 			    type name depends-on))
+  (unless (listp weakly-depends-on)
+    (sysdef-error-component ":weakly-depends-on must be a list."
+			    type name weakly-depends-on))
   (unless (listp components)
     (sysdef-error-component ":components must be NIL or a list of components."
 			    type name components))


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
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.