Created
November 20, 2019 21:44
-
-
Save realark/1b6970a13615a6e389294ab9480d1e09 to your computer and use it in GitHub Desktop.
close and re-open foreign libraries on lisp images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let ((%loaded-libraries% (list))) | |
(defun %pre-image-save () | |
(loop :for library :in (cffi:list-foreign-libraries :loaded-only t) :do | |
(format T "close foreign lib: ~A~%" library) | |
(push (cffi:foreign-library-name library) %loaded-libraries%) | |
(cffi:close-foreign-library library))) | |
(defun %post-image-load () | |
(loop :while %loaded-libraries% :do | |
(let ((library-name (pop %loaded-libraries%))) | |
(format T "load foreign lib: ~A~%" library-name) | |
(cffi:load-foreign-library library-name))))) | |
(defun make-image () | |
(%pre-image-save) | |
(sb-ext:save-lisp-and-die "my-image-name" | |
:purify T | |
:toplevel | |
#'(lambda () | |
(%post-image-load) | |
(my-main-function)) | |
:executable t | |
;; :application-type :gui | |
:save-runtime-options t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment