1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
3 ;;; asdf.lisp --- ASDF components for iolib-grovel.
5 ;;; Copyright (C) 2005-2006, Dan Knap <dankna@accela.net>
6 ;;; Copyright (C) 2005-2006, Emily Backes <lucca@accela.net>
7 ;;; Copyright (C) 2007, Stelian Ionescu <sionescu@cddr.org>
8 ;;; Copyright (C) 2007, Luis Oliveira <loliveira@common-lisp.net>
10 ;;; Permission is hereby granted, free of charge, to any person
11 ;;; obtaining a copy of this software and associated documentation
12 ;;; files (the "Software"), to deal in the Software without
13 ;;; restriction, including without limitation the rights to use, copy,
14 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
15 ;;; of the Software, and to permit persons to whom the Software is
16 ;;; furnished to do so, subject to the following conditions:
18 ;;; The above copyright notice and this permission notice shall be
19 ;;; included in all copies or substantial portions of the Software.
21 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 ;;; DEALINGS IN THE SOFTWARE.
31 (in-package :iolib-grovel
)
33 (defun ensure-pathname (thing)
34 (if (typep thing
'logical-pathname
)
35 (translate-logical-pathname thing
)
38 (defclass cc-flags-mixin
()
39 ((cc-flags :initform nil
:accessor cc-flags-of
:initarg
:cc-flags
)))
41 (defmethod asdf:perform
:around
((op asdf
:compile-op
) (file cc-flags-mixin
))
42 (let ((*cc-flags
* (append (ensure-list (cc-flags-of file
))
46 ;;;# ASDF component: GROVEL-FILE
48 (defclass asdf
::iolib-grovel-file
(asdf:cl-source-file cc-flags-mixin
)
51 "This ASDF component defines COMPILE-OP and LOAD-SOURCE-OP
52 operations that take care of calling PROCESS-GROVEL-FILE in order
53 to generate a Lisp file that is subsequently compiled and/or
56 (defmethod asdf:perform
((op asdf
:compile-op
)
57 (c asdf
::iolib-grovel-file
))
58 (let ((output-file (ensure-pathname (car (asdf:output-files op c
)))))
59 (compile-file (process-grovel-file (asdf:component-pathname c
) output-file
)
60 :output-file output-file
61 #+ecl
:system-p
#+ecl t
)))
63 (defmethod asdf:perform
((op asdf
:load-source-op
)
64 (c asdf
::iolib-grovel-file
))
65 (load (process-grovel-file
66 (asdf:component-pathname c
)
67 (ensure-pathname (car (asdf:output-files op c
))))))
69 ;;;# ASDF component: WRAPPER-FILE
71 (defclass asdf
::iolib-wrapper-file
(asdf:cl-source-file cc-flags-mixin
)
72 ((soname :initform nil
:initarg
:soname
:accessor soname-of
))
74 "This ASDF component defines COMPILE-OP and LOAD-SOURCE-OP
75 operations that take care of calling PROCESS-WRAPPER-FILE in
76 order to generate a foreign library and matching CFFI bindings
77 that are subsequently compiled and/or loaded."))
79 (defun %perform-process-wrapper-file
(op c
)
80 (let ((fasl-file (ensure-pathname (car (asdf:output-files op c
)))))
81 (values (process-wrapper-file (asdf:component-pathname c
)
84 (asdf:component-name c
)))
87 (defmethod asdf:perform
((op asdf
:compile-op
)
88 (c asdf
::iolib-wrapper-file
))
89 (multiple-value-bind (generated-source-file fasl-file
)
90 (%perform-process-wrapper-file op c
)
91 (compile-file generated-source-file
92 :output-file fasl-file
93 #+ecl
:system-p
#+ecl t
)))
95 (defmethod asdf:perform
((op asdf
:load-source-op
)
96 (c asdf
::iolib-wrapper-file
))
97 (load (%perform-process-wrapper-file op c
)))