Cabal-1.18.1.5: A framework for packaging Haskell software

Copyright | Isaac Jones 2003-2007
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
Language | Haskell98

Distribution.Simple.GHC

Description

This is a fairly large module. It contains most of the GHC-specific code for configuring, building and installing packages. It also exports a function for finding out what packages are already installed. Configuring involves finding the `ghc` and `ghc-pkg` programs, finding what language extensions this version of ghc supports and returning a `Compiler` value.

`getInstalledPackages` involves calling the `ghc-pkg` program to find out what packages are installed.

Building is somewhat complex as there is quite a bit of information to take into account. We have to build libs and programs, possibly for profiling and shared libs. We have to support building libraries that will be usable by GHCi and also ghc's `-split-objs` feature. We have to compile any C files using ghc. Linking, especially for `split-objs` is remarkably complex, partly because there tend to be 1,000's of `.o` files and this can often be more than we can pass to the `ld` or `ar` programs in one go.

Installing for libs and exes involves finding the right files and copying them to the right places. One of the more tricky things about this module is remembering the layout of files in the build directory (which is not explicitly documented) and thus what search dirs are used for various kinds of files.

Synopsis

- getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]
- configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, Maybe Platform, ProgramConfiguration)
- getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex
- getPackageDBContents :: Verbosity -> PackageDB -> ProgramConfiguration -> IO PackageIndex
- buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()
- buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()
- replLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()
- replExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()
- installLib :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> PackageDescription -> Library -> ComponentLocalBuildInfo -> IO ()
- installExe :: Verbosity -> LocalBuildInfo -> InstallDirs FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> Executable -> IO ()
- libAbiHash :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO String
- initPackageDB :: Verbosity -> ProgramConfiguration -> FilePath -> IO ()
- invokeHcPkg :: Verbosity -> ProgramConfiguration -> PackageDBStack -> [String] -> IO ()
- registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()
- componentGhcOptions :: Verbosity -> LocalBuildInfo -> BuildInfo -> ComponentLocalBuildInfo -> FilePath -> GhcOptions
- ghcLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath
- ghcDynamic :: Verbosity -> ConfiguredProgram -> IO Bool

# Documentation

getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]

configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, Maybe Platform, ProgramConfiguration)

getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex

Given a package DB stack, return all installed packages.

getPackageDBContents :: Verbosity -> PackageDB -> ProgramConfiguration -> IO PackageIndex

Given a single package DB, return all installed packages.

buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

Build a library with GHC.

buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()

Build an executable with GHC.

replLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO ()

Build a library with GHC.

replExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO ()

Build an executable with GHC.

installLib

Arguments

:: Verbosity |
-> LocalBuildInfo |
-> FilePath | install location
-> FilePath | install location for dynamic librarys
-> FilePath | Build location
-> PackageDescription |
-> Library |
-> ComponentLocalBuildInfo |
-> IO () |

Install for ghc, .hi, .a and, if --with-ghci given, .o

installExe

Arguments

:: Verbosity |
-> LocalBuildInfo |
-> InstallDirs FilePath | Where to copy the files to
-> FilePath | Build location
-> (FilePath, FilePath) | Executable (prefix,suffix)
-> PackageDescription |
-> Executable |
-> IO () |

Install executables for GHC.

libAbiHash :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO String

Extracts a String representing a hash of the ABI of a built library. It can fail if the library has not yet been built.

initPackageDB :: Verbosity -> ProgramConfiguration -> FilePath -> IO ()

Create an empty package DB at the specified location.

invokeHcPkg :: Verbosity -> ProgramConfiguration -> PackageDBStack -> [String] -> IO ()

Run 'ghc-pkg' using a given package DB stack, directly forwarding the provided command-line arguments to it.

registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO ()

componentGhcOptions :: Verbosity -> LocalBuildInfo -> BuildInfo -> ComponentLocalBuildInfo -> FilePath -> GhcOptions

ghcLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath

ghcDynamic :: Verbosity -> ConfiguredProgram -> IO Bool