Re: ASDF: alternative system configurations
Christophe Rhodes <[email protected]>
| Newsgroups | gmane.lisp.cclan.general |
|---|---|
| Message-ID | <[email protected]> |
Nikodemus Siivola <[email protected]> writes: > How should I deal with alternative system configurations with ASDF? My > system can function both with or without CL-SDL, but the system is slightly > different when it is not present: > > window.lisp <-- needs SDL > render.lisp <-- needs window.lisp if we have SDL > > Currently I have solved this by having two alternative system definitions, > detecting the presence of SDL before calling ASDF, and then loading the > correct system. As far as solutions go it works, but is butt ugly. > > Is there a way to handle this with a single system-definition? Apologies for the appallingly late reply; maybe you've already solved this, or given up entirely, or something, but just in case this information is still useful, I think I know how to do this. There is good news and bad news. The bad news is that this can't be done without a *feature*, I think. On the other hand, said feature doesn't have to be provided by cl-sdl; you can do something like (when (find-package "SDL") (pushnew :my-package-has-found-sdl *features*)) Sadly, I can't see a way currently to avoid polluting the global *features*, unless you're in the habit of compiling your .asd files, in which case it could be done on (eval-when (:compile-toplevel) ...) Anyway, on with the good news: on the assumption that the above feature under your control is :FOO (choose a better name :-): (defpackage "FOO" (:use "ASDF" "CL")) (in-package "FOO") (defsystem foo :components ((:module "win" :components ((:file "window" :in-order-to ((compile-op (feature :foo))))) :pathname #.(make-pathname :directory '(:relative)) :if-component-dep-fails :ignore) (:file "render" :depends-on ("win")))) Then if :FOO is on *FEATURES* when the asdf operation is invoked, the window.lisp file will be treated as part of the system; otherwise, it won't. I tested this with two empty files in /tmp, with asdf as distributed with SBCL (should be roughly the same as CVS HEAD, I believe): * (require 'asdf) ("ASDF") * (load "/tmp/foo.asd") ; registering #<SYSTEM FOO {9545DB9}> as FOO T * (asdf:oos 'asdf:load-op 'foo) ; compiling file "/tmp/render.lisp" (written 11 JUN 2003 11:19:52 AM): ; /tmp/render.fasl written ; compilation finished in 0:00:00 NIL * (push :foo *features*) ; and rm render.fasl, just in case (:FOO :ASDF ...) * (asdf:oos 'asdf:load-op 'foo) ; compiling file "/tmp/window.lisp" (written 11 JUN 2003 11:19:49 AM): ; /tmp/window.fasl written ; compilation finished in 0:00:00 ; compiling file "/tmp/render.lisp" (written 11 JUN 2003 11:19:52 AM): ; /tmp/render.fasl written ; compilation finished in 0:00:00 NIL [ Rereading the documentation, and the source a little, it may be possible to do this without polluting *features* with something like the following: (defclass sdl-dependent-source-file (cl-source-file) ()) (defmethod perform :around (o (s sdl-dependent-source-file)) (unless (find-package "SDL") (error 'missing-dependency :required-by s)) (call-next-method)) and adding :default-component-class sdl-dependent-source-file to the :module "win" clause above. Since I've used only exported symbols here, this should be OK... untested, though. ] Cheers, Christophe -- http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757 (set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b))) (defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge) ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com.