(in-package :asdf-ecs/uffi) (defun %load-foreign-library (file module) (or (load-foreign-library file :module module) (error "Could not load ~A into ~A!" file module))) (defclass uffi-library (c-library) ((load-into :initarg :load-into :accessor uffi-library-module)) (:documentation "A library for use with uffi.")) (defmethod reinitialize-instance :after ((ob uffi-library) &key) (unless (slot-boundp ob 'load-into) (setf (uffi-library-module ob) (component-name ob)))) (defmethod input-files ((o load-op) (c uffi-library)) (list (or (when (slot-boundp c 'library-definition) (apply #'find-foreign-library (library-definition c))) ;; FIXME: Make sure this does what we want. (issue:load-system-.so-files) ;; Does this load .so files from the same place as .lisp files are found, ;; or from where .fasl files end up? We want the former so distributions ;; can include .so/.dll files. (make-pathname :name (component-name c) :type (default-foreign-library-type) :defaults (component-pathname c))))) ;; We have nothing to compile. (defmethod perform ((o compile-op) (c uffi-library)) nil) (defmethod perform ((o load-op) (c uffi-library)) (dolist (file (input-files o c)) (%load-foreign-library file (uffi-library-module c)))) (defclass uffi-source-file (c-source-file) ()) (defmethod output-files ((o compile-op) (c uffi-source-file)) (list (make-pathname :name (component-name c) :type (default-foreign-library-type) :defaults (component-pathname c)))) (defmethod perform ((o load-op) (c uffi-source-file)) (dolist (file (input-files o c)) (%load-foreign-library file (component-name c))))