| 1 | -- C -> Haskell Compiler: management of switches |
| 2 | -- |
| 3 | -- Author : Manuel M T Chakravarty |
| 4 | -- Created: 6 March 99 |
| 5 | -- |
| 6 | -- Version $Revision: 1.3 $ from $Date: 2005/06/22 16:01:21 $ |
| 7 | -- |
| 8 | -- Copyright (c) [1999..2004] Manuel M T Chakravarty |
| 9 | -- |
| 10 | -- This file is free software; you can redistribute it and/or modify |
| 11 | -- it under the terms of the GNU General Public License as published by |
| 12 | -- the Free Software Foundation; either version 2 of the License, or |
| 13 | -- (at your option) any later version. |
| 14 | -- |
| 15 | -- This file is distributed in the hope that it will be useful, |
| 16 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | -- GNU General Public License for more details. |
| 19 | -- |
| 20 | --- DESCRIPTION --------------------------------------------------------------- |
| 21 | -- |
| 22 | -- This module manages C2HS's compiler switches. It exports the data types |
| 23 | -- used to store the switches and operations on them. |
| 24 | -- |
| 25 | --- DOCU ---------------------------------------------------------------------- |
| 26 | -- |
| 27 | -- language: Haskell 98 |
| 28 | -- |
| 29 | -- Overview over the switches: |
| 30 | -- |
| 31 | -- * The cpp options specify the options passed to the C preprocessor. |
| 32 | -- |
| 33 | -- * The cpp filename gives the name of the executable of the C preprocessor. |
| 34 | -- |
| 35 | -- * The `hpaths' switch lists all directories that should be considered when |
| 36 | -- searching for a header file. |
| 37 | -- |
| 38 | -- * The `keep' flag says whether the intermediate file produced by the C |
| 39 | -- pre-processor should be retained or not. |
| 40 | -- |
| 41 | -- * Traces specify which trace information should be output by the compiler. |
| 42 | -- Currently the following trace information is supported: |
| 43 | -- |
| 44 | -- - information about phase activation and phase completion |
| 45 | -- |
| 46 | -- * After processing the compiler options, `outputSB' contains the base name |
| 47 | -- for the generated Haskell, C header, and .chi files. However, during |
| 48 | -- processing compiler options, `outputSB' contains arguments to the |
| 49 | -- `--output' option and `outDirSB' contains arguments to the |
| 50 | -- `--output-dir' option. |
| 51 | -- |
| 52 | -- * The pre-compiled header switch is unset if no pre-compiled header should |
| 53 | -- be read or generated. If the option is set and a header file is given |
| 54 | -- a concise version of the header will be written to the FilePath. If |
| 55 | -- a binding file is given, the pre-compiled header is used to expand the |
| 56 | -- module unless the binding file contains itself C declarations. |
| 57 | -- |
| 58 | --- TODO ---------------------------------------------------------------------- |
| 59 | -- |
| 60 | |
| 61 | module Switches ( |
| 62 | SwitchBoard(..), Traces(..), initialSwitchBoard |
| 63 | ) where |
| 64 | |
| 65 | |
| 66 | -- the switch board contains all toolkit switches |
| 67 | -- ---------------------------------------------- |
| 68 | |
| 69 | -- all switches of the toolkit (EXPORTED) |
| 70 | -- |
| 71 | data SwitchBoard = SwitchBoard { |
| 72 | cppOptsSB :: [String], -- cpp options |
| 73 | cppSB :: FilePath, -- cpp executable |
| 74 | hpathsSB :: [FilePath], -- header file directories |
| 75 | -- since 0.11.1 `hpathsSB' isn't really needed anymore.. |
| 76 | -- ..remove from 0.12 series |
| 77 | keepSB :: Bool, -- keep intermediate file |
| 78 | tracesSB :: Traces, -- trace flags |
| 79 | outputSB :: FilePath, -- basename of generated files |
| 80 | outDirSB :: FilePath, -- dir where generated files go |
| 81 | headerSB :: FilePath, -- generated header file |
| 82 | preCompSB :: Maybe FilePath,-- optional binary header r/w |
| 83 | oldFFI :: Bool, -- GHC 4.XX compatible code |
| 84 | chiPathSB :: [FilePath], -- .chi file directories |
| 85 | lockFunSB :: Maybe String -- a function to wrap each call |
| 86 | } |
| 87 | |
| 88 | -- switch states on startup (EXPORTED) |
| 89 | -- |
| 90 | initialSwitchBoard :: SwitchBoard |
| 91 | initialSwitchBoard = SwitchBoard { |
| 92 | cppOptsSB = [], |
| 93 | cppSB = "cpp", |
| 94 | hpathsSB = [], |
| 95 | keepSB = False, |
| 96 | tracesSB = initialTraces, |
| 97 | outputSB = "", |
| 98 | outDirSB = "", |
| 99 | headerSB = "", |
| 100 | preCompSB = Nothing, |
| 101 | oldFFI = False, |
| 102 | chiPathSB = ["."], |
| 103 | lockFunSB = Nothing |
| 104 | } |
| 105 | |
| 106 | |
| 107 | -- traces |
| 108 | -- ------ |
| 109 | |
| 110 | -- different kinds of traces possible (EXPORTED) |
| 111 | -- |
| 112 | data Traces = Traces { |
| 113 | tracePhasesSW :: Bool, |
| 114 | traceGenBindSW :: Bool, |
| 115 | traceCTravSW :: Bool, |
| 116 | dumpCHSSW :: Bool |
| 117 | } |
| 118 | |
| 119 | -- trace setting on startup |
| 120 | -- |
| 121 | -- * all traces are initially off |
| 122 | -- |
| 123 | initialTraces :: Traces |
| 124 | initialTraces = Traces { |
| 125 | tracePhasesSW = False, |
| 126 | traceGenBindSW = False, |
| 127 | traceCTravSW = False, |
| 128 | dumpCHSSW = False |
| 129 | } |