Cabal-1.24.2.0: A framework for packaging Haskell software

Distribution.Simple.PreProcess

Description

This defines a PreProcessor abstraction which represents a pre-processor that can transform one kind of file into another. There is also a PPSuffixHandler which is a combination of a file extension and a function for configuring a PreProcessor. It defines a bunch of known built-in preprocessors like cpp, cpphs, c2hs, hsc2hs, happy, alex etc and lists them in knownSuffixHandlers. On top of this it provides a function for actually preprocessing some sources given a bunch of known suffix handlers. This module is not as good as it could be, it could really do with a rewrite to address some of the problems we have with pre-processors.

Synopsis

# Documentation

Apply preprocessors to the sources from hsSourceDirs for a given component (lib, exe, or test suite).

Find any extra C sources generated by preprocessing that need to be added to the component (addresses issue #238).

Standard preprocessors: GreenCard, c2hs, hsc2hs, happy, alex and cpphs.

ppSuffixes :: [PPSuffixHandler] -> [String] Source #

Convenience function; get the suffixes of these preprocessors.

A preprocessor for turning non-Haskell files with the given extension into plain Haskell source files.

The interface to a preprocessor, which may be implemented using an external program, but need not be. The arguments are the name of the input file, the name of the output file and a verbosity level. Here is a simple example that merely prepends a comment to the given source file:

ppTestHandler :: PreProcessor
ppTestHandler =
PreProcessor {
platformIndependent = True,
runPreProcessor = mkSimplePreProcessor \$ \inFile outFile verbosity ->
do info verbosity (inFile++" has been preprocessed to "++outFile)
return ExitSuccess