Re: How CLSQL finds and loads foreign libraries
Edi Weitz <[email protected]>
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Kevin! I'm sorry for being so slow on this but I'm currently too busy with paid work. I saw you've released a new version in the meantime, but anyway... On Thu, 9 Jun 2005 19:11:38 -0600, Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> wrote: > Where did you thing about having such a statement. In the clsql.asd > file? I think that's OK. > Wouldn't PERFORM :AFTER construct work as well as your proposal > above for Debian? Yes, sure. The proposal was just to demonstrate how I would conditionalize. I have now attached a patch which implements a PUSH-LIBRARY-PATH function as described. The new function and the new special variable have documentation strings. I'd propose to add a general paragraph to the CLSQL documentation somewhere that looks like this: How CLSQL finds and loads foreign libraries ------------------------------------------- For some database types CLSQL has to load external foreign libaries. These are usually searched for in the standard locations the operating system uses but you can tell CLSQL to look into other directories as well by using the function CLSQL:PUSH-LIBRARY-PATH or by directly manipulating the special variable CLSQL:*FOREIGN-LIBRARY-SEARCH-PATHS*. If, say, the shared library libpq.so needed for PostgreSQL support is located in the directory "/opt/foo/" on your machine you'd use (clsql:push-library-path "/opt/foo/") before loading the CLSQL-POSTGRESQL module. (Note the trailing slash above!) If you want to combine this with fully automatic loading of libraries via ASDF a technique like the following works: (defmethod asdf:perform :after ((o asdf:load-op) (c (eql (asdf:find-system :clsql)))) (funcall (find-symbol "PUSH-LIBRARY-PATH" (find-package :clsql)) #p"/opt/foo/")) I've also slightly changed the order of libraries in two files in order to prefer the versions without a hard-coded path. The reason is that LispWorks (and maybe other Lisps) will remember the path used to load a library when an executable is delivered. It is certainly desirable that the executable doesn't use hard-coded library locations. Cheers, Edi. _______________________________________________ CLSQL-Devel mailing list [email protected] http://lists.b9.com/mailman/listinfo/clsql-devel
clsql.diff
(text/x-patch, 4.7 KB)
diff -ru clsql-3.2.0/ChangeLog clsql-new/ChangeLog --- clsql-3.2.0/ChangeLog 2005-06-08 19:27:26.000000000 +0200 +++ clsql-new/ChangeLog 2005-06-24 23:31:30.768843200 +0200 @@ -1,3 +1,12 @@ +2005-06-24 Edi Weitz <[email protected]> + * sql/db-interface.lisp: Added new special variable + *FOREIGN-LIBRARY-SEARCH-PATHS* and function PUSH-LIBRARY-PATH to + manipulate it. + * sql/package.lisp: Export these. + * uffi/clsq-uffi-loader.lisp: Used new variable; changed order of + libs. + * db-mysql/mysql-loader.lisp: Changed order of libs. + 09 Jun 2005 Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> * Version 3.2.0: REQUIRES UFFI VERSION 1.4.38 OR HIGHER * clsql-mysql.asd: Renamed clsql/mysql interface library from Only in clsql-3.2.0/db-mysql: clsql_mysql.dll diff -ru clsql-3.2.0/db-mysql/mysql-loader.lisp clsql-new/db-mysql/mysql-loader.lisp --- clsql-3.2.0/db-mysql/mysql-loader.lisp 2005-06-08 19:27:26.000000000 +0200 +++ clsql-new/db-mysql/mysql-loader.lisp 2005-06-24 23:22:21.529075200 +0200 @@ -19,12 +19,12 @@ (in-package #:mysql) (defparameter *clsql-mysql-library-candidate-names* - (list #+(or 64bit x86-64) (make-pathname :name "clsql_mysql64" + (list #+(or 64bit x86-64) "clsql_mysql64" + #+(or 64bit x86-64) (make-pathname :name "clsql_mysql64" :directory (pathname-directory *load-truename*)) - #+(or 64bit x86-64) "clsql_mysql64" + "clsql_mysql" (make-pathname :name "clsql_mysql" - :directory (pathname-directory *load-truename*)) - "clsql_mysql")) + :directory (pathname-directory *load-truename*)))) (defvar *mysql-library-candidate-names* '("libmysqlclient" "libmysql")) diff -ru clsql-3.2.0/sql/db-interface.lisp clsql-new/sql/db-interface.lisp --- clsql-3.2.0/sql/db-interface.lisp 2005-06-08 19:27:26.000000000 +0200 +++ clsql-new/sql/db-interface.lisp 2005-06-24 23:24:13.389923200 +0200 @@ -452,4 +452,11 @@ (unless (is-database-open database) (signal-closed-database-error database))) +(defvar *foreign-library-search-paths* nil + "A list of pathnames denoting directories where CLSQL will look +for foreign libraries \(in addition to the default places).") +(defun push-library-path (path) + "Adds the pathspec PATH \(which should denote a directory) to +the list *FOREIGN-LIBRARY-SEARCH-PATHS*." + (push path *foreign-library-search-paths*)) \ No newline at end of file diff -ru clsql-3.2.0/sql/package.lisp clsql-new/sql/package.lisp --- clsql-3.2.0/sql/package.lisp 2005-06-08 19:27:26.000000000 +0200 +++ clsql-new/sql/package.lisp 2005-06-24 23:23:31.860206400 +0200 @@ -226,6 +226,10 @@ ;; Shared exports for re-export by CLSQL package. #1=( + ;; foreign library loading + #:*foreign-library-search-paths* + #:push-library-path + ;; Condition system (conditions.lisp) #:sql-user-error #:sql-database-error diff -ru clsql-3.2.0/uffi/clsql-uffi-loader.lisp clsql-new/uffi/clsql-uffi-loader.lisp --- clsql-3.2.0/uffi/clsql-uffi-loader.lisp 2005-06-08 19:27:26.000000000 +0200 +++ clsql-new/uffi/clsql-uffi-loader.lisp 2005-06-24 23:26:08.875984000 +0200 @@ -19,7 +19,13 @@ (in-package #:clsql-uffi) (defun find-and-load-foreign-library (filenames &key module supporting-libraries (errorp t)) - (setq filenames (if (listp filenames) filenames (list filenames))) + (setq filenames (if (listp filenames) filenames (list filenames)) + filenames + (append + (loop for search-path in clsql:*foreign-library-search-paths* + nconc (loop for filename in filenames + collect (merge-pathnames filename search-path))) + filenames)) (or (loop for type in (uffi:foreign-library-types) for suffix = (make-pathname :type type) thereis (loop for filename in filenames @@ -35,12 +41,12 @@ (length filenames) filenames)))) (defvar *clsql-uffi-library-filenames* - (list #+(or 64bit x86-64) (make-pathname :name "clsql_uffi64" + (list #+(or 64bit x86-64) "clsql_uffi64" + #+(or 64bit x86-64) (make-pathname :name "clsql_uffi64" :directory clsql-uffi-system::*library-file-dir*) - #+(or 64bit x86-64) "clsql_uffi64" + "clsql_uffi" (make-pathname :name "clsql_uffi" - :directory clsql-uffi-system::*library-file-dir*) - "clsql_uffi")) + :directory clsql-uffi-system::*library-file-dir*))) (defvar *clsql-uffi-supporting-libraries* '("c") "Used only by CMU. List of library flags needed to be passed to ld to Only in clsql-3.2.0/uffi: clsql_uffi.dll