0.pre8.50
[sbcl.git] / contrib / sb-grovel / README
1 Many of the structure offsets and symbolic constants necessary to do
2 FFI vary between architectures and operating systems.  To avoid a
3 maintenance nightmare, we derive them automatically by creating and
4 running a small C program.  The C program is created by
5 def-to-lisp.lisp with input from a GROVEL-CONSTANTS-FILE
6
7 The ASDF component type GROVEL-CONSTANTS-FILE has its PERFORM
8 operation defined to write out a C source file, compile it, and run
9 it.  The output from this program is Lisp, which is then itself
10 compiled.
11
12 How to use it from your own system
13
14 1) Create a Lisp package for the foreign constants/functions to go into.
15 It needs to use SB-GROVEL and SB-ALIEN
16
17 2) Make your system depend on the "sb-grovel" system
18
19 3) Create a grovel-constants data file - see example-constants.lisp in
20 this directory
21
22 4) Add it as a component in your system. e.g.
23
24 (defsystem sbcl-hemlock
25     :depends-on (sb-grovel)
26     :components
27     ((:module "sbcl"
28               :components
29               ((:file "defpackage")
30                (sb-grovel:grovel-constants-file "example-constants"
31                                                 :package :sbcl-hemlock
32                                                 )))))
33
34 Make sure to specify the package you chose in step 1
35
36 5) Build stuff
37
38 ---
39
40 Note that we assume that the C type char has 8 bits. 
41