Difference between revisions of "FFI imports packaging utility"
Line 33: | Line 33: | ||
=== Package Naming and Versioning === |
=== Package Naming and Versioning === |
||
− | Per the Cabal specification, the two fields are mandatory for a package descriptor file: ''Name'' and ''Version''. The ''-p'' option sets the name of the package into its argument uppercased. If omitted, name of the first include file found on the command line will be used for package name |
+ | Per the Cabal specification, the two fields are mandatory for a package descriptor file: ''Name'' and ''Version''. The ''-p'' option sets the name of the package into its argument uppercased. If omitted, name of the first include file found on the command line will be used for package name, uppercased, with directory part and file name suffix stripped. The ''-w'' option sets the version field of the package descriptor file to its argument. The version supplied is checked for correctness using the same parser Cabal itself uses. |
=== Location of Libraries and Include Files === |
=== Location of Libraries and Include Files === |
Revision as of 10:55, 1 February 2006
Abstract
The Haskell Cabal [1] is a framework which defines a common interface for authors to more easily build their applications in a portable way. The Haskell Foreign Functions Import Generator (hsffig) [3] is a tool to convert a C header file (.h) into Haskell code containing FFI [2] import statements for all entities whose declarations are found in the header file. The FFI Packaging Utility (ffipkg) is a tool that integrates the functionality of hsffig with the Cabal framework allowing for building and installation of packages entirely consisting of foreign functions imports.
It is recommended that readers of this document be familiar with the documents referred to as [3] and [4].
Benefits of Packaging FFI Imports
To build a Haskell application linked to a foreign library, it is necessary to specify the locations of certain files (C headers and static or shared library files) for the Haskell compiler, and this information must be remembered for every application using the library. Building a FFI package means that all such information is contained within the package descriptor, and all that needs to be remembered is just name of the package.
Purpose
The ffipkg utility accepts locations of C header and foreign library files as command line arguments and produces Haskell source files with FFI declarations, a Makefile, a Cabal package descriptor file, and a Setup.hs file suitable for running the Cabal package setup program. The utility acts as a "driver" running the C preprocessor, the equivalent of the hsffig program, and the source splitter. The Makefile created allows for compilation of Haskell source files into split object files: a feature provided by GHC. This technique is discussed in [4].
Command Line Options
Synopsis
Usage: ffipkg [OPTION...] include-file... -v --verbose provide verbose output -n --new-hooks use newer userHooks interface -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 program 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
Package Naming and Versioning
Per the Cabal specification, the two fields are mandatory for a package descriptor file: Name and Version. The -p option sets the name of the package into its argument uppercased. If omitted, name of the first include file found on the command line will be used for package name, uppercased, with directory part and file name suffix stripped. The -w option sets the version field of the package descriptor file to its argument. The version supplied is checked for correctness using the same parser Cabal itself uses.