-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A framework for packaging Haskell software -- -- The Haskell Common Architecture for Building Applications and -- Libraries: a framework defining a common interface for authors to more -- easily build their Haskell applications in a portable way. -- -- The Haskell Cabal is part of a larger infrastructure for distributing, -- organizing, and cataloging Haskell libraries and tools. @package Cabal @version 1.14.0 -- | This module defines the detailed test suite interface which makes it -- possible to expose individual tests to Cabal or other test agents. module Distribution.TestSuite -- | Options are provided to pass options to test runners, making -- tests reproducable. Each option is a (String, -- String) of the form (Name, Value). Use -- mappend to combine sets of Options; if the same option -- is given different values, the value from the left argument of -- mappend will be used. newtype Options Options :: [(String, String)] -> Options -- | Read an option from the specified set of Options. It is an -- error to lookup an option that has not been specified. For this -- reason, test agents should mappend any Options against -- the defaultOptions for a test, so the default value specified -- by the test framework will be used for any otherwise-unspecified -- options. lookupOption :: Read r => String -> Options -> r class TestOptions t name :: TestOptions t => t -> String options :: TestOptions t => t -> [(String, TypeRep)] defaultOptions :: TestOptions t => t -> IO Options check :: TestOptions t => t -> Options -> [String] -- | Test is a wrapper for pure and impure tests so that lists -- containing arbitrary test types can be constructed. data Test -- | A convenient function for wrapping pure tests into Tests. pure :: PureTestable p => p -> Test -- | A convenient function for wrapping impure tests into Tests. impure :: ImpureTestable i => i -> Test data Result -- | indicates a successful test Pass :: Result -- | indicates a test completed unsuccessfully; the String value -- should be a human-readable message indicating how the test failed. Fail :: String -> Result -- | indicates a test that could not be completed due to some error; the -- test framework should provide a message indicating the nature of the -- error. Error :: String -> Result -- | Class abstracting impure tests. Test frameworks should implement this -- class only as a last resort for test types which actually require -- IO. In particular, tests that simply require pseudo-random -- number generation can be implemented as pure tests. class TestOptions t => ImpureTestable t runM :: ImpureTestable t => t -> Options -> IO Result -- | Class abstracting pure tests. Test frameworks should prefer to -- implement this class over ImpureTestable. A default instance -- exists so that any pure test can be lifted into an impure test; when -- lifted, any exceptions are automatically caught. Test agents that lift -- pure tests themselves must handle exceptions. class TestOptions t => PureTestable t run :: PureTestable t => t -> Options -> Result instance Read Options instance Show Options instance Eq Options instance Read Result instance Show Result instance Eq Result instance ImpureTestable Test instance TestOptions Test instance Monoid Options -- | Remove the "literal" markups from a Haskell source file, including -- ">", "\begin{code}", "\end{code}", and -- "#" module Distribution.Simple.PreProcess.Unlit -- | unlit takes a filename (for error reports), and transforms the -- given string, to eliminate the literate comments from the program -- text. unlit :: FilePath -> String -> Either String String -- | No unliteration. plain :: String -> String -> String -- | This is a library of parser combinators, originally written by Koen -- Claessen. It parses all alternatives in parallel, so it never keeps -- hold of the beginning of the input string, a common source of space -- leaks with other parsers. The '(+++)' choice combinator is genuinely -- commutative; it makes no difference which branch is "shorter". -- -- See also Koen's paper Parallel Parsing Processes -- (http://www.cs.chalmers.se/~koen/publications.html). -- -- This version of ReadP has been locally hacked to make it H98, by -- Martin Sjögren mailto:msjogren@gmail.com module Distribution.Compat.ReadP type ReadP r a = Parser r Char a -- | Consumes and returns the next character. Fails if there is no input -- left. get :: ReadP r Char -- | Look-ahead: returns the part of the input that is left, without -- consuming it. look :: ReadP r String -- | Symmetric choice. (+++) :: ReadP r a -> ReadP r a -> ReadP r a -- | Local, exclusive, left-biased choice: If left parser locally produces -- any result at all, then right parser is not used. (<++) :: ReadP a a -> ReadP r a -> ReadP r a -- | Transforms a parser into one that does the same, but in addition -- returns the exact characters read. IMPORTANT NOTE: gather gives -- a runtime error if its first argument is built using any occurrences -- of readS_to_P. gather :: ReadP (String -> P Char r) a -> ReadP r (String, a) -- | Always fails. pfail :: ReadP r a -- | Consumes and returns the next character, if it satisfies the specified -- predicate. satisfy :: (Char -> Bool) -> ReadP r Char -- | Parses and returns the specified character. char :: Char -> ReadP r Char -- | Parses and returns the specified string. string :: String -> ReadP r String -- | Parses the first zero or more characters satisfying the predicate. munch :: (Char -> Bool) -> ReadP r String -- | Parses the first one or more characters satisfying the predicate. munch1 :: (Char -> Bool) -> ReadP r String -- | Skips all whitespace. skipSpaces :: ReadP r () -- | Combines all parsers in the specified list. choice :: [ReadP r a] -> ReadP r a -- | count n p parses n occurrences of p in -- sequence. A list of results is returned. count :: Int -> ReadP r a -> ReadP r [a] -- | between open close p parses open, followed by -- p and finally close. Only the value of p is -- returned. between :: ReadP r open -> ReadP r close -> ReadP r a -> ReadP r a -- | option x p will either parse p or return x -- without consuming any input. option :: a -> ReadP r a -> ReadP r a -- | optional p optionally parses p and always returns -- (). optional :: ReadP r a -> ReadP r () -- | Parses zero or more occurrences of the given parser. many :: ReadP r a -> ReadP r [a] -- | Parses one or more occurrences of the given parser. many1 :: ReadP r a -> ReadP r [a] -- | Like many, but discards the result. skipMany :: ReadP r a -> ReadP r () -- | Like many1, but discards the result. skipMany1 :: ReadP r a -> ReadP r () -- | sepBy p sep parses zero or more occurrences of p, -- separated by sep. Returns a list of values returned by -- p. sepBy :: ReadP r a -> ReadP r sep -> ReadP r [a] -- | sepBy1 p sep parses one or more occurrences of p, -- separated by sep. Returns a list of values returned by -- p. sepBy1 :: ReadP r a -> ReadP r sep -> ReadP r [a] -- | endBy p sep parses zero or more occurrences of p, -- separated and ended by sep. endBy :: ReadP r a -> ReadP r sep -> ReadP r [a] -- | endBy p sep parses one or more occurrences of p, -- separated and ended by sep. endBy1 :: ReadP r a -> ReadP r sep -> ReadP r [a] -- | chainr p op x parses zero or more occurrences of p, -- separated by op. Returns a value produced by a right -- associative application of all functions returned by op. If -- there are no occurrences of p, x is returned. chainr :: ReadP r a -> ReadP r (a -> a -> a) -> a -> ReadP r a -- | chainl p op x parses zero or more occurrences of p, -- separated by op. Returns a value produced by a left -- associative application of all functions returned by op. If -- there are no occurrences of p, x is returned. chainl :: ReadP r a -> ReadP r (a -> a -> a) -> a -> ReadP r a -- | Like chainl, but parses one or more occurrences of p. chainl1 :: ReadP r a -> ReadP r (a -> a -> a) -> ReadP r a -- | Like chainr, but parses one or more occurrences of p. chainr1 :: ReadP r a -> ReadP r (a -> a -> a) -> ReadP r a -- | manyTill p end parses zero or more occurrences of p, -- until end succeeds. Returns a list of values returned by -- p. manyTill :: ReadP r a -> ReadP [a] end -> ReadP r [a] -- | A parser for a type a, represented as a function that takes a -- String and returns a list of possible parses as -- (a,String) pairs. -- -- Note that this kind of backtracking parser is very inefficient; -- reading a large structure may be quite slow (cf ReadP). type ReadS a = String -> [(a, String)] -- | Converts a parser into a Haskell ReadS-style function. This is the -- main way in which you can "run" a ReadP parser: the expanded -- type is readP_to_S :: ReadP a -> String -> [(a,String)] -- readP_to_S :: ReadP a a -> ReadS a -- | Converts a Haskell ReadS-style function into a parser. Warning: This -- introduces local backtracking in the resulting parser, and therefore a -- possible inefficiency. readS_to_P :: ReadS a -> ReadP r a instance Monad (Parser r s) instance Functor (Parser r s) instance MonadPlus (P s) instance Monad (P s) -- | Simple parsing with failure module Distribution.ReadE -- | Parser with simple error reporting newtype ReadE a ReadE :: (String -> Either ErrorMsg a) -> ReadE a runReadE :: ReadE a -> String -> Either ErrorMsg a succeedReadE :: (String -> a) -> ReadE a failReadE :: ErrorMsg -> ReadE a parseReadE :: ReadE a -> ReadP r a readEOrFail :: ReadE a -> (String -> a) readP_to_E :: (String -> ErrorMsg) -> ReadP a a -> ReadE a instance Functor ReadE -- | A simple Verbosity type with associated utilities. There are 4 -- standard verbosity levels from silent, normal, -- verbose up to deafening. This is used for deciding what -- logging messages to print. module Distribution.Verbosity data Verbosity silent :: Verbosity normal :: Verbosity verbose :: Verbosity deafening :: Verbosity moreVerbose :: Verbosity -> Verbosity lessVerbose :: Verbosity -> Verbosity intToVerbosity :: Int -> Maybe Verbosity flagToVerbosity :: ReadE Verbosity showForCabal, showForGHC :: Verbosity -> String instance Show Verbosity instance Read Verbosity instance Eq Verbosity instance Ord Verbosity instance Enum Verbosity instance Bounded Verbosity -- | This defines a Text class which is a bit like the Read -- and Show classes. The difference is that is uses a modern -- pretty printer and parser system and the format is not expected to be -- Haskell concrete syntax but rather the external human readable -- representation used by Cabal. module Distribution.Text class Text a disp :: Text a => a -> Doc parse :: Text a => ReadP r a display :: Text a => a -> String simpleParse :: Text a => String -> Maybe a instance Text Version instance Text Bool -- | Data type for Haskell module names. module Distribution.ModuleName -- | A valid Haskell module name. data ModuleName -- | Construct a ModuleName from a valid module name String. -- -- This is just a convenience function intended for valid module strings. -- It is an error if it is used with a string that is not a valid module -- name. If you are parsing user input then use simpleParse -- instead. fromString :: String -> ModuleName -- | The individual components of a hierarchical module name. For example -- --
-- components (fromString "A.B.C") = ["A", "B", "C"] --components :: ModuleName -> [String] -- | Convert a module name to a file path, but without any file extension. -- For example: -- --
-- toFilePath (fromString "A.B.C") = "A/B/C" --toFilePath :: ModuleName -> FilePath -- | The module name Main. main :: ModuleName simple :: String -> ModuleName instance Eq ModuleName instance Ord ModuleName instance Read ModuleName instance Show ModuleName instance Text ModuleName -- | Cabal often needs to do slightly different things on specific -- platforms. You probably know about the os however using that is -- very inconvenient because it is a string and different Haskell -- implementations do not agree on using the same strings for the same -- platforms! (In particular see the controversy over "windows" vs -- "ming32"). So to make it more consistent and easy to use we have an -- OS enumeration. module Distribution.System data OS Linux :: OS Windows :: OS OSX :: OS FreeBSD :: OS OpenBSD :: OS NetBSD :: OS Solaris :: OS AIX :: OS HPUX :: OS IRIX :: OS HaLVM :: OS OtherOS :: String -> OS buildOS :: OS data Arch I386 :: Arch X86_64 :: Arch PPC :: Arch PPC64 :: Arch Sparc :: Arch Arm :: Arch Mips :: Arch SH :: Arch IA64 :: Arch S390 :: Arch Alpha :: Arch Hppa :: Arch Rs6000 :: Arch M68k :: Arch Vax :: Arch OtherArch :: String -> Arch buildArch :: Arch data Platform Platform :: Arch -> OS -> Platform buildPlatform :: Platform instance Eq OS instance Ord OS instance Show OS instance Read OS instance Eq Arch instance Ord Arch instance Show Arch instance Read Arch instance Eq Platform instance Ord Platform instance Show Platform instance Read Platform instance Text Platform instance Text Arch instance Text OS -- | Haskell language dialects and extensions module Language.Haskell.Extension -- | This represents a Haskell language dialect. -- -- Language Extensions are interpreted relative to one of these -- base languages. data Language -- | The Haskell 98 language as defined by the Haskell 98 report. -- http://haskell.org/onlinereport/ Haskell98 :: Language -- | The Haskell 2010 language as defined by the Haskell 2010 report. -- http://www.haskell.org/onlinereport/haskell2010 Haskell2010 :: Language -- | An unknown language, identified by its name. UnknownLanguage :: String -> Language knownLanguages :: [Language] -- | This represents language extensions beyond a base Language -- definition (such as Haskell98) that are supported by some -- implementations, usually in some special mode. -- -- Where applicable, references are given to an implementation's official -- documentation, e.g. "GHC § 7.2.1" for an extension documented in -- section 7.2.1 of the GHC User's Guide. data Extension -- | Enable a known extension EnableExtension :: KnownExtension -> Extension -- | Disable a known extension DisableExtension :: KnownExtension -> Extension -- | An unknown extension, identified by the name of its LANGUAGE -- pragma. UnknownExtension :: String -> Extension data KnownExtension -- |
-- import "network" Network.Socket --PackageImports :: KnownExtension -- |
-- import safe Network.Socket --SafeImports :: KnownExtension -- |
-- withinRange v anyVersion = True --anyVersion :: VersionRange -- | The empty version range, that is a version range containing no -- versions. -- -- This can be constructed using any unsatisfiable version range -- expression, for example > 1 && < 1. -- --
-- withinRange v anyVersion = False --noVersion :: VersionRange -- | The version range == v -- --
-- withinRange v' (thisVersion v) = v' == v --thisVersion :: Version -> VersionRange -- | The version range v || v -- --
-- withinRange v' (notThisVersion v) = v' /= v --notThisVersion :: Version -> VersionRange -- | The version range > v -- --
-- withinRange v' (laterVersion v) = v' > v --laterVersion :: Version -> VersionRange -- | The version range < v -- --
-- withinRange v' (earlierVersion v) = v' < v --earlierVersion :: Version -> VersionRange -- | The version range >= v -- --
-- withinRange v' (orLaterVersion v) = v' >= v --orLaterVersion :: Version -> VersionRange -- | The version range <= v -- --
-- withinRange v' (orEarlierVersion v) = v' <= v --orEarlierVersion :: Version -> VersionRange -- | The version range vr1 || vr2 -- --
-- withinRange v' (unionVersionRanges vr1 vr2) -- = withinRange v' vr1 || withinRange v' vr2 --unionVersionRanges :: VersionRange -> VersionRange -> VersionRange -- | The version range vr1 && vr2 -- --
-- withinRange v' (intersectVersionRanges vr1 vr2) -- = withinRange v' vr1 && withinRange v' vr2 --intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange -- | The version range == v.*. -- -- For example, for version 1.2, the version range == -- 1.2.* is the same as >= 1.2 && < 1.3 -- --
-- withinRange v' (laterVersion v) = v' >= v && v' < upper v -- where -- upper (Version lower t) = Version (init lower ++ [last lower + 1]) t --withinVersion :: Version -> VersionRange -- | The version range >= v1 && <= v2. -- -- In practice this is not very useful because we normally use inclusive -- lower bounds and exclusive upper bounds. -- --
-- withinRange v' (laterVersion v) = v' > v --betweenVersionsInclusive :: Version -> Version -> VersionRange -- | Does this version fall within the given range? -- -- This is the evaluation function for the VersionRange type. withinRange :: Version -> VersionRange -> Bool -- | Does this VersionRange place any restriction on the -- Version or is it in fact equivalent to AnyVersion. -- -- Note this is a semantic check, not simply a syntactic check. So for -- example the following is True (for all v). -- --
-- isAnyVersion (EarlierVersion v `UnionVersionRanges` orLaterVersion v) --isAnyVersion :: VersionRange -> Bool -- | This is the converse of isAnyVersion. It check if the version -- range is empty, if there is no possible version that satisfies the -- version range. -- -- For example this is True (for all v): -- --
-- isNoVersion (EarlierVersion v `IntersectVersionRanges` LaterVersion v) --isNoVersion :: VersionRange -> Bool -- | Is this version range in fact just a specific version? -- -- For example the version range ">= 3 && <= 3" -- contains only the version 3. isSpecificVersion :: VersionRange -> Maybe Version -- | Simplify a VersionRange expression. For non-empty version -- ranges this produces a canonical form. Empty or inconsistent version -- ranges are left as-is because that provides more information. -- -- If you need a canonical form use fromVersionIntervals . -- toVersionIntervals -- -- It satisfies the following properties: -- --
-- withinRange v (simplifyVersionRange r) = withinRange v r ---- --
-- withinRange v r = withinRange v r' -- ==> simplifyVersionRange r = simplifyVersionRange r' -- || isNoVersion r -- || isNoVersion r' --simplifyVersionRange :: VersionRange -> VersionRange -- | Fold over the basic syntactic structure of a VersionRange. -- -- This provides a syntacic view of the expression defining the version -- range. The syntactic sugar ">= v", "<= v" and -- "== v.*" is presented in terms of the other basic syntax. -- -- For a semantic view use asVersionIntervals. foldVersionRange :: a -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (a -> a -> a) -> (a -> a -> a) -> VersionRange -> a -- | An extended variant of foldVersionRange that also provides a -- view of in which the syntactic sugar ">= v", "<= -- v" and "== v.*" is presented explicitly rather than in -- terms of the other basic syntax. foldVersionRange' :: a -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (Version -> a) -> (Version -> Version -> a) -> (a -> a -> a) -> (a -> a -> a) -> (a -> a) -> VersionRange -> a -- | View a VersionRange as a union of intervals. -- -- This provides a canonical view of the semantics of a -- VersionRange as opposed to the syntax of the expression used to -- define it. For the syntactic view use foldVersionRange. -- -- Each interval is non-empty. The sequence is in increasing order and no -- intervals overlap or touch. Therefore only the first and last can be -- unbounded. The sequence can be empty if the range is empty (e.g. a -- range expression like 1 && 2). -- -- Other checks are trivial to implement using this view. For example: -- --
-- isNoVersion vr | [] <- asVersionIntervals vr = True -- | otherwise = False ---- --
-- isSpecificVersion vr -- | [(LowerBound v InclusiveBound -- ,UpperBound v' InclusiveBound)] <- asVersionIntervals vr -- , v == v' = Just v -- | otherwise = Nothing --asVersionIntervals :: VersionRange -> [VersionInterval] type VersionInterval = (LowerBound, UpperBound) data LowerBound LowerBound :: Version -> !Bound -> LowerBound data UpperBound NoUpperBound :: UpperBound UpperBound :: Version -> !Bound -> UpperBound data Bound ExclusiveBound :: Bound InclusiveBound :: Bound -- | A complementary representation of a VersionRange. Instead of a -- boolean version predicate it uses an increasing sequence of -- non-overlapping, non-empty intervals. -- -- The key point is that this representation gives a canonical -- representation for the semantics of VersionRanges. This makes -- it easier to check things like whether a version range is empty, -- covers all versions, or requires a certain minimum or maximum version. -- It also makes it easy to check equality or containment. It also makes -- it easier to identify 'simple' version predicates for translation into -- foreign packaging systems that do not support complex version range -- expressions. data VersionIntervals -- | Convert a VersionRange to a sequence of version intervals. toVersionIntervals :: VersionRange -> VersionIntervals -- | Convert a VersionIntervals value back into a -- VersionRange expression representing the version intervals. fromVersionIntervals :: VersionIntervals -> VersionRange -- | Test if a version falls within the version intervals. -- -- It exists mostly for completeness and testing. It satisfies the -- following properties: -- --
-- withinIntervals v (toVersionIntervals vr) = withinRange v vr -- withinIntervals v ivs = withinRange v (fromVersionIntervals ivs) --withinIntervals :: Version -> VersionIntervals -> Bool -- | Inspect the list of version intervals. versionIntervals :: VersionIntervals -> [VersionInterval] -- | Directly construct a VersionIntervals from a list of intervals. -- -- Each interval must be non-empty. The sequence must be in increasing -- order and no invervals may overlap or touch. If any of these -- conditions are not satisfied the function returns Nothing. mkVersionIntervals :: [VersionInterval] -> Maybe VersionIntervals unionVersionIntervals :: VersionIntervals -> VersionIntervals -> VersionIntervals intersectVersionIntervals :: VersionIntervals -> VersionIntervals -> VersionIntervals instance Show VersionRange instance Read VersionRange instance Eq VersionRange instance Eq Bound instance Show Bound instance Eq UpperBound instance Show UpperBound instance Eq LowerBound instance Show LowerBound instance Eq VersionIntervals instance Show VersionIntervals instance Text VersionRange instance Ord UpperBound instance Ord LowerBound -- | The License datatype. For more information about these and other -- open-source licenses, you may visit http://www.opensource.org/. -- -- The .cabal file allows you to specify a license file. Of -- course you can use any license you like but people often pick common -- open source licenses and it's useful if we can automatically recognise -- that (eg so we can display it on the hackage web pages). So you can -- also specify the license itself in the .cabal file from a -- short enumeration defined in this module. It includes GPL, -- LGPL and BSD3 licenses. module Distribution.License -- | This datatype indicates the license under which your package is -- released. It is also wise to add your license to each source file -- using the license-file field. The AllRightsReserved constructor -- is not actually a license, but states that you are not giving anyone -- else a license to use or distribute your work. The comments below are -- general guidelines. Please read the licenses themselves and consult a -- lawyer if you are unsure of your rights to release the software. data License -- | GNU Public License. Source code must accompany alterations. GPL :: (Maybe Version) -> License -- | Lesser GPL, Less restrictive than GPL, useful for libraries. LGPL :: (Maybe Version) -> License -- | 3-clause BSD license, newer, no advertising clause. Very free license. BSD3 :: License -- | 4-clause BSD license, older, with advertising clause. You almost -- certainly want to use the BSD3 license instead. BSD4 :: License -- | The MIT license, similar to the BSD3. Very free license. MIT :: License -- | Holder makes no claim to ownership, least restrictive license. PublicDomain :: License -- | No rights are granted to others. Undistributable. Most restrictive. AllRightsReserved :: License -- | Some other license. OtherLicense :: License -- | Not a recognised license. Allows us to deal with future extensions -- more gracefully. UnknownLicense :: String -> License knownLicenses :: [License] instance Read License instance Show License instance Eq License instance Text License -- | Defines a package identifier along with a parser and pretty printer -- for it. PackageIdentifiers consist of a name and an exact -- version. It also defines a Dependency data type. A dependency -- is a package name and a version range, like "foo >= 1.2 -- && < 2". module Distribution.Package newtype PackageName PackageName :: String -> PackageName -- | The name and version of a package. data PackageIdentifier PackageIdentifier :: PackageName -> Version -> PackageIdentifier -- | The name of this package, eg. foo pkgName :: PackageIdentifier -> PackageName -- | the version of this package, eg 1.2 pkgVersion :: PackageIdentifier -> Version -- | Type alias so we can use the shorter name PackageId. type PackageId = PackageIdentifier -- | An InstalledPackageId uniquely identifies an instance of an installed -- package. There can be at most one package with a given -- InstalledPackageId in a package database, or overlay of -- databases. newtype InstalledPackageId InstalledPackageId :: String -> InstalledPackageId -- | Describes a dependency on a source package (API) data Dependency Dependency :: PackageName -> VersionRange -> Dependency thisPackageVersion :: PackageIdentifier -> Dependency notThisPackageVersion :: PackageIdentifier -> Dependency -- | Simplify the VersionRange expression in a Dependency. -- See simplifyVersionRange. simplifyDependency :: Dependency -> Dependency -- | Class of things that have a PackageIdentifier -- -- Types in this class are all notions of a package. This allows us to -- have different types for the different phases that packages go though, -- from simple name/id, package description, configured or installed -- packages. -- -- Not all kinds of packages can be uniquely identified by a -- PackageIdentifier. In particular, installed packages cannot, -- there may be many installed instances of the same source package. class Package pkg packageId :: Package pkg => pkg -> PackageIdentifier packageName :: Package pkg => pkg -> PackageName packageVersion :: Package pkg => pkg -> Version -- | Subclass of packages that have specific versioned dependencies. -- -- So for example a not-yet-configured package has dependencies on -- version ranges, not specific versions. A configured or an already -- installed package depends on exact versions. Some operations or data -- structures (like dependency graphs) only make sense on this subclass -- of package types. class Package pkg => PackageFixedDeps pkg depends :: PackageFixedDeps pkg => pkg -> [PackageIdentifier] instance Read PackageName instance Show PackageName instance Eq PackageName instance Ord PackageName instance Read PackageIdentifier instance Show PackageIdentifier instance Eq PackageIdentifier instance Ord PackageIdentifier instance Read InstalledPackageId instance Show InstalledPackageId instance Eq InstalledPackageId instance Ord InstalledPackageId instance Read Dependency instance Show Dependency instance Eq Dependency instance Package PackageIdentifier instance Text Dependency instance Text InstalledPackageId instance Text PackageIdentifier instance Text PackageName -- | A large and somewhat miscellaneous collection of utility functions -- used throughout the rest of the Cabal lib and in other tools that use -- the Cabal lib like cabal-install. It has a very simple set of -- logging actions. It has low level functions for running programs, a -- bunch of wrappers for various directory and file functions that do -- extra logging. module Distribution.Simple.Utils cabalVersion :: Version die :: String -> IO a dieWithLocation :: FilePath -> Maybe Int -> String -> IO a topHandler :: IO a -> IO a -- | Non fatal conditions that may be indicative of an error or problem. -- -- We display these at the normal verbosity level. warn :: Verbosity -> String -> IO () -- | Useful status messages. -- -- We display these at the normal verbosity level. -- -- This is for the ordinary helpful status messages that users see. Just -- enough information to know that things are working but not floods of -- detail. notice :: Verbosity -> String -> IO () setupMessage :: Verbosity -> String -> PackageIdentifier -> IO () -- | More detail on the operation of some action. -- -- We display these messages when the verbosity level is verbose info :: Verbosity -> String -> IO () -- | Detailed internal debugging information -- -- We display these messages when the verbosity level is deafening debug :: Verbosity -> String -> IO () -- | Perform an IO action, catching any IO exceptions and printing an error -- if one occurs. chattyTry :: String -> IO () -> IO () rawSystemExit :: Verbosity -> FilePath -> [String] -> IO () rawSystemExitCode :: Verbosity -> FilePath -> [String] -> IO ExitCode rawSystemExitWithEnv :: Verbosity -> FilePath -> [String] -> [(String, String)] -> IO () -- | Run a command and return its output. -- -- The output is assumed to be text in the locale encoding. rawSystemStdout :: Verbosity -> FilePath -> [String] -> IO String -- | Run a command and return its output, errors and exit status. -- Optionally also supply some input. Also provides control over whether -- the binary/text mode of the input and output. rawSystemStdInOut :: Verbosity -> FilePath -> [String] -> Maybe (String, Bool) -> Bool -> IO (String, String, ExitCode) maybeExit :: IO ExitCode -> IO () -- | Like the unix xargs program. Useful for when we've got very long -- command lines that might overflow an OS limit on command line length -- and so you need to invoke a command multiple times to get all the args -- in. -- -- Use it with either of the rawSystem variants above. For example: -- --
-- xargs (32*1024) (rawSystemExit verbosity) prog fixedArgs bigArgs --xargs :: Int -> ([String] -> IO ()) -> [String] -> [String] -> IO () -- | Look for a program on the path. findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath) -- | Look for a program and try to find it's version number. It can accept -- either an absolute path or the name of a program binary, in which case -- we will look for the program on the path. findProgramVersion :: String -> (String -> String) -> Verbosity -> FilePath -> IO (Maybe Version) smartCopySources :: Verbosity -> [FilePath] -> FilePath -> [ModuleName] -> [String] -> IO () -- | Same as createDirectoryIfMissing but logs at higher verbosity -- levels. createDirectoryIfMissingVerbose :: Verbosity -> Bool -> FilePath -> IO () -- | Copies a file without copying file permissions. The target file is -- created with default permissions. Any existing target file is -- replaced. -- -- At higher verbosity levels it logs an info message. copyFileVerbose :: Verbosity -> FilePath -> FilePath -> IO () copyDirectoryRecursiveVerbose :: Verbosity -> FilePath -> FilePath -> IO () -- | Copies a bunch of files to a target directory, preserving the -- directory structure in the target location. The target directories are -- created if they do not exist. -- -- The files are identified by a pair of base directory and a path -- relative to that base. It is only the relative part that is preserved -- in the destination. -- -- For example: -- --
-- copyFiles normal "dist/src"
-- [("", "src/Foo.hs"), ("dist/build/", "src/Bar.hs")]
--
--
-- This would copy "src/Foo.hs" to "dist/src/src/Foo.hs" and copy
-- "dist/build/src/Bar.hs" to "dist/src/src/Bar.hs".
--
-- This operation is not atomic. Any IO failure during the copy
-- (including any missing source files) leaves the target in an unknown
-- state so it is best to use it with a freshly created directory so that
-- it can be simply deleted if anything goes wrong.
copyFiles :: Verbosity -> FilePath -> [(FilePath, FilePath)] -> IO ()
-- | Install an ordinary file. This is like a file copy but the permissions
-- are set appropriately for an installed file. On Unix it is
-- "-rw-r--r--" while on Windows it uses the default permissions for the
-- target directory.
installOrdinaryFile :: Verbosity -> FilePath -> FilePath -> IO ()
-- | Install an executable file. This is like a file copy but the
-- permissions are set appropriately for an installed file. On Unix it is
-- "-rwxr-xr-x" while on Windows it uses the default permissions for the
-- target directory.
installExecutableFile :: Verbosity -> FilePath -> FilePath -> IO ()
-- | This is like copyFiles but uses installOrdinaryFile.
installOrdinaryFiles :: Verbosity -> FilePath -> [(FilePath, FilePath)] -> IO ()
-- | This installs all the files in a directory to a target location,
-- preserving the directory layout. All the files are assumed to be
-- ordinary rather than executable files.
installDirectoryContents :: Verbosity -> FilePath -> FilePath -> IO ()
setFileOrdinary, setFileExecutable :: FilePath -> IO ()
-- | The path name that represents the current directory. In Unix, it's
-- ".", but this is system-specific. (E.g. AmigaOS uses the
-- empty string "" for the current directory.)
currentDir :: FilePath
-- | Find a file by looking in a search path. The file path must match
-- exactly.
findFile :: [FilePath] -> FilePath -> IO FilePath
findFirstFile :: (a -> FilePath) -> [a] -> IO (Maybe a)
-- | Find a file by looking in a search path with one of a list of possible
-- file extensions. The file base name should be given and it will be
-- tried with each of the extensions in each element of the search path.
findFileWithExtension :: [String] -> [FilePath] -> FilePath -> IO (Maybe FilePath)
-- | Like findFileWithExtension but returns which element of the
-- search path the file was found in, and the file path relative to that
-- base directory.
findFileWithExtension' :: [String] -> [FilePath] -> FilePath -> IO (Maybe (FilePath, FilePath))
-- | Find the file corresponding to a Haskell module name.
--
-- This is similar to findFileWithExtension' but specialised to a
-- module name. The function fails if the file corresponding to the
-- module is missing.
findModuleFile :: [FilePath] -> [String] -> ModuleName -> IO (FilePath, FilePath)
-- | Finds the files corresponding to a list of Haskell module names.
--
-- As findModuleFile but for a list of module names.
findModuleFiles :: [FilePath] -> [String] -> [ModuleName] -> IO [(FilePath, FilePath)]
-- | List all the files in a directory and all subdirectories.
--
-- The order places files in sub-directories after all the files in their
-- parent directories. The list is generated lazily so is not well
-- defined if the source directory structure changes before the list is
-- used.
getDirectoryContentsRecursive :: FilePath -> IO [FilePath]
matchFileGlob :: FilePath -> IO [FilePath]
matchDirFileGlob :: FilePath -> FilePath -> IO [FilePath]
parseFileGlob :: FilePath -> Maybe FileGlob
data FileGlob
-- | No glob at all, just an ordinary file
NoGlob :: FilePath -> FileGlob
-- | dir prefix and extension, like "foo/bar/*.baz" corresponds to
-- FileGlob "foo/bar" ".baz"
FileGlob :: FilePath -> String -> FileGlob
-- | Use a temporary filename that doesn't already exist.
withTempFile :: FilePath -> String -> (FilePath -> Handle -> IO a) -> IO a
-- | Create and use a temporary directory.
--
-- Creates a new temporary directory inside the given directory, making
-- use of the template. The temp directory is deleted after use. For
-- example:
--
-- -- withTempDirectory verbosity "src" "sdist." $ \tmpDir -> do ... ---- -- The tmpDir will be a new subdirectory of the given directory, -- e.g. src/sdist.342. withTempDirectory :: Verbosity -> FilePath -> String -> (FilePath -> IO a) -> IO a -- | Package description file (pkgname.cabal) defaultPackageDesc :: Verbosity -> IO FilePath -- | Find a package description file in the given directory. Looks for -- .cabal files. findPackageDesc :: FilePath -> IO FilePath -- | Optional auxiliary package information file -- (pkgname.buildinfo) defaultHookedPackageDesc :: IO (Maybe FilePath) -- | Find auxiliary package information in the given directory. Looks for -- .buildinfo files. findHookedPackageDesc :: FilePath -> IO (Maybe FilePath) -- | Gets the contents of a file, but guarantee that it gets closed. -- -- The file is read lazily but if it is not fully consumed by the action -- then the remaining input is truncated and the file is closed. withFileContents :: FilePath -> (String -> IO a) -> IO a -- | Writes a file atomically. -- -- The file is either written sucessfully or an IO exception is raised -- and the original file is left unchanged. -- -- On windows it is not possible to delete a file that is open by a -- process. This case will give an IO exception but the atomic property -- is not affected. writeFileAtomic :: FilePath -> String -> IO () -- | Write a file but only if it would have new content. If we would be -- writing the same as the existing content then leave the file as is so -- that we do not update the file's modification time. rewriteFile :: FilePath -> String -> IO () fromUTF8 :: String -> String toUTF8 :: String -> String -- | Reads a UTF8 encoded text file as a Unicode String -- -- Reads lazily using ordinary readFile. readUTF8File :: FilePath -> IO String -- | Reads a UTF8 encoded text file as a Unicode String -- -- Same behaviour as withFileContents. withUTF8FileContents :: FilePath -> (String -> IO a) -> IO a -- | Writes a Unicode String as a UTF8 encoded text file. -- -- Uses writeFileAtomic, so provides the same guarantees. writeUTF8File :: FilePath -> String -> IO () -- | Fix different systems silly line ending conventions normaliseLineEndings :: String -> String equating :: Eq a => (b -> a) -> b -> b -> Bool comparing :: Ord a => (b -> a) -> b -> b -> Ordering isInfixOf :: String -> String -> Bool intercalate :: [a] -> [[a]] -> [a] lowercase :: String -> String -- | Wraps text to the default line width. Existing newlines are preserved. wrapText :: String -> String -- | Wraps a list of words to a list of lines of words of a particular -- width. wrapLine :: Int -> [String] -> [[String]] -- | This provides an abstraction which deals with configuring and running -- programs. A Program is a static notion of a known program. A -- ConfiguredProgram is a Program that has been found on -- the current machine and is ready to be run (possibly with some -- user-supplied default args). Configuring a program involves finding -- its location and if necessary finding its version. There's reasonable -- default behavior for trying to find "foo" in PATH, being able to -- override its location, etc. module Distribution.Simple.Program.Types -- | Represents a program which can be configured. -- -- Note: rather than constructing this directly, start with -- simpleProgram and override any extra fields. data Program Program :: String -> (Verbosity -> IO (Maybe FilePath)) -> (Verbosity -> FilePath -> IO (Maybe Version)) -> (Verbosity -> ConfiguredProgram -> IO [ProgArg]) -> Program -- | The simple name of the program, eg. ghc programName :: Program -> String -- | A function to search for the program if it's location was not -- specified by the user. Usually this will just be a programFindLocation :: Program -> Verbosity -> IO (Maybe FilePath) -- | Try to find the version of the program. For many programs this is not -- possible or is not necessary so it's ok to return Nothing. programFindVersion :: Program -> Verbosity -> FilePath -> IO (Maybe Version) -- | A function to do any additional configuration after we have located -- the program (and perhaps identified its version). It is allowed to -- return additional flags that will be passed to the program on every -- invocation. programPostConf :: Program -> Verbosity -> ConfiguredProgram -> IO [ProgArg] -- | Make a simple named program. -- -- By default we'll just search for it in the path and not try to find -- the version name. You can override these behaviours if necessary, eg: -- --
-- simpleProgram "foo" { programFindLocation = ... , programFindVersion ... }
--
simpleProgram :: String -> Program
-- | Represents a program which has been configured and is thus ready to be
-- run.
--
-- These are usually made by configuring a Program, but if you
-- have to construct one directly then start with
-- simpleConfiguredProgram and override any extra fields.
data ConfiguredProgram
ConfiguredProgram :: String -> Maybe Version -> [String] -> [String] -> ProgramLocation -> ConfiguredProgram
-- | Just the name again
programId :: ConfiguredProgram -> String
-- | The version of this program, if it is known.
programVersion :: ConfiguredProgram -> Maybe Version
-- | Default command-line args for this program. These flags will appear
-- first on the command line, so they can be overridden by subsequent
-- flags.
programDefaultArgs :: ConfiguredProgram -> [String]
-- | Override command-line args for this program. These flags will appear
-- last on the command line, so they override all earlier flags.
programOverrideArgs :: ConfiguredProgram -> [String]
-- | Location of the program. eg. /usr/bin/ghc-6.4
programLocation :: ConfiguredProgram -> ProgramLocation
-- | The full path of a configured program.
programPath :: ConfiguredProgram -> FilePath
type ProgArg = String
-- | Where a program was found. Also tells us whether it's specifed by user
-- or not. This includes not just the path, but the program as well.
data ProgramLocation
-- | The user gave the path to this program, eg.
-- --ghc-path=/usr/bin/ghc-6.6
UserSpecified :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath
-- | The program was found automatically.
FoundOnSystem :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath
-- | Make a simple ConfiguredProgram.
--
-- -- simpleConfiguredProgram "foo" (FoundOnSystem path) --simpleConfiguredProgram :: String -> ProgramLocation -> ConfiguredProgram instance Read ProgramLocation instance Show ProgramLocation instance Eq ProgramLocation instance Read ConfiguredProgram instance Show ConfiguredProgram instance Eq ConfiguredProgram -- | This module provides a data type for program invocations and functions -- to run them. module Distribution.Simple.Program.Run -- | Represents a specific invocation of a specific program. -- -- This is used as an intermediate type between deciding how to call a -- program and actually doing it. This provides the opportunity to the -- caller to adjust how the program will be called. These invocations can -- either be run directly or turned into shell or batch scripts. data ProgramInvocation ProgramInvocation :: FilePath -> [String] -> [(String, String)] -> Maybe FilePath -> Maybe String -> IOEncoding -> IOEncoding -> ProgramInvocation progInvokePath :: ProgramInvocation -> FilePath progInvokeArgs :: ProgramInvocation -> [String] progInvokeEnv :: ProgramInvocation -> [(String, String)] progInvokeCwd :: ProgramInvocation -> Maybe FilePath progInvokeInput :: ProgramInvocation -> Maybe String progInvokeInputEncoding :: ProgramInvocation -> IOEncoding progInvokeOutputEncoding :: ProgramInvocation -> IOEncoding data IOEncoding IOEncodingText :: IOEncoding IOEncodingUTF8 :: IOEncoding emptyProgramInvocation :: ProgramInvocation simpleProgramInvocation :: FilePath -> [String] -> ProgramInvocation programInvocation :: ConfiguredProgram -> [String] -> ProgramInvocation -- | Like the unix xargs program. Useful for when we've got very long -- command lines that might overflow an OS limit on command line length -- and so you need to invoke a command multiple times to get all the args -- in. -- -- It takes four template invocations corresponding to the simple, -- initial, middle and last invocations. If the number of args given is -- small enough that we can get away with just a single invocation then -- the simple one is used: -- --
-- $ simple args ---- -- If the number of args given means that we need to use multiple -- invocations then the templates for the initial, middle and last -- invocations are used: -- --
-- $ initial args_0 -- $ middle args_1 -- $ middle args_2 -- ... -- $ final args_n --multiStageProgramInvocation :: ProgramInvocation -> (ProgramInvocation, ProgramInvocation, ProgramInvocation) -> [String] -> [ProgramInvocation] runProgramInvocation :: Verbosity -> ProgramInvocation -> IO () getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String -- | This module provides an library interface to the ar program. module Distribution.Simple.Program.Ar -- | Call ar to create a library archive from a bunch of object -- files. createArLibArchive :: Verbosity -> ConfiguredProgram -> FilePath -> [FilePath] -> IO () -- | Like the unix xargs program. Useful for when we've got very long -- command lines that might overflow an OS limit on command line length -- and so you need to invoke a command multiple times to get all the args -- in. -- -- It takes four template invocations corresponding to the simple, -- initial, middle and last invocations. If the number of args given is -- small enough that we can get away with just a single invocation then -- the simple one is used: -- --
-- $ simple args ---- -- If the number of args given means that we need to use multiple -- invocations then the templates for the initial, middle and last -- invocations are used: -- --
-- $ initial args_0 -- $ middle args_1 -- $ middle args_2 -- ... -- $ final args_n --multiStageProgramInvocation :: ProgramInvocation -> (ProgramInvocation, ProgramInvocation, ProgramInvocation) -> [String] -> [ProgramInvocation] -- | This module provides an library interface to the ld linker -- program. module Distribution.Simple.Program.Ld -- | Call ld -r to link a bunch of object files together. combineObjectFiles :: Verbosity -> ConfiguredProgram -> FilePath -> [FilePath] -> IO () -- | This module provides an library interface to the hpc program. module Distribution.Simple.Program.Hpc markup :: ConfiguredProgram -> Verbosity -> FilePath -> FilePath -> FilePath -> [ModuleName] -> IO () union :: ConfiguredProgram -> Verbosity -> [FilePath] -> FilePath -> [ModuleName] -> IO () -- | This module provides an library interface to the hc-pkg -- program. Currently only GHC and LHC have hc-pkg programs. module Distribution.Simple.Program.Script -- | Generate a system script, either POSIX shell script or Windows batch -- file as appropriate for the given system. invocationAsSystemScript :: OS -> ProgramInvocation -> String -- | Generate a POSIX shell script that invokes a program. invocationAsShellScript :: ProgramInvocation -> String -- | Generate a Windows batch file that invokes a program. invocationAsBatchFile :: ProgramInvocation -> String -- | The module defines all the known built-in Programs. -- -- Where possible we try to find their version numbers. module Distribution.Simple.Program.Builtin -- | The default list of programs. These programs are typically used -- internally to Cabal. builtinPrograms :: [Program] ghcProgram :: Program ghcPkgProgram :: Program lhcProgram :: Program lhcPkgProgram :: Program nhcProgram :: Program hmakeProgram :: Program jhcProgram :: Program hugsProgram :: Program ffihugsProgram :: Program uhcProgram :: Program gccProgram :: Program ranlibProgram :: Program arProgram :: Program stripProgram :: Program happyProgram :: Program alexProgram :: Program hsc2hsProgram :: Program c2hsProgram :: Program cpphsProgram :: Program hscolourProgram :: Program haddockProgram :: Program greencardProgram :: Program ldProgram :: Program tarProgram :: Program cppProgram :: Program pkgConfigProgram :: Program hpcProgram :: Program -- | This provides a ProgramDb type which holds configured and -- not-yet configured programs. It is the parameter to lots of actions -- elsewhere in Cabal that need to look up and run programs. If we had a -- Cabal monad, the ProgramDb would probably be a reader or state -- component of it. -- -- One nice thing about using it is that any program that is registered -- with Cabal will get some "configure" and ".cabal" helpers like -- --with-foo-args --foo-path= and extra-foo-args. -- -- There's also a hook for adding programs in a Setup.lhs script. See -- hookedPrograms in UserHooks. This gives a hook user the ability -- to get the above flags and such so that they don't have to write all -- the PATH logic inside Setup.lhs. module Distribution.Simple.Program.Db -- | The configuration is a collection of information about programs. It -- contains information both about configured programs and also about -- programs that we are yet to configure. -- -- The idea is that we start from a collection of unconfigured programs -- and one by one we try to configure them at which point we move them -- into the configured collection. For unconfigured programs we record -- not just the Program but also any user-provided arguments and -- location for the program. data ProgramDb emptyProgramDb :: ProgramDb defaultProgramDb :: ProgramDb -- | The Read/Show instance does not preserve all the unconfigured -- Programs because Program is not in Read/Show because -- it contains functions. So to fully restore a deserialised -- ProgramDb use this function to add back all the known -- Programs. -- --
-- simpleProgram "foo" { programFindLocation = ... , programFindVersion ... }
--
simpleProgram :: String -> Program
-- | Look for a program on the path.
findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath)
-- | Look for a program and try to find it's version number. It can accept
-- either an absolute path or the name of a program binary, in which case
-- we will look for the program on the path.
findProgramVersion :: String -> (String -> String) -> Verbosity -> FilePath -> IO (Maybe Version)
-- | Represents a program which has been configured and is thus ready to be
-- run.
--
-- These are usually made by configuring a Program, but if you
-- have to construct one directly then start with
-- simpleConfiguredProgram and override any extra fields.
data ConfiguredProgram
ConfiguredProgram :: String -> Maybe Version -> [String] -> [String] -> ProgramLocation -> ConfiguredProgram
-- | Just the name again
programId :: ConfiguredProgram -> String
-- | The version of this program, if it is known.
programVersion :: ConfiguredProgram -> Maybe Version
-- | Default command-line args for this program. These flags will appear
-- first on the command line, so they can be overridden by subsequent
-- flags.
programDefaultArgs :: ConfiguredProgram -> [String]
-- | Override command-line args for this program. These flags will appear
-- last on the command line, so they override all earlier flags.
programOverrideArgs :: ConfiguredProgram -> [String]
-- | Location of the program. eg. /usr/bin/ghc-6.4
programLocation :: ConfiguredProgram -> ProgramLocation
-- | The full path of a configured program.
programPath :: ConfiguredProgram -> FilePath
type ProgArg = String
-- | Where a program was found. Also tells us whether it's specifed by user
-- or not. This includes not just the path, but the program as well.
data ProgramLocation
-- | The user gave the path to this program, eg.
-- --ghc-path=/usr/bin/ghc-6.6
UserSpecified :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath
-- | The program was found automatically.
FoundOnSystem :: FilePath -> ProgramLocation
locationPath :: ProgramLocation -> FilePath
-- | Runs the given configured program.
runProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
-- | Runs the given configured program and gets the output.
getProgramOutput :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String
-- | Represents a specific invocation of a specific program.
--
-- This is used as an intermediate type between deciding how to call a
-- program and actually doing it. This provides the opportunity to the
-- caller to adjust how the program will be called. These invocations can
-- either be run directly or turned into shell or batch scripts.
data ProgramInvocation
ProgramInvocation :: FilePath -> [String] -> [(String, String)] -> Maybe FilePath -> Maybe String -> IOEncoding -> IOEncoding -> ProgramInvocation
progInvokePath :: ProgramInvocation -> FilePath
progInvokeArgs :: ProgramInvocation -> [String]
progInvokeEnv :: ProgramInvocation -> [(String, String)]
progInvokeCwd :: ProgramInvocation -> Maybe FilePath
progInvokeInput :: ProgramInvocation -> Maybe String
progInvokeInputEncoding :: ProgramInvocation -> IOEncoding
progInvokeOutputEncoding :: ProgramInvocation -> IOEncoding
emptyProgramInvocation :: ProgramInvocation
simpleProgramInvocation :: FilePath -> [String] -> ProgramInvocation
programInvocation :: ConfiguredProgram -> [String] -> ProgramInvocation
runProgramInvocation :: Verbosity -> ProgramInvocation -> IO ()
getProgramInvocationOutput :: Verbosity -> ProgramInvocation -> IO String
-- | The default list of programs. These programs are typically used
-- internally to Cabal.
builtinPrograms :: [Program]
type ProgramConfiguration = ProgramDb
emptyProgramConfiguration, defaultProgramConfiguration :: ProgramConfiguration
restoreProgramConfiguration :: [Program] -> ProgramConfiguration -> ProgramConfiguration
-- | Add a known program that we may configure later
addKnownProgram :: Program -> ProgramDb -> ProgramDb
addKnownPrograms :: [Program] -> ProgramDb -> ProgramDb
lookupKnownProgram :: String -> ProgramDb -> Maybe Program
knownPrograms :: ProgramDb -> [(Program, Maybe ConfiguredProgram)]
-- | User-specify this path. Basically override any path information for
-- this program in the configuration. If it's not a known program ignore
-- it.
userSpecifyPath :: String -> FilePath -> ProgramDb -> ProgramDb
-- | Like userSpecifyPath but for a list of progs and their paths.
userSpecifyPaths :: [(String, FilePath)] -> ProgramDb -> ProgramDb
userMaybeSpecifyPath :: String -> Maybe FilePath -> ProgramDb -> ProgramDb
-- | User-specify the arguments for this program. Basically override any
-- args information for this program in the configuration. If it's not a
-- known program, ignore it..
userSpecifyArgs :: String -> [ProgArg] -> ProgramDb -> ProgramDb
-- | Like userSpecifyPath but for a list of progs and their args.
userSpecifyArgss :: [(String, [ProgArg])] -> ProgramDb -> ProgramDb
-- | Get any extra args that have been previously specified for a program.
userSpecifiedArgs :: Program -> ProgramDb -> [ProgArg]
-- | Try to find a configured program
lookupProgram :: Program -> ProgramDb -> Maybe ConfiguredProgram
-- | Update a configured program in the database.
updateProgram :: ConfiguredProgram -> ProgramDb -> ProgramDb
-- | Try to configure a specific program. If the program is already
-- included in the colleciton of unconfigured programs then we use any
-- user-supplied location and arguments. If the program gets configured
-- sucessfully it gets added to the configured collection.
--
-- Note that it is not a failure if the program cannot be configured.
-- It's only a failure if the user supplied a location and the program
-- could not be found at that location.
--
-- The reason for it not being a failure at this stage is that we don't
-- know up front all the programs we will need, so we try to configure
-- them all. To verify that a program was actually sucessfully configured
-- use requireProgram.
configureProgram :: Verbosity -> Program -> ProgramDb -> IO ProgramDb
-- | Try to configure all the known programs that have not yet been
-- configured.
configureAllKnownPrograms :: Verbosity -> ProgramDb -> IO ProgramDb
-- | reconfigure a bunch of programs given new user-specified args. It
-- takes the same inputs as userSpecifyPath and
-- userSpecifyArgs and for all progs with a new path it calls
-- configureProgram.
reconfigurePrograms :: Verbosity -> [(String, FilePath)] -> [(String, [ProgArg])] -> ProgramDb -> IO ProgramDb
-- | Check that a program is configured and available to be run.
--
-- It raises an exception if the program could not be configured,
-- otherwise it returns the configured program.
requireProgram :: Verbosity -> Program -> ProgramDb -> IO (ConfiguredProgram, ProgramDb)
-- | Check that a program is configured and available to be run.
--
-- Additionally check that the version of the program number is suitable
-- and return it. For example you could require AnyVersion or
-- orLaterVersion (Version [1,0] [])
--
-- It raises an exception if the program could not be configured or the
-- version is unsuitable, otherwise it returns the configured program and
-- its version number.
requireProgramVersion :: Verbosity -> Program -> VersionRange -> ProgramDb -> IO (ConfiguredProgram, Version, ProgramDb)
-- | Looks up the given program in the program database and runs it.
runDbProgram :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO ()
-- | Looks up the given program in the program database and runs it.
getDbProgramOutput :: Verbosity -> Program -> ProgramDb -> [ProgArg] -> IO String
ghcProgram :: Program
ghcPkgProgram :: Program
lhcProgram :: Program
lhcPkgProgram :: Program
nhcProgram :: Program
hmakeProgram :: Program
jhcProgram :: Program
hugsProgram :: Program
ffihugsProgram :: Program
uhcProgram :: Program
gccProgram :: Program
ranlibProgram :: Program
arProgram :: Program
stripProgram :: Program
happyProgram :: Program
alexProgram :: Program
hsc2hsProgram :: Program
c2hsProgram :: Program
cpphsProgram :: Program
hscolourProgram :: Program
haddockProgram :: Program
greencardProgram :: Program
ldProgram :: Program
tarProgram :: Program
cppProgram :: Program
pkgConfigProgram :: Program
hpcProgram :: Program
rawSystemProgram :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO ()
rawSystemProgramStdout :: Verbosity -> ConfiguredProgram -> [ProgArg] -> IO String
rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO ()
rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration -> [ProgArg] -> IO String
findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath)
-- | This has an enumeration of the various compilers that Cabal knows
-- about. It also specifies the default compiler. Sadly you'll often see
-- code that does case analysis on this compiler flavour enumeration
-- like:
--
-- -- case compilerFlavor comp of -- GHC -> GHC.getInstalledPackages verbosity packageDb progconf -- JHC -> JHC.getInstalledPackages verbosity packageDb progconf ---- -- Obviously it would be better to use the proper Compiler -- abstraction because that would keep all the compiler-specific code -- together. Unfortunately we cannot make this change yet without -- breaking the UserHooks api, which would break all custom -- Setup.hs files, so for the moment we just have to live with -- this deficiency. If you're interested, see ticket #50. module Distribution.Compiler data CompilerFlavor GHC :: CompilerFlavor NHC :: CompilerFlavor YHC :: CompilerFlavor Hugs :: CompilerFlavor HBC :: CompilerFlavor Helium :: CompilerFlavor JHC :: CompilerFlavor LHC :: CompilerFlavor UHC :: CompilerFlavor OtherCompiler :: String -> CompilerFlavor buildCompilerFlavor :: CompilerFlavor -- | The default compiler flavour to pick when compiling stuff. This -- defaults to the compiler used to build the Cabal lib. -- -- However if it's not a recognised compiler then it's Nothing and -- the user will have to specify which compiler they want. defaultCompilerFlavor :: Maybe CompilerFlavor -- | Like classifyCompilerFlavor but compatible with the old ReadS -- parser. -- -- It is compatible in the sense that it accepts only the same strings, -- eg GHC but not ghc. However other strings get mapped to -- OtherCompiler. The point of this is that we do not allow extra -- valid values that would upset older Cabal versions that had a stricter -- parser however we cope with new values more gracefully so that we'll -- be able to introduce new value in future without breaking things so -- much. parseCompilerFlavorCompat :: ReadP r CompilerFlavor data CompilerId CompilerId :: CompilerFlavor -> Version -> CompilerId instance Show CompilerFlavor instance Read CompilerFlavor instance Eq CompilerFlavor instance Ord CompilerFlavor instance Eq CompilerId instance Ord CompilerId instance Read CompilerId instance Show CompilerId instance Text CompilerId instance Text CompilerFlavor -- | Utilities for parsing PackageDescription and -- InstalledPackageInfo. -- -- The .cabal file format is not trivial, especially with the -- introduction of configurations and the section syntax that goes with -- that. This module has a bunch of parsing functions that is used by the -- .cabal parser and a couple others. It has the parsing -- framework code and also little parsers for many of the formats we get -- in various .cabal file fields, like module names, comma -- separated lists etc. module Distribution.ParseUtils type LineNo = Int data PError AmbigousParse :: String -> LineNo -> PError NoParse :: String -> LineNo -> PError TabsError :: LineNo -> PError FromString :: String -> (Maybe LineNo) -> PError data PWarning PWarning :: String -> PWarning UTFWarning :: LineNo -> String -> PWarning locatedErrorMsg :: PError -> (Maybe LineNo, String) syntaxError :: LineNo -> String -> ParseResult a warning :: String -> ParseResult () runP :: LineNo -> String -> ReadP a a -> String -> ParseResult a runE :: LineNo -> String -> ReadE a -> String -> ParseResult a data ParseResult a ParseFailed :: PError -> ParseResult a ParseOk :: [PWarning] -> a -> ParseResult a catchParseError :: ParseResult a -> (PError -> ParseResult a) -> ParseResult a parseFail :: PError -> ParseResult a showPWarning :: FilePath -> PWarning -> String data Field -- | A regular property: value field F :: LineNo -> String -> String -> Field -- | A section with a name and possible parameter. The syntactic structure -- is: -- --
-- sectionname arg {
-- field*
-- }
--
Section :: LineNo -> String -> String -> [Field] -> Field
-- | A conditional block with an optional else branch:
--
--
-- if condition {
-- field*
-- } else {
-- field*
-- }
--
IfBlock :: LineNo -> String -> [Field] -> [Field] -> Field
fName :: Field -> String
lineNo :: Field -> LineNo
-- | Field descriptor. The parameter a parameterizes over where
-- the field's value is stored in.
data FieldDescr a
FieldDescr :: String -> (a -> Doc) -> (LineNo -> String -> a -> ParseResult a) -> FieldDescr a
fieldName :: FieldDescr a -> String
fieldGet :: FieldDescr a -> a -> Doc
-- | fieldSet n str x Parses the field value from the given input
-- string str and stores the result in x if the parse
-- was successful. Otherwise, reports an error on line number n.
fieldSet :: FieldDescr a -> LineNo -> String -> a -> ParseResult a
ppField :: String -> Doc -> Doc
ppFields :: [FieldDescr a] -> a -> Doc
readFields :: String -> ParseResult [Field]
readFieldsFlat :: String -> ParseResult [Field]
showFields :: [FieldDescr a] -> a -> String
showSingleNamedField :: [FieldDescr a] -> String -> Maybe (a -> String)
parseFields :: [FieldDescr a] -> a -> String -> ParseResult a
parseFieldsFlat :: [FieldDescr a] -> a -> String -> ParseResult a
parseFilePathQ :: ReadP r FilePath
parseTokenQ :: ReadP r String
parseTokenQ' :: ReadP r String
-- | parse a module name
parseModuleNameQ :: ReadP r ModuleName
parseBuildTool :: ReadP r Dependency
parsePkgconfigDependency :: ReadP r Dependency
parseOptVersion :: ReadP r Version
parsePackageNameQ :: ReadP r PackageName
parseVersionRangeQ :: ReadP r VersionRange
parseTestedWithQ :: ReadP r (CompilerFlavor, VersionRange)
parseLicenseQ :: ReadP r License
parseLanguageQ :: ReadP r Language
parseExtensionQ :: ReadP r Extension
parseSepList :: ReadP r b -> ReadP r a -> ReadP r [a]
parseCommaList :: ReadP r a -> ReadP r [a]
parseOptCommaList :: ReadP r a -> ReadP r [a]
showFilePath :: FilePath -> Doc
showToken :: String -> Doc
showTestedWith :: (CompilerFlavor, VersionRange) -> Doc
-- | Pretty-print free-format text, ensuring that it is vertically aligned,
-- and with blank lines replaced by dots for correct re-parsing.
showFreeText :: String -> Doc
parseFreeText :: ReadP s String
field :: String -> (a -> Doc) -> (ReadP a a) -> FieldDescr a
simpleField :: String -> (a -> Doc) -> (ReadP a a) -> (b -> a) -> (a -> b -> b) -> FieldDescr b
listField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
spaceListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
commaListField :: String -> (a -> Doc) -> (ReadP [a] a) -> (b -> [a]) -> ([a] -> b -> b) -> FieldDescr b
optsField :: String -> CompilerFlavor -> (b -> [(CompilerFlavor, [String])]) -> ([(CompilerFlavor, [String])] -> b -> b) -> FieldDescr b
liftField :: (b -> a) -> (a -> b -> b) -> FieldDescr a -> FieldDescr b
boolField :: String -> (b -> Bool) -> (Bool -> b -> b) -> FieldDescr b
parseQuoted :: ReadP r a -> ReadP r a
-- | The type of a function which, given a name-value pair of an
-- unrecognized field, and the current structure being built, decides
-- whether to incorporate the unrecognized field (by returning Just x,
-- where x is a possibly modified version of the structure being built),
-- or not (by returning Nothing).
type UnrecFieldParser a = (String, String) -> a -> Maybe a
-- | A default unrecognized field parser which simply returns Nothing, i.e.
-- ignores all unrecognized fields, so warnings will be generated.
warnUnrec :: UnrecFieldParser a
-- | A default unrecognized field parser which silently (i.e. no warnings
-- will be generated) ignores unrecognized fields, by returning the
-- structure being built unmodified.
ignoreUnrec :: UnrecFieldParser a
instance Show PError
instance Show PWarning
instance Show a => Show (ParseResult a)
instance Show Field
instance Eq Field
instance Monad ParseResult
-- | This is the information about an installed package that is
-- communicated to the ghc-pkg program in order to register a
-- package. ghc-pkg now consumes this package format (as of
-- version 6.4). This is specific to GHC at the moment.
--
-- The .cabal file format is for describing a package that is
-- not yet installed. It has a lot of flexibility, like conditionals and
-- dependency ranges. As such, that format is not at all suitable for
-- describing a package that has already been built and installed. By the
-- time we get to that stage, we have resolved all conditionals and
-- resolved dependency version constraints to exact versions of dependent
-- packages. So, this module defines the InstalledPackageInfo data
-- structure that contains all the info we keep about an installed
-- package. There is a parser and pretty printer. The textual format is
-- rather simpler than the .cabal format: there are no sections,
-- for example.
module Distribution.InstalledPackageInfo
data InstalledPackageInfo_ m
InstalledPackageInfo :: InstalledPackageId -> PackageId -> License -> String -> String -> String -> String -> String -> String -> String -> String -> String -> Bool -> [m] -> [m] -> Bool -> [FilePath] -> [FilePath] -> [String] -> [String] -> [String] -> [FilePath] -> [String] -> [InstalledPackageId] -> [String] -> [String] -> [String] -> [FilePath] -> [String] -> [FilePath] -> [FilePath] -> InstalledPackageInfo_ m
installedPackageId :: InstalledPackageInfo_ m -> InstalledPackageId
sourcePackageId :: InstalledPackageInfo_ m -> PackageId
license :: InstalledPackageInfo_ m -> License
copyright :: InstalledPackageInfo_ m -> String
maintainer :: InstalledPackageInfo_ m -> String
author :: InstalledPackageInfo_ m -> String
stability :: InstalledPackageInfo_ m -> String
homepage :: InstalledPackageInfo_ m -> String
pkgUrl :: InstalledPackageInfo_ m -> String
synopsis :: InstalledPackageInfo_ m -> String
description :: InstalledPackageInfo_ m -> String
category :: InstalledPackageInfo_ m -> String
exposed :: InstalledPackageInfo_ m -> Bool
exposedModules :: InstalledPackageInfo_ m -> [m]
hiddenModules :: InstalledPackageInfo_ m -> [m]
trusted :: InstalledPackageInfo_ m -> Bool
importDirs :: InstalledPackageInfo_ m -> [FilePath]
libraryDirs :: InstalledPackageInfo_ m -> [FilePath]
hsLibraries :: InstalledPackageInfo_ m -> [String]
extraLibraries :: InstalledPackageInfo_ m -> [String]
extraGHCiLibraries :: InstalledPackageInfo_ m -> [String]
includeDirs :: InstalledPackageInfo_ m -> [FilePath]
includes :: InstalledPackageInfo_ m -> [String]
depends :: InstalledPackageInfo_ m -> [InstalledPackageId]
hugsOptions :: InstalledPackageInfo_ m -> [String]
ccOptions :: InstalledPackageInfo_ m -> [String]
ldOptions :: InstalledPackageInfo_ m -> [String]
frameworkDirs :: InstalledPackageInfo_ m -> [FilePath]
frameworks :: InstalledPackageInfo_ m -> [String]
haddockInterfaces :: InstalledPackageInfo_ m -> [FilePath]
haddockHTMLs :: InstalledPackageInfo_ m -> [FilePath]
type InstalledPackageInfo = InstalledPackageInfo_ ModuleName
data ParseResult a
ParseFailed :: PError -> ParseResult a
ParseOk :: [PWarning] -> a -> ParseResult a
data PError
AmbigousParse :: String -> LineNo -> PError
NoParse :: String -> LineNo -> PError
TabsError :: LineNo -> PError
FromString :: String -> (Maybe LineNo) -> PError
data PWarning
emptyInstalledPackageInfo :: InstalledPackageInfo_ m
parseInstalledPackageInfo :: String -> ParseResult InstalledPackageInfo
showInstalledPackageInfo :: InstalledPackageInfo -> String
showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
fieldsInstalledPackageInfo :: [FieldDescr InstalledPackageInfo]
instance Read m => Read (InstalledPackageInfo_ m)
instance Show m => Show (InstalledPackageInfo_ m)
instance Package (InstalledPackageInfo_ str)
-- | An index of packages.
module Distribution.Simple.PackageIndex
-- | The collection of information about packages from one or more
-- PackageDBs.
--
-- Packages are uniquely identified in by their
-- InstalledPackageId, they can also be effeciently looked up by
-- package name or by name and version.
data PackageIndex
-- | Build an index out of a bunch of packages.
--
-- If there are duplicates by InstalledPackageId then later ones
-- mask earlier ones.
fromList :: [InstalledPackageInfo] -> PackageIndex
-- | Merge two indexes.
--
-- Packages from the second mask packages from the first if they have the
-- exact same InstalledPackageId.
--
-- For packages with the same source PackageId, packages from the
-- second are "preferred" over those from the first. Being preferred
-- means they are top result when we do a lookup by source
-- PackageId. This is the mechanism we use to prefer user packages
-- over global packages.
merge :: PackageIndex -> PackageIndex -> PackageIndex
-- | Inserts a single package into the index.
--
-- This is equivalent to (but slightly quicker than) using mappend
-- or merge with a singleton index.
insert :: InstalledPackageInfo -> PackageIndex -> PackageIndex
-- | Removes a single installed package from the index.
deleteInstalledPackageId :: InstalledPackageId -> PackageIndex -> PackageIndex
-- | Removes all packages with this source PackageId from the index.
deleteSourcePackageId :: PackageId -> PackageIndex -> PackageIndex
-- | Removes all packages with this (case-sensitive) name from the index.
deletePackageName :: PackageName -> PackageIndex -> PackageIndex
-- | Does a lookup by source package id (name & version).
--
-- Since multiple package DBs mask each other by
-- InstalledPackageId, then we get back at most one package.
lookupInstalledPackageId :: PackageIndex -> InstalledPackageId -> Maybe InstalledPackageInfo
-- | Does a lookup by source package id (name & version).
--
-- There can be multiple installed packages with the same source
-- PackageId but different InstalledPackageId. They are
-- returned in order of preference, with the most preferred first.
lookupSourcePackageId :: PackageIndex -> PackageId -> [InstalledPackageInfo]
-- | Does a lookup by source package name.
lookupPackageName :: PackageIndex -> PackageName -> [(Version, [InstalledPackageInfo])]
-- | Does a lookup by source package name and a range of versions.
--
-- We get back any number of versions of the specified package name, all
-- satisfying the version range constraint.
lookupDependency :: PackageIndex -> Dependency -> [(Version, [InstalledPackageInfo])]
-- | Does a case-insensitive search by package name.
--
-- If there is only one package that compares case-insentiviely to this
-- name then the search is unambiguous and we get back all versions of
-- that package. If several match case-insentiviely but one matches
-- exactly then it is also unambiguous.
--
-- If however several match case-insentiviely and none match exactly then
-- we have an ambiguous result, and we get back all the versions of all
-- the packages. The list of ambiguous results is split by exact package
-- name. So it is a non-empty list of non-empty lists.
searchByName :: PackageIndex -> String -> SearchResult [InstalledPackageInfo]
data SearchResult a
None :: SearchResult a
Unambiguous :: a -> SearchResult a
Ambiguous :: [a] -> SearchResult a
-- | Does a case-insensitive substring search by package name.
--
-- That is, all packages that contain the given string in their name.
searchByNameSubstring :: PackageIndex -> String -> [InstalledPackageInfo]
-- | Get all the packages from the index.
allPackages :: PackageIndex -> [InstalledPackageInfo]
-- | Get all the packages from the index.
--
-- They are grouped by package name, case-sensitively.
allPackagesByName :: PackageIndex -> [[InstalledPackageInfo]]
-- | All packages that have immediate dependencies that are not in the
-- index.
--
-- Returns such packages along with the dependencies that they're
-- missing.
brokenPackages :: PackageIndex -> [(InstalledPackageInfo, [InstalledPackageId])]
-- | Tries to take the transitive closure of the package dependencies.
--
-- If the transitive closure is complete then it returns that subset of
-- the index. Otherwise it returns the broken packages as in
-- brokenPackages.
--
-- -- [GlobalPackageDB] -- [GlobalPackageDB, UserPackageDB] -- [GlobalPackageDB, SpecificPackageDB "package.conf.inplace"] ---- -- Note that the GlobalPackageDB is invariably at the bottom since -- it contains the rts, base and other special compiler-specific -- packages. -- -- We are not restricted to using just the above combinations. In -- particular we can use several custom package dbs and the user package -- db together. -- -- When it comes to writing, the top most (last) package is used. type PackageDBStack = [PackageDB] -- | Return the package that we should register into. This is the package -- db at the top of the stack. registrationPackageDB :: PackageDBStack -> PackageDB -- | Some compilers support optimising. Some have different levels. For -- compliers that do not the level is just capped to the level they do -- support. data OptimisationLevel NoOptimisation :: OptimisationLevel NormalOptimisation :: OptimisationLevel MaximumOptimisation :: OptimisationLevel flagToOptimisationLevel :: Maybe String -> OptimisationLevel type Flag = String languageToFlags :: Compiler -> Maybe Language -> [Flag] unsupportedLanguages :: Compiler -> [Language] -> [Language] -- | For the given compiler, return the flags for the supported extensions. extensionsToFlags :: Compiler -> [Extension] -> [Flag] -- | For the given compiler, return the extensions it does not support. unsupportedExtensions :: Compiler -> [Extension] -> [Extension] instance Eq PackageDB instance Ord PackageDB instance Show PackageDB instance Read PackageDB instance Eq OptimisationLevel instance Show OptimisationLevel instance Read OptimisationLevel instance Enum OptimisationLevel instance Bounded OptimisationLevel instance Show Compiler instance Read Compiler -- | This module provides an library interface to the hc-pkg -- program. Currently only GHC and LHC have hc-pkg programs. module Distribution.Simple.Program.HcPkg -- | Call hc-pkg to register a package. -- --
-- hc-pkg register {filename | -} [--user | --global | --package-conf]
--
register :: Verbosity -> ConfiguredProgram -> PackageDBStack -> Either FilePath InstalledPackageInfo -> IO ()
-- | Call hc-pkg to re-register a package.
--
--
-- hc-pkg register {filename | -} [--user | --global | --package-conf]
--
reregister :: Verbosity -> ConfiguredProgram -> PackageDBStack -> Either FilePath InstalledPackageInfo -> IO ()
-- | Call hc-pkg to unregister a package
--
-- -- hc-pkg unregister [pkgid] [--user | --global | --package-conf] --unregister :: Verbosity -> ConfiguredProgram -> PackageDB -> PackageId -> IO () -- | Call hc-pkg to expose a package. -- --
-- hc-pkg expose [pkgid] [--user | --global | --package-conf] --expose :: Verbosity -> ConfiguredProgram -> PackageDB -> PackageId -> IO () -- | Call hc-pkg to expose a package. -- --
-- hc-pkg expose [pkgid] [--user | --global | --package-conf] --hide :: Verbosity -> ConfiguredProgram -> PackageDB -> PackageId -> IO () -- | Call hc-pkg to get all the installed packages. dump :: Verbosity -> ConfiguredProgram -> PackageDB -> IO [InstalledPackageInfo] registerInvocation, reregisterInvocation :: ConfiguredProgram -> Verbosity -> PackageDBStack -> Either FilePath InstalledPackageInfo -> ProgramInvocation unregisterInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> PackageId -> ProgramInvocation exposeInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> PackageId -> ProgramInvocation hideInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> PackageId -> ProgramInvocation dumpInvocation :: ConfiguredProgram -> Verbosity -> PackageDB -> ProgramInvocation -- | This manages everything to do with where files get installed (though -- does not get involved with actually doing any installation). It -- provides an InstallDirs type which is a set of directories for -- where to install things. It also handles the fact that we use -- templates in these install dirs. For example most install dirs are -- relative to some $prefix and by changing the prefix all other -- dirs still end up changed appropriately. So it provides a -- PathTemplate type and functions for substituting for these -- templates. module Distribution.Simple.InstallDirs -- | The directories where we will install files for packages. -- -- We have several different directories for different types of files -- since many systems have conventions whereby different types of files -- in a package are installed in different direcotries. This is -- particularly the case on unix style systems. data InstallDirs dir InstallDirs :: dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> dir -> InstallDirs dir prefix :: InstallDirs dir -> dir bindir :: InstallDirs dir -> dir libdir :: InstallDirs dir -> dir libsubdir :: InstallDirs dir -> dir dynlibdir :: InstallDirs dir -> dir libexecdir :: InstallDirs dir -> dir progdir :: InstallDirs dir -> dir includedir :: InstallDirs dir -> dir datadir :: InstallDirs dir -> dir datasubdir :: InstallDirs dir -> dir docdir :: InstallDirs dir -> dir mandir :: InstallDirs dir -> dir htmldir :: InstallDirs dir -> dir haddockdir :: InstallDirs dir -> dir -- | The installation directories in terms of PathTemplates that -- contain variables. -- -- The defaults for most of the directories are relative to each other, -- in particular they are all relative to a single prefix. This makes it -- convenient for the user to override the default installation directory -- by only having to specify --prefix=... rather than overriding each -- individually. This is done by allowing $-style variables in the dirs. -- These are expanded by textual substituion (see -- substPathTemplate). -- -- A few of these installation directories are split into two components, -- the dir and subdir. The full installation path is formed by combining -- the two together with /. The reason for this is compatibility -- with other unix build systems which also support --libdir and -- --datadir. We would like users to be able to configure -- --libdir=/usr/lib64 for example but because by default we -- want to support installing multiple versions of packages and building -- the same package for multiple compilers we append the libsubdir to -- get: /usr/lib64/$pkgid/$compiler. -- -- An additional complication is the need to support relocatable packages -- on systems which support such things, like Windows. type InstallDirTemplates = InstallDirs PathTemplate defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c -- | Convert from abstract install directories to actual absolute ones by -- substituting for all the variables in the abstract paths, to get real -- absolute path. absoluteInstallDirs :: PackageIdentifier -> CompilerId -> CopyDest -> InstallDirs PathTemplate -> InstallDirs FilePath -- | The location prefix for the copy command. data CopyDest NoCopyDest :: CopyDest CopyTo :: FilePath -> CopyDest -- | Check which of the paths are relative to the installation $prefix. -- -- If any of the paths are not relative, ie they are absolute paths, then -- it prevents us from making a relocatable package (also known as a -- "prefix independent" package). prefixRelativeInstallDirs :: PackageIdentifier -> CompilerId -> InstallDirTemplates -> InstallDirs (Maybe FilePath) -- | Substitute the install dir templates into each other. -- -- To prevent cyclic substitutions, only some variables are allowed in -- particular dir templates. If out of scope vars are present, they are -- not substituted for. Checking for any remaining unsubstituted vars can -- be done as a subsequent operation. -- -- The reason it is done this way is so that in -- prefixRelativeInstallDirs we can replace prefix with the -- PrefixVar and get resulting PathTemplates that still -- have the PrefixVar in them. Doing this makes it each to check -- which paths are relative to the $prefix. substituteInstallDirTemplates :: PathTemplateEnv -> InstallDirTemplates -> InstallDirTemplates -- | An abstract path, posibly containing variables that need to be -- substituted for to get a real FilePath. data PathTemplate data PathTemplateVariable -- | The $prefix path variable PrefixVar :: PathTemplateVariable -- | The $bindir path variable BindirVar :: PathTemplateVariable -- | The $libdir path variable LibdirVar :: PathTemplateVariable -- | The $libsubdir path variable LibsubdirVar :: PathTemplateVariable -- | The $datadir path variable DatadirVar :: PathTemplateVariable -- | The $datasubdir path variable DatasubdirVar :: PathTemplateVariable -- | The $docdir path variable DocdirVar :: PathTemplateVariable -- | The $htmldir path variable HtmldirVar :: PathTemplateVariable -- | The $pkg package name path variable PkgNameVar :: PathTemplateVariable -- | The $version package version path variable PkgVerVar :: PathTemplateVariable -- | The $pkgid package Id path variable, eg foo-1.0 PkgIdVar :: PathTemplateVariable -- | The compiler name and version, eg ghc-6.6.1 CompilerVar :: PathTemplateVariable -- | The operating system name, eg windows or linux OSVar :: PathTemplateVariable -- | The cpu architecture name, eg i386 or x86_64 ArchVar :: PathTemplateVariable -- | The executable name; used in shell wrappers ExecutableNameVar :: PathTemplateVariable -- | The name of the test suite being run TestSuiteNameVar :: PathTemplateVariable -- | The result of the test suite being run, eg pass, -- fail, or error. TestSuiteResultVar :: PathTemplateVariable -- | The name of the benchmark being run BenchmarkNameVar :: PathTemplateVariable type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)] -- | Convert a FilePath to a PathTemplate including any -- template vars. toPathTemplate :: FilePath -> PathTemplate -- | Convert back to a path, any remaining vars are included fromPathTemplate :: PathTemplate -> FilePath substPathTemplate :: PathTemplateEnv -> PathTemplate -> PathTemplate -- | The initial environment has all the static stuff but no paths initialPathTemplateEnv :: PackageIdentifier -> CompilerId -> PathTemplateEnv platformTemplateEnv :: Platform -> PathTemplateEnv compilerTemplateEnv :: CompilerId -> PathTemplateEnv packageTemplateEnv :: PackageIdentifier -> PathTemplateEnv installDirsTemplateEnv :: InstallDirs PathTemplate -> PathTemplateEnv instance Read dir => Read (InstallDirs dir) instance Show dir => Show (InstallDirs dir) instance Eq CopyDest instance Show CopyDest instance Eq PathTemplateVariable instance Eq PathComponent instance Read PathTemplate instance Show PathTemplate instance Read PathComponent instance Show PathComponent instance Read PathTemplateVariable instance Show PathTemplateVariable instance Monoid dir => Monoid (InstallDirs dir) instance Functor InstallDirs -- | This is a big module, but not very complicated. The code is very -- regular and repetitive. It defines the command line interface for all -- the Cabal commands. For each command (like configure, -- build etc) it defines a type that holds all the flags, the -- default set of flags and a CommandUI that maps command line -- flags to and from the corresponding flags type. -- -- All the flags types are instances of Monoid, see -- http://www.haskell.org/pipermail/cabal-devel/2007-December/001509.html -- for an explanation. -- -- The types defined here get used in the front end and especially in -- cabal-install which has to do quite a bit of manipulating -- sets of command line flags. -- -- This is actually relatively nice, it works quite well. The main change -- it needs is to unify it with the code for managing sets of fields that -- can be read and written from files. This would allow us to save -- configure flags in config files. module Distribution.Simple.Setup -- | Flags that apply at the top level, not to any sub-command. data GlobalFlags GlobalFlags :: Flag Bool -> Flag Bool -> GlobalFlags globalVersion :: GlobalFlags -> Flag Bool globalNumericVersion :: GlobalFlags -> Flag Bool emptyGlobalFlags :: GlobalFlags defaultGlobalFlags :: GlobalFlags globalCommand :: CommandUI GlobalFlags -- | Flags to configure command data ConfigFlags ConfigFlags :: ProgramConfiguration -> [(String, FilePath)] -> [(String, [String])] -> Flag CompilerFlavor -> Flag FilePath -> Flag FilePath -> Flag Bool -> Flag Bool -> Flag Bool -> Flag Bool -> Flag Bool -> [String] -> Flag OptimisationLevel -> Flag PathTemplate -> Flag PathTemplate -> InstallDirs (Flag PathTemplate) -> Flag FilePath -> [FilePath] -> [FilePath] -> Flag FilePath -> Flag Verbosity -> Flag Bool -> Flag PackageDB -> Flag Bool -> Flag Bool -> Flag Bool -> [Dependency] -> FlagAssignment -> Flag Bool -> Flag Bool -> Flag Bool -> ConfigFlags -- | All programs that cabal may run configPrograms :: ConfigFlags -> ProgramConfiguration -- | user specifed programs paths configProgramPaths :: ConfigFlags -> [(String, FilePath)] -- | user specifed programs args configProgramArgs :: ConfigFlags -> [(String, [String])] -- | The "flavor" of the compiler, sugh as GHC or Hugs. configHcFlavor :: ConfigFlags -> Flag CompilerFlavor -- | given compiler location configHcPath :: ConfigFlags -> Flag FilePath -- | given hc-pkg location configHcPkg :: ConfigFlags -> Flag FilePath -- | Enable vanilla library configVanillaLib :: ConfigFlags -> Flag Bool -- | Enable profiling in the library configProfLib :: ConfigFlags -> Flag Bool -- | Build shared library configSharedLib :: ConfigFlags -> Flag Bool -- | Enable dynamic linking of the executables. configDynExe :: ConfigFlags -> Flag Bool -- | Enable profiling in the executables. configProfExe :: ConfigFlags -> Flag Bool -- | Extra arguments to configure configConfigureArgs :: ConfigFlags -> [String] -- | Enable optimization. configOptimization :: ConfigFlags -> Flag OptimisationLevel -- | Installed executable prefix. configProgPrefix :: ConfigFlags -> Flag PathTemplate -- | Installed executable suffix. configProgSuffix :: ConfigFlags -> Flag PathTemplate -- | Installation paths configInstallDirs :: ConfigFlags -> InstallDirs (Flag PathTemplate) configScratchDir :: ConfigFlags -> Flag FilePath -- | path to search for extra libraries configExtraLibDirs :: ConfigFlags -> [FilePath] -- | path to search for header files configExtraIncludeDirs :: ConfigFlags -> [FilePath] -- | dist prefix configDistPref :: ConfigFlags -> Flag FilePath -- | verbosity level configVerbosity :: ConfigFlags -> Flag Verbosity -- | The --user/--global flag configUserInstall :: ConfigFlags -> Flag Bool -- | Which package DB to use configPackageDB :: ConfigFlags -> Flag PackageDB -- | Enable compiling library for GHCi configGHCiLib :: ConfigFlags -> Flag Bool -- | Enable -split-objs with GHC configSplitObjs :: ConfigFlags -> Flag Bool -- | Enable executable stripping configStripExes :: ConfigFlags -> Flag Bool -- | Additional constraints for dependencies configConstraints :: ConfigFlags -> [Dependency] configConfigurationsFlags :: ConfigFlags -> FlagAssignment -- | Enable test suite compilation configTests :: ConfigFlags -> Flag Bool -- | Enable benchmark compilation configBenchmarks :: ConfigFlags -> Flag Bool -- | Enable test suite program coverage configLibCoverage :: ConfigFlags -> Flag Bool emptyConfigFlags :: ConfigFlags defaultConfigFlags :: ProgramConfiguration -> ConfigFlags configureCommand :: ProgramConfiguration -> CommandUI ConfigFlags -- | Flags to copy: (destdir, copy-prefix (backwards compat), -- verbosity) data CopyFlags CopyFlags :: Flag CopyDest -> Flag FilePath -> Flag Verbosity -> CopyFlags copyDest :: CopyFlags -> Flag CopyDest copyDistPref :: CopyFlags -> Flag FilePath copyVerbosity :: CopyFlags -> Flag Verbosity emptyCopyFlags :: CopyFlags defaultCopyFlags :: CopyFlags copyCommand :: CommandUI CopyFlags -- | Flags to install: (package db, verbosity) data InstallFlags InstallFlags :: Flag PackageDB -> Flag FilePath -> Flag Bool -> Flag Bool -> Flag Verbosity -> InstallFlags installPackageDB :: InstallFlags -> Flag PackageDB installDistPref :: InstallFlags -> Flag FilePath installUseWrapper :: InstallFlags -> Flag Bool installInPlace :: InstallFlags -> Flag Bool installVerbosity :: InstallFlags -> Flag Verbosity emptyInstallFlags :: InstallFlags defaultInstallFlags :: InstallFlags installCommand :: CommandUI InstallFlags data HaddockFlags HaddockFlags :: [(String, FilePath)] -> [(String, [String])] -> Flag Bool -> Flag Bool -> Flag String -> Flag Bool -> Flag Bool -> Flag FilePath -> Flag Bool -> Flag FilePath -> Flag PathTemplate -> Flag FilePath -> Flag Verbosity -> HaddockFlags haddockProgramPaths :: HaddockFlags -> [(String, FilePath)] haddockProgramArgs :: HaddockFlags -> [(String, [String])] haddockHoogle :: HaddockFlags -> Flag Bool haddockHtml :: HaddockFlags -> Flag Bool haddockHtmlLocation :: HaddockFlags -> Flag String haddockExecutables :: HaddockFlags -> Flag Bool haddockInternal :: HaddockFlags -> Flag Bool haddockCss :: HaddockFlags -> Flag FilePath haddockHscolour :: HaddockFlags -> Flag Bool haddockHscolourCss :: HaddockFlags -> Flag FilePath haddockContents :: HaddockFlags -> Flag PathTemplate haddockDistPref :: HaddockFlags -> Flag FilePath haddockVerbosity :: HaddockFlags -> Flag Verbosity emptyHaddockFlags :: HaddockFlags defaultHaddockFlags :: HaddockFlags haddockCommand :: CommandUI HaddockFlags data HscolourFlags HscolourFlags :: Flag FilePath -> Flag Bool -> Flag FilePath -> Flag Verbosity -> HscolourFlags hscolourCSS :: HscolourFlags -> Flag FilePath hscolourExecutables :: HscolourFlags -> Flag Bool hscolourDistPref :: HscolourFlags -> Flag FilePath hscolourVerbosity :: HscolourFlags -> Flag Verbosity emptyHscolourFlags :: HscolourFlags defaultHscolourFlags :: HscolourFlags hscolourCommand :: CommandUI HscolourFlags data BuildFlags BuildFlags :: [(String, FilePath)] -> [(String, [String])] -> Flag FilePath -> Flag Verbosity -> BuildFlags buildProgramPaths :: BuildFlags -> [(String, FilePath)] buildProgramArgs :: BuildFlags -> [(String, [String])] buildDistPref :: BuildFlags -> Flag FilePath buildVerbosity :: BuildFlags -> Flag Verbosity emptyBuildFlags :: BuildFlags defaultBuildFlags :: BuildFlags buildCommand :: ProgramConfiguration -> CommandUI BuildFlags buildVerbose :: BuildFlags -> Verbosity data CleanFlags CleanFlags :: Flag Bool -> Flag FilePath -> Flag Verbosity -> CleanFlags cleanSaveConf :: CleanFlags -> Flag Bool cleanDistPref :: CleanFlags -> Flag FilePath cleanVerbosity :: CleanFlags -> Flag Verbosity emptyCleanFlags :: CleanFlags defaultCleanFlags :: CleanFlags cleanCommand :: CommandUI CleanFlags -- | Flags to register and unregister: (user package, -- gen-script, in-place, verbosity) data RegisterFlags RegisterFlags :: Flag PackageDB -> Flag Bool -> Flag (Maybe FilePath) -> Flag Bool -> Flag FilePath -> Flag Verbosity -> RegisterFlags regPackageDB :: RegisterFlags -> Flag PackageDB regGenScript :: RegisterFlags -> Flag Bool regGenPkgConf :: RegisterFlags -> Flag (Maybe FilePath) regInPlace :: RegisterFlags -> Flag Bool regDistPref :: RegisterFlags -> Flag FilePath regVerbosity :: RegisterFlags -> Flag Verbosity emptyRegisterFlags :: RegisterFlags defaultRegisterFlags :: RegisterFlags registerCommand :: CommandUI RegisterFlags unregisterCommand :: CommandUI RegisterFlags -- | Flags to sdist: (snapshot, verbosity) data SDistFlags SDistFlags :: Flag Bool -> Flag FilePath -> Flag FilePath -> Flag Verbosity -> SDistFlags sDistSnapshot :: SDistFlags -> Flag Bool sDistDirectory :: SDistFlags -> Flag FilePath sDistDistPref :: SDistFlags -> Flag FilePath sDistVerbosity :: SDistFlags -> Flag Verbosity emptySDistFlags :: SDistFlags defaultSDistFlags :: SDistFlags sdistCommand :: CommandUI SDistFlags data TestFlags TestFlags :: Flag FilePath -> Flag Verbosity -> Flag PathTemplate -> Flag PathTemplate -> Flag TestShowDetails -> Flag Bool -> Flag [String] -> [PathTemplate] -> TestFlags testDistPref :: TestFlags -> Flag FilePath testVerbosity :: TestFlags -> Flag Verbosity testHumanLog :: TestFlags -> Flag PathTemplate testMachineLog :: TestFlags -> Flag PathTemplate testShowDetails :: TestFlags -> Flag TestShowDetails testKeepTix :: TestFlags -> Flag Bool testList :: TestFlags -> Flag [String] testOptions :: TestFlags -> [PathTemplate] emptyTestFlags :: TestFlags defaultTestFlags :: TestFlags testCommand :: CommandUI TestFlags data TestShowDetails Never :: TestShowDetails Failures :: TestShowDetails Always :: TestShowDetails data BenchmarkFlags BenchmarkFlags :: Flag FilePath -> Flag Verbosity -> [PathTemplate] -> BenchmarkFlags benchmarkDistPref :: BenchmarkFlags -> Flag FilePath benchmarkVerbosity :: BenchmarkFlags -> Flag Verbosity benchmarkOptions :: BenchmarkFlags -> [PathTemplate] emptyBenchmarkFlags :: BenchmarkFlags defaultBenchmarkFlags :: BenchmarkFlags benchmarkCommand :: CommandUI BenchmarkFlags -- | The location prefix for the copy command. data CopyDest NoCopyDest :: CopyDest CopyTo :: FilePath -> CopyDest -- | Arguments to pass to a configure script, e.g. generated by -- autoconf. configureArgs :: Bool -> ConfigFlags -> [String] configureOptions :: ShowOrParseArgs -> [OptionField ConfigFlags] configureCCompiler :: Verbosity -> ProgramConfiguration -> IO (FilePath, [String]) configureLinker :: Verbosity -> ProgramConfiguration -> IO (FilePath, [String]) installDirsOptions :: [OptionField (InstallDirs (Flag PathTemplate))] defaultDistPref :: FilePath -- | All flags are monoids, they come in two flavours: -- --
-- --ghc-option=foo --ghc-option=bar ---- -- gives us all the values [foo, bar] -- --
-- --enable-foo --disable-foo ---- -- gives us Just False So this Flag type is for the latter singular kind -- of flag. Its monoid instance gives us the behaviour where it starts -- out as NoFlag and later flags override earlier ones. data Flag a Flag :: a -> Flag a NoFlag :: Flag a toFlag :: a -> Flag a fromFlag :: Flag a -> a fromFlagOrDefault :: a -> Flag a -> a flagToMaybe :: Flag a -> Maybe a flagToList :: Flag a -> [a] boolOpt :: SFlags -> SFlags -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a boolOpt' :: OptFlags -> OptFlags -> MkOptDescr (a -> Flag Bool) (Flag Bool -> a -> a) a trueArg, falseArg :: SFlags -> LFlags -> Description -> (b -> Flag Bool) -> (Flag Bool -> (b -> b)) -> OptDescr b optionVerbosity :: (flags -> Flag Verbosity) -> (Flag Verbosity -> flags -> flags) -> OptionField flags instance Show a => Show (Flag a) instance Read a => Read (Flag a) instance Eq a => Eq (Flag a) instance Read ConfigFlags instance Show ConfigFlags instance Show CopyFlags instance Show InstallFlags instance Show SDistFlags instance Show RegisterFlags instance Show HscolourFlags instance Show HaddockFlags instance Show CleanFlags instance Show BuildFlags instance Eq TestShowDetails instance Ord TestShowDetails instance Enum TestShowDetails instance Bounded TestShowDetails instance Show TestShowDetails instance Monoid BenchmarkFlags instance Monoid TestFlags instance Monoid TestShowDetails instance Text TestShowDetails instance Monoid BuildFlags instance Monoid CleanFlags instance Monoid HaddockFlags instance Monoid HscolourFlags instance Monoid RegisterFlags instance Monoid SDistFlags instance Monoid InstallFlags instance Monoid CopyFlags instance Monoid ConfigFlags instance Monoid GlobalFlags instance Enum a => Enum (Flag a) instance Bounded a => Bounded (Flag a) instance Monoid (Flag a) instance Functor Flag -- | This is an alternative build system that delegates everything to the -- make program. All the commands just end up calling -- make with appropriate arguments. The intention was to allow -- preexisting packages that used makefiles to be wrapped into Cabal -- packages. In practice essentially all such packages were converted -- over to the "Simple" build system instead. Consequently this module is -- not used much and it certainly only sees cursory maintenance and no -- testing. Perhaps at some point we should stop pretending that it -- works. -- -- Uses the parsed command-line from Distribution.Simple.Setup in -- order to build Haskell tools using a backend build system based on -- make. Obviously we assume that there is a configure script, and that -- after the ConfigCmd has been run, there is a Makefile. Further -- assumptions: -- --
-- VERSION_<package> -- MIN_VERSION_<package>(A,B,C) ---- -- for each package in build-depends, which is true if -- the version of package in use is >= A.B.C, using -- the normal ordering on version numbers. module Distribution.Simple.Build.Macros generate :: PackageDescription -> LocalBuildInfo -> String -- | Generating the Paths_pkgname module. -- -- This is a module that Cabal generates for the benefit of packages. It -- enables them to find their version number and find any installed data -- files at runtime. This code should probably be split off into another -- module. module Distribution.Simple.Build.PathsModule generate :: PackageDescription -> LocalBuildInfo -> String -- | Generates the name of the environment variable controlling the path -- component of interest. pkgPathEnvVar :: PackageDescription -> String -> String -- | 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. module Distribution.Simple.GHC configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration) getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex -- | Build a library with GHC. buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO () -- | Build an executable with GHC. buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO () -- | Install for ghc, .hi, .a and, if --with-ghci given, .o installLib :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> PackageDescription -> Library -> IO () -- | Install executables for GHC. installExe :: Verbosity -> LocalBuildInfo -> InstallDirs FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> Executable -> IO () -- | Extracts a String representing a hash of the ABI of a built library. -- It can fail if the library has not yet been built. libAbiHash :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO String registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO () ghcOptions :: LocalBuildInfo -> BuildInfo -> ComponentLocalBuildInfo -> FilePath -> [String] ghcVerbosityOptions :: Verbosity -> [String] ghcPackageDbOptions :: PackageDBStack -> [String] ghcLibDir :: Verbosity -> LocalBuildInfo -> IO FilePath -- | 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. module Distribution.Simple.LHC configure :: Verbosity -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration) getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex -- | Build a library with LHC. buildLib :: Verbosity -> PackageDescription -> LocalBuildInfo -> Library -> ComponentLocalBuildInfo -> IO () -- | Build an executable with LHC. buildExe :: Verbosity -> PackageDescription -> LocalBuildInfo -> Executable -> ComponentLocalBuildInfo -> IO () -- | Install for ghc, .hi, .a and, if --with-ghci given, .o installLib :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> FilePath -> PackageDescription -> Library -> IO () -- | Install executables for GHC. installExe :: Verbosity -> LocalBuildInfo -> InstallDirs FilePath -> FilePath -> (FilePath, FilePath) -> PackageDescription -> Executable -> IO () registerPackage :: Verbosity -> InstalledPackageInfo -> PackageDescription -> LocalBuildInfo -> Bool -> PackageDBStack -> IO () ghcOptions :: LocalBuildInfo -> BuildInfo -> ComponentLocalBuildInfo -> FilePath -> [String] ghcVerbosityOptions :: Verbosity -> [String] -- | This module provides functions for locating various HPC-related paths -- and a function for adding the necessary options to a -- PackageDescription to build test suites with HPC enabled. module Distribution.Simple.Hpc -- | Conditionally enable Haskell Program Coverage by adding the necessary -- GHC options to a PackageDescription. -- -- TODO: do this differently in the build stage by constructing local -- build info, not by modifying the original PackageDescription. enableCoverage :: Bool -> String -> PackageDescription -> PackageDescription htmlDir :: FilePath -> FilePath -> FilePath tixDir :: FilePath -> FilePath -> FilePath -- | Path to the .tix file containing a test suite's sum statistics. tixFilePath :: FilePath -> FilePath -> FilePath -- | Generate the HTML markup for all of a package's test suites. markupPackage :: Verbosity -> LocalBuildInfo -> FilePath -> String -> [TestSuite] -> IO () -- | Generate the HTML markup for a test suite. markupTest :: Verbosity -> LocalBuildInfo -> FilePath -> String -> TestSuite -> IO () -- | This is the entry point into testing a built package. It performs the -- "./setup test" action. It runs test suites designated in the -- package description and reports on the results. module Distribution.Simple.Test -- | Perform the "./setup test" action. test :: PackageDescription -> LocalBuildInfo -> TestFlags -> IO () -- | The test runner used in library TestSuite stub executables. -- Runs a list of Tests. An executable calling this function is -- meant to be invoked as the child of a Cabal process during ./setup -- test. A TestSuiteLog, provided by Cabal, is read from the -- standard input; it supplies the name of the test suite and the -- location of the machine-readable test suite log file. Human-readable -- log information is written to the standard output for capture by the -- calling Cabal process. runTests :: [Test] -> IO () -- | Write the source file for a library TestSuite stub -- executable. writeSimpleTestStub :: TestSuite -> FilePath -> IO () -- | The filename of the source file for the stub executable associated -- with a library TestSuite. stubFilePath :: TestSuite -> FilePath -- | The name of the stub executable associated with a library -- TestSuite. stubName :: TestSuite -> FilePath -- | Logs all test results for a package, broken down first by test suite -- and then by test case. data PackageLog PackageLog :: PackageId -> CompilerId -> Platform -> [TestSuiteLog] -> PackageLog package :: PackageLog -> PackageId compiler :: PackageLog -> CompilerId platform :: PackageLog -> Platform testSuites :: PackageLog -> [TestSuiteLog] -- | Logs test suite results, itemized by test case. data TestSuiteLog TestSuiteLog :: String -> [Case] -> FilePath -> TestSuiteLog name :: TestSuiteLog -> String cases :: TestSuiteLog -> [Case] logFile :: TestSuiteLog -> FilePath data Case Case :: String -> Options -> Result -> Case caseName :: Case -> String caseOptions :: Case -> Options caseResult :: Case -> Result -- | From a TestSuiteLog, determine if the test suite passed. suitePassed :: TestSuiteLog -> Bool -- | From a TestSuiteLog, determine if the test suite failed. suiteFailed :: TestSuiteLog -> Bool -- | From a TestSuiteLog, determine if the test suite encountered -- errors. suiteError :: TestSuiteLog -> Bool instance Read Case instance Show Case instance Eq Case instance Read TestSuiteLog instance Show TestSuiteLog instance Eq TestSuiteLog instance Read PackageLog instance Show PackageLog instance Eq PackageLog -- | 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. module Distribution.Simple.PreProcess -- | Apply preprocessors to the sources from hsSourceDirs for a -- given component (lib, exe, or test suite). preprocessComponent :: PackageDescription -> Component -> LocalBuildInfo -> Bool -> Verbosity -> [PPSuffixHandler] -> IO () -- | Standard preprocessors: GreenCard, c2hs, hsc2hs, happy, alex and -- cpphs. knownSuffixHandlers :: [PPSuffixHandler] -- | Convenience function; get the suffixes of these preprocessors. ppSuffixes :: [PPSuffixHandler] -> [String] -- | A preprocessor for turning non-Haskell files with the given extension -- into plain Haskell source files. type PPSuffixHandler = (String, BuildInfo -> LocalBuildInfo -> PreProcessor) -- | 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)
-- stuff <- readFile inFile
-- writeFile outFile ("-- preprocessed as a test\n\n" ++ stuff)
-- return ExitSuccess
--
--
-- We split the input and output file names into a base directory and the
-- rest of the file name. The input base dir is the path in the list of
-- search dirs that this file was found in. The output base dir is the
-- build dir where all the generated source files are put.
--
-- The reason for splitting it up this way is that some pre-processors
-- don't simply generate one output .hs file from one input file but have
-- dependencies on other genereated files (notably c2hs, where building
-- one .hs file may require reading other .chi files, and then compiling
-- the .hs file may require reading a generated .h file). In these cases
-- the generated files need to embed relative path names to each other
-- (eg the generated .hs file mentions the .h file in the FFI imports).
-- This path must be relative to the base directory where the genereated
-- files are located, it cannot be relative to the top level of the build
-- tree because the compilers do not look for .h files relative to there,
-- ie we do not use "-I .", instead we use "-I dist/build" (or whatever
-- dist dir has been set by the user)
--
-- Most pre-processors do not care of course, so mkSimplePreProcessor and
-- runSimplePreProcessor functions handle the simple case.
data PreProcessor
PreProcessor :: Bool -> ((FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO ()) -> PreProcessor
platformIndependent :: PreProcessor -> Bool
runPreProcessor :: PreProcessor -> (FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO ()
mkSimplePreProcessor :: (FilePath -> FilePath -> Verbosity -> IO ()) -> (FilePath, FilePath) -> (FilePath, FilePath) -> Verbosity -> IO ()
runSimplePreProcessor :: PreProcessor -> FilePath -> FilePath -> Verbosity -> IO ()
ppCpp :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppCpp' :: [String] -> BuildInfo -> LocalBuildInfo -> PreProcessor
ppGreenCard :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppC2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppHsc2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppHappy :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppAlex :: BuildInfo -> LocalBuildInfo -> PreProcessor
ppUnlit :: PreProcessor
-- | This defines the API that Setup.hs scripts can use to
-- customise the way the build works. This module just defines the
-- UserHooks type. The predefined sets of hooks that implement the
-- Simple, Make and Configure build systems
-- are defined in Distribution.Simple. The UserHooks is a
-- big record of functions. There are 3 for each action, a pre, post and
-- the action itself. There are few other miscellaneous hooks, ones to
-- extend the set of programs and preprocessors and one to override the
-- function used to read the .cabal file.
--
-- This hooks type is widely agreed to not be the right solution. Partly
-- this is because changes to it usually break custom Setup.hs
-- files and yet many internal code changes do require changes to the
-- hooks. For example we cannot pass any extra parameters to most of the
-- functions that implement the various phases because it would involve
-- changing the types of the corresponding hook. At some point it will
-- have to be replaced.
module Distribution.Simple.UserHooks
-- | Hooks allow authors to add specific functionality before and after a
-- command is run, and also to specify additional preprocessors.
--
-- -- dist/setup-config --localBuildInfoFile :: FilePath -> FilePath getInstalledPackages :: Verbosity -> Compiler -> PackageDBStack -> ProgramConfiguration -> IO PackageIndex configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath -> ProgramConfiguration -> Verbosity -> IO (Compiler, ProgramConfiguration) configCompilerAux :: ConfigFlags -> IO (Compiler, ProgramConfiguration) -- | Makes a BuildInfo from C compiler and linker flags. -- -- This can be used with the output from configuration programs like -- pkg-config and similar package-specific programs like mysql-config, -- freealut-config etc. For example: -- --
-- ccflags <- rawSystemProgramStdoutConf verbosity prog conf ["--cflags"] -- ldflags <- rawSystemProgramStdoutConf verbosity prog conf ["--libs"] -- return (ccldOptionsBuildInfo (words ccflags) (words ldflags)) --ccLdOptionsBuildInfo :: [String] -> [String] -> BuildInfo tryGetConfigStateFile :: Read a => FilePath -> IO (Either String a) checkForeignDeps :: PackageDescription -> LocalBuildInfo -> Verbosity -> IO () -- | This is the entry point into installing a built package. Performs the -- "./setup install" and "./setup copy" actions. It -- moves files into place based on the prefix argument. It does the -- generic bits and then calls compiler-specific functions to do the -- rest. module Distribution.Simple.Install -- | Perform the "./setup install" and "./setup copy" -- actions. Move files into place based on the prefix argument. FIX: nhc -- isn't implemented yet. install :: PackageDescription -> LocalBuildInfo -> CopyFlags -> IO () -- | This is the entry point to actually building the modules in a package. -- It doesn't actually do much itself, most of the work is delegated to -- compiler-specific actions. It does do some non-compiler specific bits -- like running pre-processors. module Distribution.Simple.Build -- | Build the libraries and executables in this package. build :: PackageDescription -> LocalBuildInfo -> BuildFlags -> [PPSuffixHandler] -> IO () initialBuildSteps :: FilePath -> PackageDescription -> LocalBuildInfo -> Verbosity -> IO () -- | Generate and write out the Paths_pkg.hs and cabal_macros.h -- files writeAutogenFiles :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO () -- | This module deals with the haddock and hscolour -- commands. Sadly this is a rather complicated module. It deals with two -- versions of haddock (0.x and 2.x). It has to do pre-processing for -- haddock 0.x which involves 'unlit'ing and using -DHADDOCK for -- any source code that uses cpp. It uses information about -- installed packages (from ghc-pkg) to find the locations of -- documentation for dependent packages, so it can create links. -- -- The hscolour support allows generating html versions of the -- original source, with coloured syntax highlighting. module Distribution.Simple.Haddock haddock :: PackageDescription -> LocalBuildInfo -> [PPSuffixHandler] -> HaddockFlags -> IO () hscolour :: PackageDescription -> LocalBuildInfo -> [PPSuffixHandler] -> HscolourFlags -> IO () instance Read Directory instance Show Directory instance Eq Directory instance Ord Directory instance Monoid Directory instance Monoid HaddockArgs -- | This is the command line front end to the Simple build system. When -- given the parsed command-line args and package information, is able to -- perform basic commands like configure, build, install, register, etc. -- -- This module exports the main functions that Setup.hs scripts use. It -- re-exports the UserHooks type, the standard entry points like -- defaultMain and defaultMainWithHooks and the predefined -- sets of UserHooks that custom Setup.hs scripts can -- extend to add their own behaviour. -- -- This module isn't called "Simple" because it's simple. Far from it. -- It's called "Simple" because it does complicated things to simple -- software. -- -- The original idea was that there could be different build systems that -- all presented the same compatible command line interfaces. There is -- still a Distribution.Make system but in practice no packages -- use it. module Distribution.Simple -- | A simple implementation of main for a Cabal setup script. It -- reads the package description file using IO, and performs the action -- specified on the command line. defaultMain :: IO () -- | Like defaultMain, but accepts the package description as input -- rather than using IO to read it. defaultMainNoRead :: GenericPackageDescription -> IO () -- | A version of defaultMain that is passed the command line -- arguments, rather than getting them from the environment. defaultMainArgs :: [String] -> IO () -- | Hooks allow authors to add specific functionality before and after a -- command is run, and also to specify additional preprocessors. -- --