cl: cffi:*foreign-library-directories*

Table of Contents

Here's an sample code to be able to configure that special variable without loading cffi's system at all.

;; Create a dummy package
#-cffi
(defpackage #:cffi (:use))

#-cffi
;; We create and export the symbol cffi:*foreign-library-directories*
(export
 ;; This is to make sure the _symbol_ exists before the defvar,
 ;; otherwise the reader will complain that it doesn't exist.
 (intern "*FOREIGN-LIBRARY-DIRECTORIES*" '#:cffi)
 '#:cffi)

;; This is to bind the symbol and proclaim it special.
#-cffi
(defvar cffi:*foreign-library-directories* '())

;; Idempotently add a list of paths to
;; cffi:*foreign-library-directories*
(progn
  (map nil (lambda (path)
             (pushnew path cffi:*foreign-library-directories* :test #'equal))
       ;; Generated with:
       ;; sudo ldconfig -N -v 2>&1 | sed -n 's|^\(/[^:]*\).*$|\1|p' \
       ;; | sort -u | sed 's/^/"/; s/$/"/; 1 s/^/\'(/; $ s/$/)/'
       '("/lib"
         "/lib/i386-linux-gnu"
         "/lib/x86_64-linux-gnu"
         "/lib32"
         "/sbin/ldconfig.real"
         "/usr/lib/x86_64-linux-gnu/libfakeroot"
         "/usr/local/lib"))
  cffi:*foreign-library-directories*)

1. Backlinks

Created: 2024-04-06 Sat 00:49