X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/77dd2192c99777a157dddc183a03f291f7ac395b..f0c3c3e59fe910d16608ccdb6ae58b368e664552:/tools/asdf-extensions.lisp diff --git a/tools/asdf-extensions.lisp b/tools/asdf-extensions.lisp index 633e21c..75918f7 100644 --- a/tools/asdf-extensions.lisp +++ b/tools/asdf-extensions.lisp @@ -1,5 +1,7 @@ (in-package :asdf) +(export 'load-dso) + (defun concatenate-strings (strings &optional delimiter) (if (not (rest strings)) (first strings) @@ -10,7 +12,7 @@ (concatenate-strings (rest strings) delimiter)))) ;;; The following code is more or less copied frm sb-bsd-sockets.asd, -;;; but extended to allow flags set in a general way +;;; but extended to allow flags to be set in a general way (defclass unix-dso (module) ()) (defun unix-name (pathname) @@ -19,7 +21,7 @@ (logical-pathname (translate-logical-pathname pathname)) (t pathname)))) -(defmethod asdf::input-files ((operation compile-op) (dso unix-dso)) +(defmethod input-files ((operation compile-op) (dso unix-dso)) (mapcar #'component-pathname (module-components dso))) (defmethod output-files ((operation compile-op) (dso unix-dso)) @@ -49,11 +51,16 @@ (module-components dso))))) (error 'operation-error :operation operation :component dso)))) + +(defun load-dso (filename) + #+sbcl(sb-alien:load-shared-object filename) + #+cmu(system::load-object-file filename)) + + (defmethod perform ((o load-op) (c unix-dso)) (let ((co (make-instance 'compile-op))) (let ((filename (car (output-files co c)))) - #+cmu (ext:load-foreign filename) - #+sbcl (sb-alien:load-shared-object filename)))) + (load-dso filename)))) @@ -65,9 +72,7 @@ (defmethod output-files ((op compile-op) (c c-source-file)) - (list - (make-pathname :type "o" :defaults - (component-pathname c)))) + (list (make-pathname :type "o" :defaults (component-pathname c)))) (defmethod perform ((op compile-op) (c c-source-file)) @@ -95,3 +100,37 @@ t) +;;; Shared libraries + +(defclass library (component) + ((libdir :initarg :libdir))) + + +(defun relative-pathname (path) + (etypecase path + (cons path) + (string (if (char= #\/ (char path 0)) + (subseq path 1) + path)))) + +(defmethod component-pathname ((lib library)) + (make-pathname :type "so" + :name (component-name lib) + :directory (relative-pathname (slot-value lib 'libdir)))) + +(defmethod perform ((o load-op) (c library)) + (load-dso (component-pathname c))) + +(defmethod perform ((operation operation) (c library)) + nil) + +(defmethod operation-done-p ((o load-op) (c library)) + #+sbcl(find (sb-ext::unix-namestring (component-pathname c)) sb-alien::*shared-objects* :key #'sb-alien::shared-object-file :test #'equal) + #+cmu(rassoc (unix::unix-namestring (component-pathname c)) + system::*global-table* + :key #'(lambda (pathname) + (when pathname (unix::unix-namestring pathname))) + :test #'equal)) + +(defmethod operation-done-p ((o operation) (c library)) + t)