FFI imports packaging utility
Note: This page contains a progressing draft of the documentation for an extension to HSFFIG to create Haskell packages for FFI imports. Once this page is complete this note will be removed. Dimitry Golubovsky
- 1 The FFI Packaging Utility
- 1.1 Abstract
- 1.2 Why Package FFI Imports
- 1.3 Command Line Options
- 1.4 How It Works
- 1.5 Working Examples
- 1.6 Conclusion
The FFI Packaging Utility
This document contains user manual for the FFI Packaging Utility (ffipkg) which is an extension to HSFFIG.
Why Package FFI Imports
Typically, when building a Haskell applications calling foreign functions from some library directly, certain things are taken into consideration such as location of the library header files and the library itself.
The hsffig tool automatically preprocesses library header files and generates FFI import statements for all foreign functions (with few exceptions like variadic functions and functions taking/returning structures) as well as function declarations to access members of C structures and unions.
As a result of such automatic FFI import generation, substantial amount of Haskell code is created which in turn results in subatantial time to compile it.
The Cabal tool assists in creation of packages. Usually Haskell packages contain reusable libraries of modules written in Haskell.
The ffipkg utility serves the purpose to bridge FFI imports and packaging. With FFI packages, locations of foreign libraries and header files need to be remembered only once, during package creation. The Haskell code created during the automated FFI import process needs to be compiled only once, thus reducing the time to compile applications using the foreign library.
Command Line Options
Usage: ffipkg [OPTION...] include-file... -v --verbose provide verbose output -s --static prefer static libraries -i --header stop after writing package include file -?, -h --help print this help message -I include files location (may be multiple) -L library files location (may be multiple) -l library file to link (may be multiple) -V --version show version number -w 0.0 --package-version=0.0 specify version of the package -p --package-name= name the package (will be uppercased) --with-make=make path to make --with-awk=awk path to awk --with-ar=ar path to ar --with-ghc=ghc path to ghc --with-gcc=gcc path to gcc --with-hsc2hs=hsc2hs path to hsc2hs