resolution of symlinks in asdf

Kevin Layer <[email protected]>
Newsgroups gmane.lisp.cclan.general
Message-ID <10756.1148683914@gemini>
A contractor of Franz recently used asdf on a project.  When I went to
integrate the project into our sources and build system I found it
didn't work.  We use (and have for 15+ years) binary symlink
directories (currently there are 17 of them, each one corresponding to
one non-windows port of Allegro) to a single source directory.  Each
binary directory mirrors the structure of the source directory, except
all source files are symlinks to the ones in the source directory.
The build process then put the output files in the binary directories
instead of the source directory.

The problem is, asdf's defsystem macro follows the symlink of the
*load-truename*.  That is, if the defsystem form is in foo.asd, which
is a symlink to a source directory, the output files will go into the
source directory.

I added an option for getting around this behavior, :resolve-symlinks.
The changes are backward compatible--no existing program will break
due to the additional option.

Attached is a diff -u with respect to 1.97.  Can someone on the commit
list do the deed?


Thanks.

Kevin Layer

_______________________________________________
cclan-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cclan-list
asdf.diff (application/octet-stream, 2 KB)
--- asdf.lisp.orig	Fri May 26 14:35:15 2006
+++ asdf.lisp	Fri May 26 14:59:53 2006
@@ -78,6 +78,7 @@
 	   #:system-author
 	   #:system-maintainer
 	   #:system-license
+	   #:system-resolve-symlinks
 	   
 	   #:operation-on-warnings
 	   #:operation-on-failure
@@ -285,7 +286,9 @@
     :accessor system-long-description :initarg :long-description)
    (author :accessor system-author :initarg :author)
    (maintainer :accessor system-maintainer :initarg :maintainer)
-   (licence :accessor system-licence :initarg :licence)))
+   (licence :accessor system-licence :initarg :licence)
+   (resolve-symlinks :accessor system-resolve-symlinks :initarg
+		     :resolve-symlinks)))
 
 ;;; version-satisfies
 
@@ -877,7 +880,9 @@
     (aux key arglist)))
 
 (defmacro defsystem (name &body options)
-  (destructuring-bind (&key pathname (class 'system) &allow-other-keys) options
+  (destructuring-bind (&key pathname (class 'system)
+			    (resolve-symlinks t)
+		       &allow-other-keys) options
     (let ((component-options (remove-keyword :class options)))
       `(progn
 	;; system must be registered before we parse the body, otherwise
@@ -894,15 +899,20 @@
 		(t
 		 (register-system (quote ,name)
 				  (make-instance ',class :name ',name)))))
-	(parse-component-form nil (apply
-				   #'list
-				   :module (coerce-name ',name)
-				   :pathname
-				   (or ,pathname
-				       (pathname-sans-name+type
-					(resolve-symlinks  *load-truename*))
-				       *default-pathname-defaults*)
-				   ',component-options))))))
+	(parse-component-form
+	 nil (apply #'list
+		    :module (coerce-name ',name)
+		    :pathname
+		    (or ,pathname
+			,(if resolve-symlinks
+			     (pathname-sans-name+type
+			      (resolve-symlinks  *load-truename*))
+			   ;; *load-truename* has already-resolved symlinks
+			   ;; in some implementations, so use
+			   ;; *load-pathname*.
+			   (pathname-sans-name+type *load-pathname*))
+			*default-pathname-defaults*)
+		    ',component-options))))))
   
 
 (defun class-for-type (parent type)
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.