From b44232e9bf9e0c442331958976762278389bdedf Mon Sep 17 00:00:00 2001 From: u-u-h Date: Tue, 31 May 2016 11:02:26 +0200 Subject: [PATCH] modernize for asdf3 --- asdf-component-shared-unix-library.asd | 47 ------------------------ satwrap.asd | 66 ++++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 62 deletions(-) delete mode 100644 asdf-component-shared-unix-library.asd diff --git a/asdf-component-shared-unix-library.asd b/asdf-component-shared-unix-library.asd deleted file mode 100644 index 5214a21..0000000 --- a/asdf-component-shared-unix-library.asd +++ /dev/null @@ -1,47 +0,0 @@ -;;; ASDF Definition. -*- lisp -*- - -(defpackage :asdf-component-shared-unix-library-system - (:use :cl :asdf) - (:export #:shared-unix-library)) - -(in-package :asdf-component-shared-unix-library-system) - -(defclass shared-unix-library (source-file) - ()) - -(defmethod source-file-type ((component shared-unix-library) system) - "so") - -(defmethod input-files (operation (component shared-unix-library)) - nil) - -(defmethod output-files ((operation compile-op) (component shared-unix-library)) - nil) - -(defmethod perform ((operation compile-op) (component shared-unix-library)) - nil) -(defmethod operation-done-p ((o compile-op) (c shared-unix-library)) - t) -(defmethod operation-done-p ((o load-op) (c shared-unix-library)) - nil) - -(defmethod perform ((operation load-op) (component shared-unix-library)) - (flet ((load-lib (lib) - #+cffi - (cffi:load-foreign-library lib) - #+(and (not cffi) sbcl) - (sb-alien:load-shared-object lib) - #+(and (not cffi) allegro) - (load lib :foreign t) - #-(or sbcl allegro cffi) - (error "No foreign library support"))) - (handler-case (load-lib (component-pathname component)) - (error (e) (declare (ignore e)) - nil)))) - -(pushnew :asdf-component-shared-unix-library *features*) - -(asdf:defsystem :asdf-component-shared-unix-library - :name "ASDF component :shared-unix-library" - :components ()) - diff --git a/satwrap.asd b/satwrap.asd index e850bf4..abd1583 100644 --- a/satwrap.asd +++ b/satwrap.asd @@ -29,13 +29,47 @@ ;;; Code: +#-cffi +(progn + #+quicklisp + (ql:quickload "cffi") + #-quicklisp + (asdf:operate 'asdf:load-op "cffi")) -#-asdf-component-shared-unix-library -(asdf:operate 'asdf:load-op :asdf-component-shared-unix-library) +;; my old asdf-component-shared-unix-library-system.asd, mostly +(defclass shared-unix-library (module) + ((library-designator + :type (or symbol string list pathname) + :initarg :library-designator + :documentation + "Library designator suitable to be passed to cffi:load-foreign-library"))) -(defpackage #:satwrap-system - (:use #:cl #:asdf #:asdf-component-shared-unix-library-system)) -(in-package #:satwrap-system) +;; (defmethod source-file-type ((component shared-unix-library) system) +;; "so") +(defmethod input-files (operation (component shared-unix-library)) + nil) +(defmethod output-files ((operation compile-op) (component shared-unix-library)) + nil) +(defmethod perform ((operation compile-op) (component shared-unix-library)) + nil) +(defmethod operation-done-p ((o compile-op) (c shared-unix-library)) + t) +(defmethod operation-done-p ((o load-op) (c shared-unix-library)) + nil) +(defmethod perform ((operation load-op) (component shared-unix-library)) + (let ((cffi:*foreign-library-directories* + ;; add autoconf substitution here: + `(#p"/Users/uhaus/work/cray/eiger-cpp/.libs/" + #p"/usr/local/lib/" ;; might work... + ,cffi:*foreign-library-directories*))) + (let ((lib + (cffi:load-foreign-library + (slot-value component 'library-designator)))) + (format *standard-output* + "~&;; loaded shared-unix-library ~A as ~A~%" + (component-name component) + lib) + lib))) (defsystem #:satwrap :description "?" @@ -50,25 +84,27 @@ :components ((:module :precosat - :if-component-dep-fails :try-next :serial T :components ((:shared-unix-library "libprecosat" - :pathname "libprecosat") - (:shared-unix-library - "libprecosat_so" - :pathname "libprecosat.so") + :library-designator + (:or + "libprecosat" + "libprecosat_so" + "libprecosat.so" + "libprecosat.dylib")) (:file "satwrap.precosat"))) (:module :minisat - :if-component-dep-fails :try-next :serial T :components ((:shared-unix-library "libminisat" - :pathname "simp/.libs/libminisat") - (:shared-unix-library - "libminisat_so" - :pathname "simp/.libs/libminisat.so") + :library-designator + (:or + "simp/.libs/libminisat" + "simp/.libs/libminisat.so" + "libminisat_so" + "libminisat.so")) (:file "satwrap.minisat")))) :depends-on ("backend" "package")) ;; top-level: -- 2.11.4.GIT