X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/73572c12ccd49c661d06287903bfa725f5fd93a5..90c5d56bea07587dc74d4424bfba46d3ae8a8e47:/tools/asdf-extensions.lisp diff --git a/tools/asdf-extensions.lisp b/tools/asdf-extensions.lisp index 617b4b3..93be2d3 100644 --- a/tools/asdf-extensions.lisp +++ b/tools/asdf-extensions.lisp @@ -51,10 +51,16 @@ (module-components dso))))) (error 'operation-error :operation operation :component dso)))) +#+clisp +(defvar *loaded-libraries* ()) (defun load-dso (filename) #+sbcl(sb-alien:load-shared-object filename) - #+cmu(system::load-object-file filename)) + #+cmu(ext:load-foreign filename) + #+clisp + (unless (find filename *loaded-libraries* :test #'equal) + (ffi::foreign-library (namestring filename)) + (push filename *loaded-libraries*))) (defmethod perform ((o load-op) (c unix-dso)) @@ -100,22 +106,43 @@ t) +;;; Shared libraries -(defclass library (static-file) +(defclass library (component) ((libdir :initarg :libdir))) -(defun relative-pathname (path) - (etypecase path - (cons path) - (string (if (char= #\/ (char path 0)) - (subseq path 1) - path)))) +(defun split-path (path) + (labels ((split (path) + (unless (zerop (length path)) + (let ((slash (position #\/ path))) + (if slash + (cons (subseq path 0 slash) (split (subseq path (1+ slash)))) + (list path)))))) + (if (and (not (zerop (length path))) (char= (char path 0) #\/)) + (cons :absolute (split (subseq path 1))) + (cons :relative (split path))))) + (defmethod component-pathname ((lib library)) (make-pathname :type "so" :name (component-name lib) - :directory (relative-pathname (slot-value lib 'libdir)))) + :directory (split-path (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) + #+clisp(find (component-pathname c) *loaded-libraries* :test #'equal)) + +(defmethod operation-done-p ((o operation) (c library)) + t)