module Distribution.Simple (
module Distribution.Package,
module Distribution.Version,
module Distribution.License,
module Distribution.Simple.Compiler,
module Language.Haskell.Extension,
defaultMain, defaultMainNoRead, defaultMainArgs,
UserHooks(..), Args,
defaultMainWithHooks, defaultMainWithHooksArgs,
simpleUserHooks,
autoconfUserHooks,
defaultUserHooks, emptyUserHooks,
defaultHookedPackageDesc
) where
import Distribution.Simple.Compiler hiding (Flag)
import Distribution.Simple.UserHooks
import Distribution.Package
import Distribution.PackageDescription
( PackageDescription(..), GenericPackageDescription, Executable(..)
, updatePackageDescription, hasLibs
, HookedBuildInfo, emptyHookedBuildInfo )
import Distribution.PackageDescription.Parse
( readPackageDescription, readHookedBuildInfo )
import Distribution.PackageDescription.Configuration
( flattenPackageDescription )
import Distribution.Simple.Program
( defaultProgramConfiguration, addKnownPrograms, builtinPrograms
, restoreProgramConfiguration, reconfigurePrograms )
import Distribution.Simple.PreProcess (knownSuffixHandlers, PPSuffixHandler)
import Distribution.Simple.Setup
import Distribution.Simple.Command
import Distribution.Simple.Build ( build )
import Distribution.Simple.SrcDist ( sdist )
import Distribution.Simple.Register
( register, unregister )
import Distribution.Simple.Configure
( getPersistBuildConfig, maybeGetPersistBuildConfig
, writePersistBuildConfig, checkPersistBuildConfigOutdated
, configure, checkForeignDeps )
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )
import Distribution.Simple.BuildPaths ( srcPref)
import Distribution.Simple.Test (test)
import Distribution.Simple.Install (install)
import Distribution.Simple.Haddock (haddock, hscolour)
import Distribution.Simple.Utils
(die, notice, info, warn, setupMessage, chattyTry,
defaultPackageDesc, defaultHookedPackageDesc,
rawSystemExitWithEnv, cabalVersion, topHandler )
import Distribution.System
( OS(..), buildOS )
import Distribution.Verbosity
import Language.Haskell.Extension
import Distribution.Version
import Distribution.License
import Distribution.Text
( display )
import System.Environment(getArgs, getProgName, getEnvironment)
import System.Directory(removeFile, doesFileExist,
doesDirectoryExist, removeDirectoryRecursive)
import System.Exit
import System.IO.Error (isDoesNotExistError)
import Distribution.Compat.Exception (catchIO, throwIOIO)
import Control.Monad (when)
import Data.List (intersperse, unionBy, nub, (\\))
defaultMain :: IO ()
defaultMain = getArgs :: IO [String]getArgs (>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b>>= defaultMainHelper :: UserHooks -> Args -> IO ()defaultMainHelper simpleUserHooks :: UserHookssimpleUserHooks
defaultMainArgs :: [String] -> IO ()
defaultMainArgs = defaultMainHelper :: UserHooks -> Args -> IO ()defaultMainHelper simpleUserHooks :: UserHookssimpleUserHooks
defaultMainWithHooks :: UserHooks -> IO ()
defaultMainWithHooks hooks = getArgs :: IO [String]getArgs (>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b>>= defaultMainHelper :: UserHooks -> Args -> IO ()defaultMainHelper hooks :: UserHookshooks
defaultMainWithHooksArgs :: UserHooks -> [String] -> IO ()
defaultMainWithHooksArgs = defaultMainHelper :: UserHooks -> Args -> IO ()defaultMainHelper
defaultMainNoRead :: GenericPackageDescription -> IO ()
defaultMainNoRead pkg_descr =
getArgs :: IO [String]getArgs (>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b>>=
defaultMainHelper :: UserHooks -> Args -> IO ()defaultMainHelper simpleUserHooks :: UserHookssimpleUserHooks { readDesc = return :: Monad m => forall a. a -> m areturn (Just :: a -> Maybe aJust pkg_descr :: GenericPackageDescriptionpkg_descr) }
defaultMainHelper :: UserHooks -> Args -> IO ()
defaultMainHelper hooks args = topHandler :: IO a -> IO atopHandler ($) :: (a -> b) -> a -> b$
case commandsRun ::
CommandUI a
-> [Command action]
-> [String]
-> CommandParse (a, CommandParse action)commandsRun globalCommand :: CommandUI GlobalFlagsglobalCommand commands :: [Command (IO ())]commands args :: Argsargs of
CommandHelp help -> printHelp :: (String -> String) -> IO ()printHelp help :: String -> Stringhelp
CommandList opts -> printOptionsList :: [String] -> IO ()printOptionsList opts :: [String]opts
CommandErrors errs -> printErrors :: [[Char]] -> IO bprintErrors errs :: [[Char]]errs
CommandReadyToGo (flags, commandParse) ->
case commandParse :: CommandParse (IO ())commandParse of
_ | fromFlag :: Flag a -> afromFlag (globalVersion :: GlobalFlags -> Flag BoolglobalVersion flags :: GlobalFlagsflags) -> printVersion :: IO ()printVersion
| fromFlag :: Flag a -> afromFlag (globalNumericVersion :: GlobalFlags -> Flag BoolglobalNumericVersion flags :: GlobalFlagsflags) -> printNumericVersion :: IO ()printNumericVersion
CommandHelp help -> printHelp :: (String -> String) -> IO ()printHelp help :: String -> Stringhelp
CommandList opts -> printOptionsList :: [String] -> IO ()printOptionsList opts :: [String]opts
CommandErrors errs -> printErrors :: [[Char]] -> IO bprintErrors errs :: [[Char]]errs
CommandReadyToGo action -> action :: IO ()action
where
printHelp help = getProgName :: IO StringgetProgName (>>=) :: Monad m => forall a b. m a -> (a -> m b) -> m b>>= putStr :: String -> IO ()putStr (.) :: (b -> c) -> (a -> b) -> a -> c. help :: String -> Stringhelp
printOptionsList = putStr :: String -> IO ()putStr (.) :: (b -> c) -> (a -> b) -> a -> c. unlines :: [String] -> Stringunlines
printErrors errs = do
putStr :: String -> IO ()putStr (concat :: [[a]] -> [a]concat (intersperse :: a -> [a] -> [a]intersperse "\n" errs :: [[Char]]errs))
exitWith :: ExitCode -> IO aexitWith (ExitFailure :: Int -> ExitCodeExitFailure 1)
printNumericVersion = putStrLn :: String -> IO ()putStrLn ($) :: (a -> b) -> a -> b$ display :: Text a => a -> Stringdisplay cabalVersion :: VersioncabalVersion
printVersion = putStrLn :: String -> IO ()putStrLn ($) :: (a -> b) -> a -> b$ "Cabal library version "
(++) :: [a] -> [a] -> [a]++ display :: Text a => a -> Stringdisplay cabalVersion :: VersioncabalVersion
progs = addKnownPrograms :: [Program] -> ProgramDb -> ProgramDbaddKnownPrograms (hookedPrograms :: UserHooks -> [Program]hookedPrograms hooks :: UserHookshooks) defaultProgramConfiguration :: ProgramConfigurationdefaultProgramConfiguration
commands =
[configureCommand :: ProgramConfiguration -> CommandUI ConfigFlagsconfigureCommand progs :: ProgramDbprogs commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` \fs as ->
configureAction ::
UserHooks -> ConfigFlags -> Args -> IO LocalBuildInfoconfigureAction hooks :: UserHookshooks fs :: ConfigFlagsfs as :: [String]as (>>) :: Monad m => forall a b. m a -> m b -> m b>> return :: Monad m => forall a. a -> m areturn ()
,buildCommand :: ProgramConfiguration -> CommandUI BuildFlagsbuildCommand progs :: ProgramDbprogs commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` buildAction :: UserHooks -> BuildFlags -> Args -> IO ()buildAction hooks :: UserHookshooks
,installCommand :: CommandUI InstallFlagsinstallCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` installAction :: UserHooks -> InstallFlags -> Args -> IO ()installAction hooks :: UserHookshooks
,copyCommand :: CommandUI CopyFlagscopyCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` copyAction :: UserHooks -> CopyFlags -> Args -> IO ()copyAction hooks :: UserHookshooks
,haddockCommand :: CommandUI HaddockFlagshaddockCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` haddockAction :: UserHooks -> HaddockFlags -> Args -> IO ()haddockAction hooks :: UserHookshooks
,cleanCommand :: CommandUI CleanFlagscleanCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` cleanAction :: UserHooks -> CleanFlags -> Args -> IO ()cleanAction hooks :: UserHookshooks
,sdistCommand :: CommandUI SDistFlagssdistCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` sdistAction :: UserHooks -> SDistFlags -> Args -> IO ()sdistAction hooks :: UserHookshooks
,hscolourCommand :: CommandUI HscolourFlagshscolourCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` hscolourAction :: UserHooks -> HscolourFlags -> Args -> IO ()hscolourAction hooks :: UserHookshooks
,registerCommand :: CommandUI RegisterFlagsregisterCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` registerAction :: UserHooks -> RegisterFlags -> Args -> IO ()registerAction hooks :: UserHookshooks
,unregisterCommand :: CommandUI RegisterFlagsunregisterCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` unregisterAction :: UserHooks -> RegisterFlags -> Args -> IO ()unregisterAction hooks :: UserHookshooks
,testCommand :: CommandUI TestFlagstestCommand commandAddAction ::
CommandUI flags -> (flags -> [String] -> action) -> Command action`commandAddAction` testAction :: UserHooks -> TestFlags -> Args -> IO ()testAction hooks :: UserHookshooks
]
allSuffixHandlers :: UserHooks
-> [PPSuffixHandler]
allSuffixHandlers hooks
= overridesPP ::
[PPSuffixHandler] -> [PPSuffixHandler] -> [PPSuffixHandler]overridesPP (hookedPreProcessors :: UserHooks -> [PPSuffixHandler]hookedPreProcessors hooks :: UserHookshooks) knownSuffixHandlers :: [PPSuffixHandler]knownSuffixHandlers
where
overridesPP :: [PPSuffixHandler] -> [PPSuffixHandler] -> [PPSuffixHandler]
overridesPP = unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]unionBy (\x y -> fst :: (a, b) -> afst x :: PPSuffixHandlerx (==) :: Eq a => a -> a -> Bool== fst :: (a, b) -> afst y :: PPSuffixHandlery)
configureAction :: UserHooks -> ConfigFlags -> Args -> IO LocalBuildInfo
configureAction hooks flags args = do
let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ configDistPref :: ConfigFlags -> Flag FilePathconfigDistPref flags :: GlobalFlagsflags
pbi <- preConf :: UserHooks -> Args -> ConfigFlags -> IO HookedBuildInfopreConf hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags
(mb_pd_file, pkg_descr0) <- confPkgDescr :: IO (Maybe FilePath, GenericPackageDescription)confPkgDescr
let epkg_descr = (pkg_descr0 :: GenericPackageDescriptionpkg_descr0, pbi :: HookedBuildInfopbi)
localbuildinfo0 <- confHook ::
UserHooks
-> (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfoconfHook hooks :: UserHookshooks epkg_descr :: (GenericPackageDescription, HookedBuildInfo)epkg_descr flags :: GlobalFlagsflags
let localbuildinfo = localbuildinfo0 :: LocalBuildInfolocalbuildinfo0 {
pkgDescrFile = mb_pd_file :: Maybe FilePathmb_pd_file,
extraConfigArgs = args :: Argsargs
}
writePersistBuildConfig :: FilePath -> LocalBuildInfo -> IO ()writePersistBuildConfig distPref :: FilePathdistPref localbuildinfo :: LocalBuildInfolocalbuildinfo
let pkg_descr = localPkgDescr :: LocalBuildInfo -> PackageDescriptionlocalPkgDescr localbuildinfo :: LocalBuildInfolocalbuildinfo
postConf ::
UserHooks
-> Args
-> ConfigFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postConf hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo
return :: Monad m => forall a. a -> m areturn localbuildinfo :: LocalBuildInfolocalbuildinfo
where
verbosity = fromFlag :: Flag a -> afromFlag (configVerbosity :: ConfigFlags -> Flag VerbosityconfigVerbosity flags :: GlobalFlagsflags)
confPkgDescr :: IO (Maybe FilePath, GenericPackageDescription)
confPkgDescr = do
mdescr <- readDesc :: UserHooks -> IO (Maybe GenericPackageDescription)readDesc hooks :: UserHookshooks
case mdescr :: Maybe GenericPackageDescriptionmdescr of
Just descr -> return :: Monad m => forall a. a -> m areturn (Nothing :: Maybe aNothing, descr :: GenericPackageDescriptiondescr)
Nothing -> do
pdfile <- defaultPackageDesc :: Verbosity -> IO FilePathdefaultPackageDesc verbosity :: Verbosityverbosity
descr <- readPackageDescription ::
Verbosity -> FilePath -> IO GenericPackageDescriptionreadPackageDescription verbosity :: Verbosityverbosity pdfile :: FilePathpdfile
return :: Monad m => forall a. a -> m areturn (Just :: a -> Maybe aJust pdfile :: FilePathpdfile, descr :: GenericPackageDescriptiondescr)
buildAction :: UserHooks -> BuildFlags -> Args -> IO ()
buildAction hooks flags args = do
let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ buildDistPref :: BuildFlags -> Flag FilePathbuildDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ buildVerbosity :: BuildFlags -> Flag VerbositybuildVerbosity flags :: GlobalFlagsflags
lbi <- getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref
progs <- reconfigurePrograms ::
Verbosity
-> [(String, FilePath)]
-> [(String, [ProgArg])]
-> ProgramDb
-> IO ProgramDbreconfigurePrograms verbosity :: Verbosityverbosity
(buildProgramPaths :: BuildFlags -> [(String, FilePath)]buildProgramPaths flags :: GlobalFlagsflags)
(buildProgramArgs :: BuildFlags -> [(String, [String])]buildProgramArgs flags :: GlobalFlagsflags)
(withPrograms :: LocalBuildInfo -> ProgramConfigurationwithPrograms lbi :: LocalBuildInfolbi)
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preBuild :: UserHooks -> Args -> BuildFlags -> IO HookedBuildInfopreBuild buildHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> BuildFlags
-> IO ()buildHook postBuild ::
UserHooks
-> Args
-> BuildFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postBuild
(return :: Monad m => forall a. a -> m areturn lbi :: LocalBuildInfolbi { withPrograms = progs :: ProgramDbprogs })
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
hscolourAction :: UserHooks -> HscolourFlags -> Args -> IO ()
hscolourAction hooks flags args
= do let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ hscolourDistPref :: HscolourFlags -> Flag FilePathhscolourDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ hscolourVerbosity :: HscolourFlags -> Flag VerbosityhscolourVerbosity flags :: GlobalFlagsflags
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preHscolour ::
UserHooks -> Args -> HscolourFlags -> IO HookedBuildInfopreHscolour hscolourHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> HscolourFlags
-> IO ()hscolourHook postHscolour ::
UserHooks
-> Args
-> HscolourFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postHscolour
(getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref)
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
haddockAction :: UserHooks -> HaddockFlags -> Args -> IO ()
haddockAction hooks flags args = do
let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ haddockDistPref :: HaddockFlags -> Flag FilePathhaddockDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ haddockVerbosity :: HaddockFlags -> Flag VerbosityhaddockVerbosity flags :: GlobalFlagsflags
lbi <- getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref
progs <- reconfigurePrograms ::
Verbosity
-> [(String, FilePath)]
-> [(String, [ProgArg])]
-> ProgramDb
-> IO ProgramDbreconfigurePrograms verbosity :: Verbosityverbosity
(haddockProgramPaths :: HaddockFlags -> [(String, FilePath)]haddockProgramPaths flags :: GlobalFlagsflags)
(haddockProgramArgs :: HaddockFlags -> [(String, [String])]haddockProgramArgs flags :: GlobalFlagsflags)
(withPrograms :: LocalBuildInfo -> ProgramConfigurationwithPrograms lbi :: LocalBuildInfolbi)
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preHaddock ::
UserHooks -> Args -> HaddockFlags -> IO HookedBuildInfopreHaddock haddockHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> HaddockFlags
-> IO ()haddockHook postHaddock ::
UserHooks
-> Args
-> HaddockFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postHaddock
(return :: Monad m => forall a. a -> m areturn lbi :: LocalBuildInfolbi { withPrograms = progs :: ProgramDbprogs })
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
cleanAction :: UserHooks -> CleanFlags -> Args -> IO ()
cleanAction hooks flags args = do
pbi <- preClean :: UserHooks -> Args -> CleanFlags -> IO HookedBuildInfopreClean hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags
pdfile <- defaultPackageDesc :: Verbosity -> IO FilePathdefaultPackageDesc verbosity :: Verbosityverbosity
ppd <- readPackageDescription ::
Verbosity -> FilePath -> IO GenericPackageDescriptionreadPackageDescription verbosity :: Verbosityverbosity pdfile :: FilePathpdfile
let pkg_descr0 = flattenPackageDescription ::
GenericPackageDescription -> PackageDescriptionflattenPackageDescription ppd :: GenericPackageDescriptionppd
let pkg_descr = updatePackageDescription ::
HookedBuildInfo -> PackageDescription -> PackageDescriptionupdatePackageDescription pbi :: HookedBuildInfopbi pkg_descr0 :: GenericPackageDescriptionpkg_descr0
cleanHook ::
UserHooks
-> PackageDescription
-> ()
-> UserHooks
-> CleanFlags
-> IO ()cleanHook hooks :: UserHookshooks pkg_descr :: GenericPackageDescriptionpkg_descr () hooks :: UserHookshooks flags :: GlobalFlagsflags
postClean ::
UserHooks
-> Args
-> CleanFlags
-> PackageDescription
-> ()
-> IO ()postClean hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags pkg_descr :: GenericPackageDescriptionpkg_descr ()
where verbosity = fromFlag :: Flag a -> afromFlag (cleanVerbosity :: CleanFlags -> Flag VerbositycleanVerbosity flags :: GlobalFlagsflags)
copyAction :: UserHooks -> CopyFlags -> Args -> IO ()
copyAction hooks flags args
= do let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ copyDistPref :: CopyFlags -> Flag FilePathcopyDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ copyVerbosity :: CopyFlags -> Flag VerbositycopyVerbosity flags :: GlobalFlagsflags
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preCopy :: UserHooks -> Args -> CopyFlags -> IO HookedBuildInfopreCopy copyHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> CopyFlags
-> IO ()copyHook postCopy ::
UserHooks
-> Args
-> CopyFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postCopy
(getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref)
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
installAction :: UserHooks -> InstallFlags -> Args -> IO ()
installAction hooks flags args
= do let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ installDistPref :: InstallFlags -> Flag FilePathinstallDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ installVerbosity :: InstallFlags -> Flag VerbosityinstallVerbosity flags :: GlobalFlagsflags
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preInst :: UserHooks -> Args -> InstallFlags -> IO HookedBuildInfopreInst instHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> InstallFlags
-> IO ()instHook postInst ::
UserHooks
-> Args
-> InstallFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postInst
(getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref)
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
sdistAction :: UserHooks -> SDistFlags -> Args -> IO ()
sdistAction hooks flags args = do
let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ sDistDistPref :: SDistFlags -> Flag FilePathsDistDistPref flags :: GlobalFlagsflags
pbi <- preSDist :: UserHooks -> Args -> SDistFlags -> IO HookedBuildInfopreSDist hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags
mlbi <- maybeGetPersistBuildConfig :: FilePath -> IO (Maybe LocalBuildInfo)maybeGetPersistBuildConfig distPref :: FilePathdistPref
pdfile <- defaultPackageDesc :: Verbosity -> IO FilePathdefaultPackageDesc verbosity :: Verbosityverbosity
ppd <- readPackageDescription ::
Verbosity -> FilePath -> IO GenericPackageDescriptionreadPackageDescription verbosity :: Verbosityverbosity pdfile :: FilePathpdfile
let pkg_descr0 = flattenPackageDescription ::
GenericPackageDescription -> PackageDescriptionflattenPackageDescription ppd :: GenericPackageDescriptionppd
sanityCheckHookedBuildInfo ::
PackageDescription -> HookedBuildInfo -> IO ()sanityCheckHookedBuildInfo pkg_descr0 :: GenericPackageDescriptionpkg_descr0 pbi :: HookedBuildInfopbi
let pkg_descr = updatePackageDescription ::
HookedBuildInfo -> PackageDescription -> PackageDescriptionupdatePackageDescription pbi :: HookedBuildInfopbi pkg_descr0 :: GenericPackageDescriptionpkg_descr0
sDistHook ::
UserHooks
-> PackageDescription
-> Maybe LocalBuildInfo
-> UserHooks
-> SDistFlags
-> IO ()sDistHook hooks :: UserHookshooks pkg_descr :: GenericPackageDescriptionpkg_descr mlbi :: Maybe LocalBuildInfomlbi hooks :: UserHookshooks flags :: GlobalFlagsflags
postSDist ::
UserHooks
-> Args
-> SDistFlags
-> PackageDescription
-> Maybe LocalBuildInfo
-> IO ()postSDist hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags pkg_descr :: GenericPackageDescriptionpkg_descr mlbi :: Maybe LocalBuildInfomlbi
where verbosity = fromFlag :: Flag a -> afromFlag (sDistVerbosity :: SDistFlags -> Flag VerbositysDistVerbosity flags :: GlobalFlagsflags)
testAction :: UserHooks -> TestFlags -> Args -> IO ()
testAction hooks flags args = do
let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ testDistPref :: TestFlags -> Flag FilePathtestDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ testVerbosity :: TestFlags -> Flag VerbositytestVerbosity flags :: GlobalFlagsflags
localBuildInfo <- getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref
let pkg_descr = localPkgDescr :: LocalBuildInfo -> PackageDescriptionlocalPkgDescr localBuildInfo :: LocalBuildInfolocalBuildInfo
runTests ::
UserHooks
-> Args
-> Bool
-> PackageDescription
-> LocalBuildInfo
-> IO ()runTests hooks :: UserHookshooks args :: Argsargs False :: BoolFalse pkg_descr :: GenericPackageDescriptionpkg_descr localBuildInfo :: LocalBuildInfolocalBuildInfo
let flags' = flags :: GlobalFlagsflags { testList = Flag :: a -> Flag aFlag args :: Argsargs }
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preTest :: UserHooks -> Args -> TestFlags -> IO HookedBuildInfopreTest testHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> TestFlags
-> IO ()testHook postTest ::
UserHooks
-> Args
-> TestFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postTest
(getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref)
hooks :: UserHookshooks flags' :: TestFlagsflags' args :: Argsargs
registerAction :: UserHooks -> RegisterFlags -> Args -> IO ()
registerAction hooks flags args
= do let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ regDistPref :: RegisterFlags -> Flag FilePathregDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ regVerbosity :: RegisterFlags -> Flag VerbosityregVerbosity flags :: GlobalFlagsflags
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preReg :: UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfopreReg regHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> RegisterFlags
-> IO ()regHook postReg ::
UserHooks
-> Args
-> RegisterFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postReg
(getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref)
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
unregisterAction :: UserHooks -> RegisterFlags -> Args -> IO ()
unregisterAction hooks flags args
= do let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ regDistPref :: RegisterFlags -> Flag FilePathregDistPref flags :: GlobalFlagsflags
verbosity = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ regVerbosity :: RegisterFlags -> Flag VerbosityregVerbosity flags :: GlobalFlagsflags
hookedAction ::
(UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ())
-> (UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ())
-> IO LocalBuildInfo
-> UserHooks
-> flags
-> Args
-> IO ()hookedAction preUnreg ::
UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfopreUnreg unregHook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> RegisterFlags
-> IO ()unregHook postUnreg ::
UserHooks
-> Args
-> RegisterFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postUnreg
(getBuildConfig ::
UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfogetBuildConfig hooks :: UserHookshooks verbosity :: Verbosityverbosity distPref :: FilePathdistPref)
hooks :: UserHookshooks flags :: GlobalFlagsflags args :: Argsargs
hookedAction :: (UserHooks -> Args -> flags -> IO HookedBuildInfo)
-> (UserHooks -> PackageDescription -> LocalBuildInfo
-> UserHooks -> flags -> IO ())
-> (UserHooks -> Args -> flags -> PackageDescription
-> LocalBuildInfo -> IO ())
-> IO LocalBuildInfo
-> UserHooks -> flags -> Args -> IO ()
hookedAction pre_hook cmd_hook post_hook get_build_config hooks flags args = do
pbi <- pre_hook :: UserHooks -> Args -> flags -> IO HookedBuildInfopre_hook hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags
localbuildinfo <- get_build_config :: IO LocalBuildInfoget_build_config
let pkg_descr0 = localPkgDescr :: LocalBuildInfo -> PackageDescriptionlocalPkgDescr localbuildinfo :: LocalBuildInfolocalbuildinfo
sanityCheckHookedBuildInfo ::
PackageDescription -> HookedBuildInfo -> IO ()sanityCheckHookedBuildInfo pkg_descr0 :: GenericPackageDescriptionpkg_descr0 pbi :: HookedBuildInfopbi
let pkg_descr = updatePackageDescription ::
HookedBuildInfo -> PackageDescription -> PackageDescriptionupdatePackageDescription pbi :: HookedBuildInfopbi pkg_descr0 :: GenericPackageDescriptionpkg_descr0
cmd_hook ::
UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> flags
-> IO ()cmd_hook hooks :: UserHookshooks pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo hooks :: UserHookshooks flags :: GlobalFlagsflags
post_hook ::
UserHooks
-> Args
-> flags
-> PackageDescription
-> LocalBuildInfo
-> IO ()post_hook hooks :: UserHookshooks args :: Argsargs flags :: GlobalFlagsflags pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo
where
sanityCheckHookedBuildInfo :: PackageDescription -> HookedBuildInfo -> IO ()
sanityCheckHookedBuildInfo PackageDescription { library = Nothing } (Just _,_)
= die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "The buildinfo contains info for a library, "
(++) :: [a] -> [a] -> [a]++ "but the package does not have a library."
sanityCheckHookedBuildInfo pkg_descr (_, hookExes)
| not :: Bool -> Boolnot (null :: [a] -> Boolnull nonExistant :: [String]nonExistant)
= die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "The buildinfo contains info for an executable called '"
(++) :: [a] -> [a] -> [a]++ head :: [a] -> ahead nonExistant :: [String]nonExistant (++) :: [a] -> [a] -> [a]++ "' but the package does not have a "
(++) :: [a] -> [a] -> [a]++ "executable with that name."
where
pkgExeNames = nub :: Eq a => [a] -> [a]nub (map :: (a -> b) -> [a] -> [b]map exeName :: Executable -> StringexeName (executables :: PackageDescription -> [Executable]executables pkg_descr :: GenericPackageDescriptionpkg_descr))
hookExeNames = nub :: Eq a => [a] -> [a]nub (map :: (a -> b) -> [a] -> [b]map fst :: (a, b) -> afst hookExes :: [(String, BuildInfo)]hookExes)
nonExistant = hookExeNames :: [String]hookExeNames (\\) :: Eq a => [a] -> [a] -> [a]\\ pkgExeNames :: [String]pkgExeNames
sanityCheckHookedBuildInfo _ _ = return :: Monad m => forall a. a -> m areturn ()
getBuildConfig :: UserHooks -> Verbosity -> FilePath -> IO LocalBuildInfo
getBuildConfig hooks verbosity distPref = do
lbi_wo_programs <- getPersistBuildConfig :: FilePath -> IO LocalBuildInfogetPersistBuildConfig distPref :: FilePathdistPref
let lbi = lbi_wo_programs :: LocalBuildInfolbi_wo_programs {
withPrograms = restoreProgramConfiguration ::
[Program] -> ProgramConfiguration -> ProgramConfigurationrestoreProgramConfiguration
(builtinPrograms :: [Program]builtinPrograms (++) :: [a] -> [a] -> [a]++ hookedPrograms :: UserHooks -> [Program]hookedPrograms hooks :: UserHookshooks)
(withPrograms :: LocalBuildInfo -> ProgramConfigurationwithPrograms lbi_wo_programs :: LocalBuildInfolbi_wo_programs)
}
case pkgDescrFile :: LocalBuildInfo -> Maybe FilePathpkgDescrFile lbi :: LocalBuildInfolbi of
Nothing -> return :: Monad m => forall a. a -> m areturn lbi :: LocalBuildInfolbi
Just pkg_descr_file -> do
outdated <- checkPersistBuildConfigOutdated :: FilePath -> FilePath -> IO BoolcheckPersistBuildConfigOutdated distPref :: FilePathdistPref pkg_descr_file :: FilePathpkg_descr_file
if outdated :: Booloutdated
then reconfigure :: FilePath -> LocalBuildInfo -> IO LocalBuildInforeconfigure pkg_descr_file :: FilePathpkg_descr_file lbi :: LocalBuildInfolbi
else return :: Monad m => forall a. a -> m areturn lbi :: LocalBuildInfolbi
where
reconfigure :: FilePath -> LocalBuildInfo -> IO LocalBuildInfo
reconfigure pkg_descr_file lbi = do
notice :: Verbosity -> String -> IO ()notice verbosity :: Verbosityverbosity ($) :: (a -> b) -> a -> b$ pkg_descr_file :: FilePathpkg_descr_file (++) :: [a] -> [a] -> [a]++ " has been changed. "
(++) :: [a] -> [a] -> [a]++ "Re-configuring with most recently used options. "
(++) :: [a] -> [a] -> [a]++ "If this fails, please run configure manually.\n"
let cFlags = configFlags :: LocalBuildInfo -> ConfigFlagsconfigFlags lbi :: LocalBuildInfolbi
let cFlags' = cFlags :: ConfigFlagscFlags {
configPrograms = restoreProgramConfiguration ::
[Program] -> ProgramConfiguration -> ProgramConfigurationrestoreProgramConfiguration
(builtinPrograms :: [Program]builtinPrograms (++) :: [a] -> [a] -> [a]++ hookedPrograms :: UserHooks -> [Program]hookedPrograms hooks :: UserHookshooks)
(configPrograms :: ConfigFlags -> ProgramConfigurationconfigPrograms cFlags :: ConfigFlagscFlags),
configVerbosity = Flag :: a -> Flag aFlag verbosity :: Verbosityverbosity
}
configureAction ::
UserHooks -> ConfigFlags -> Args -> IO LocalBuildInfoconfigureAction hooks :: UserHookshooks cFlags' :: ConfigFlagscFlags' (extraConfigArgs :: LocalBuildInfo -> [String]extraConfigArgs lbi :: LocalBuildInfolbi)
clean :: PackageDescription -> CleanFlags -> IO ()
clean pkg_descr flags = do
let distPref = fromFlag :: Flag a -> afromFlag ($) :: (a -> b) -> a -> b$ cleanDistPref :: CleanFlags -> Flag FilePathcleanDistPref flags :: GlobalFlagsflags
notice :: Verbosity -> String -> IO ()notice verbosity :: Verbosityverbosity "cleaning..."
maybeConfig <- if fromFlag :: Flag a -> afromFlag (cleanSaveConf :: CleanFlags -> Flag BoolcleanSaveConf flags :: GlobalFlagsflags)
then maybeGetPersistBuildConfig :: FilePath -> IO (Maybe LocalBuildInfo)maybeGetPersistBuildConfig distPref :: FilePathdistPref
else return :: Monad m => forall a. a -> m areturn Nothing :: Maybe aNothing
chattyTry :: String -> IO () -> IO ()chattyTry "removing dist/" ($) :: (a -> b) -> a -> b$ do
exists <- doesDirectoryExist :: FilePath -> IO BooldoesDirectoryExist distPref :: FilePathdistPref
when :: Monad m => Bool -> m () -> m ()when exists :: Boolexists (removeDirectoryRecursive :: FilePath -> IO ()removeDirectoryRecursive distPref :: FilePathdistPref)
mapM_ :: Monad m => (a -> m b) -> [a] -> m ()mapM_ removeFileOrDirectory :: FilePath -> IO ()removeFileOrDirectory (extraTmpFiles :: PackageDescription -> [FilePath]extraTmpFiles pkg_descr :: GenericPackageDescriptionpkg_descr)
maybe :: b -> (a -> b) -> Maybe a -> bmaybe (return :: Monad m => forall a. a -> m areturn ()) (writePersistBuildConfig :: FilePath -> LocalBuildInfo -> IO ()writePersistBuildConfig distPref :: FilePathdistPref) maybeConfig :: Maybe LocalBuildInfomaybeConfig
where
removeFileOrDirectory :: FilePath -> IO ()
removeFileOrDirectory fname = do
isDir <- doesDirectoryExist :: FilePath -> IO BooldoesDirectoryExist fname :: FilePathfname
isFile <- doesFileExist :: FilePath -> IO BooldoesFileExist fname :: FilePathfname
if isDir :: BoolisDir then removeDirectoryRecursive :: FilePath -> IO ()removeDirectoryRecursive fname :: FilePathfname
else if isFile :: BoolisFile then removeFile :: FilePath -> IO ()removeFile fname :: FilePathfname
else return :: Monad m => forall a. a -> m areturn ()
verbosity = fromFlag :: Flag a -> afromFlag (cleanVerbosity :: CleanFlags -> Flag VerbositycleanVerbosity flags :: GlobalFlagsflags)
simpleUserHooks :: UserHooks
simpleUserHooks =
emptyUserHooks :: UserHooksemptyUserHooks {
confHook = configure ::
(GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfoconfigure,
postConf = finalChecks ::
t -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()finalChecks,
buildHook = defaultBuildHook ::
PackageDescription
-> LocalBuildInfo
-> UserHooks
-> BuildFlags
-> IO ()defaultBuildHook,
copyHook = \desc lbi _ f -> install ::
PackageDescription -> LocalBuildInfo -> CopyFlags -> IO ()install desc :: PackageDescriptiondesc lbi :: LocalBuildInfolbi f :: RegisterFlagsf,
testHook = defaultTestHook ::
PackageDescription
-> LocalBuildInfo
-> UserHooks
-> TestFlags
-> IO ()defaultTestHook,
instHook = defaultInstallHook ::
PackageDescription
-> LocalBuildInfo
-> UserHooks
-> InstallFlags
-> IO ()defaultInstallHook,
sDistHook = \p l h f -> sdist ::
PackageDescription
-> Maybe LocalBuildInfo
-> SDistFlags
-> (FilePath -> FilePath)
-> [PPSuffixHandler]
-> IO ()sdist p :: PackageDescriptionp l :: LocalBuildInfol f :: RegisterFlagsf srcPref :: FilePath -> FilePathsrcPref (allSuffixHandlers :: UserHooks -> [PPSuffixHandler]allSuffixHandlers h :: UserHooksh),
cleanHook = \p _ _ f -> clean :: PackageDescription -> CleanFlags -> IO ()clean p :: PackageDescriptionp f :: RegisterFlagsf,
hscolourHook = \p l h f -> hscolour ::
PackageDescription
-> LocalBuildInfo
-> [PPSuffixHandler]
-> HscolourFlags
-> IO ()hscolour p :: PackageDescriptionp l :: LocalBuildInfol (allSuffixHandlers :: UserHooks -> [PPSuffixHandler]allSuffixHandlers h :: UserHooksh) f :: RegisterFlagsf,
haddockHook = \p l h f -> haddock ::
PackageDescription
-> LocalBuildInfo
-> [PPSuffixHandler]
-> HaddockFlags
-> IO ()haddock p :: PackageDescriptionp l :: LocalBuildInfol (allSuffixHandlers :: UserHooks -> [PPSuffixHandler]allSuffixHandlers h :: UserHooksh) f :: RegisterFlagsf,
regHook = defaultRegHook ::
PackageDescription
-> LocalBuildInfo
-> UserHooks
-> RegisterFlags
-> IO ()defaultRegHook,
unregHook = \p l _ f -> unregister ::
PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO ()unregister p :: PackageDescriptionp l :: LocalBuildInfol f :: RegisterFlagsf
}
where
finalChecks _args flags pkg_descr lbi =
checkForeignDeps ::
PackageDescription -> LocalBuildInfo -> Verbosity -> IO ()checkForeignDeps pkg_descr :: GenericPackageDescriptionpkg_descr lbi :: LocalBuildInfolbi (lessVerbose :: Verbosity -> VerbositylessVerbose verbosity :: Verbosityverbosity)
where
verbosity = fromFlag :: Flag a -> afromFlag (configVerbosity :: ConfigFlags -> Flag VerbosityconfigVerbosity flags :: GlobalFlagsflags)
defaultUserHooks :: UserHooks
defaultUserHooks = autoconfUserHooks :: UserHooksautoconfUserHooks {
confHook = \pkg flags -> do
let verbosity = fromFlag :: Flag a -> afromFlag (configVerbosity :: ConfigFlags -> Flag VerbosityconfigVerbosity flags :: GlobalFlagsflags)
warn :: Verbosity -> String -> IO ()warn verbosity :: Verbosityverbosity ($) :: (a -> b) -> a -> b$
"defaultUserHooks in Setup script is deprecated."
confHook ::
UserHooks
-> (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfoconfHook autoconfUserHooks :: UserHooksautoconfUserHooks pkg :: (GenericPackageDescription, HookedBuildInfo)pkg flags :: GlobalFlagsflags,
postConf = oldCompatPostConf ::
[String]
-> ConfigFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()oldCompatPostConf
}
where oldCompatPostConf args flags pkg_descr lbi
= do let verbosity = fromFlag :: Flag a -> afromFlag (configVerbosity :: ConfigFlags -> Flag VerbosityconfigVerbosity flags :: GlobalFlagsflags)
noExtraFlags :: [String] -> IO ()noExtraFlags args :: Argsargs
confExists <- doesFileExist :: FilePath -> IO BooldoesFileExist "configure"
when :: Monad m => Bool -> m () -> m ()when confExists :: BoolconfExists ($) :: (a -> b) -> a -> b$
runConfigureScript ::
Verbosity -> Bool -> ConfigFlags -> LocalBuildInfo -> IO ()runConfigureScript verbosity :: Verbosityverbosity
backwardsCompatHack :: BoolbackwardsCompatHack flags :: GlobalFlagsflags lbi :: LocalBuildInfolbi
pbi <- getHookedBuildInfo :: Verbosity -> IO HookedBuildInfogetHookedBuildInfo verbosity :: Verbosityverbosity
sanityCheckHookedBuildInfo ::
PackageDescription -> HookedBuildInfo -> IO ()sanityCheckHookedBuildInfo pkg_descr :: GenericPackageDescriptionpkg_descr pbi :: HookedBuildInfopbi
let pkg_descr' = updatePackageDescription ::
HookedBuildInfo -> PackageDescription -> PackageDescriptionupdatePackageDescription pbi :: HookedBuildInfopbi pkg_descr :: GenericPackageDescriptionpkg_descr
postConf ::
UserHooks
-> Args
-> ConfigFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postConf simpleUserHooks :: UserHookssimpleUserHooks args :: Argsargs flags :: GlobalFlagsflags pkg_descr' :: PackageDescriptionpkg_descr' lbi :: LocalBuildInfolbi
backwardsCompatHack = True :: BoolTrue
autoconfUserHooks :: UserHooks
autoconfUserHooks
= simpleUserHooks :: UserHookssimpleUserHooks
{
postConf = defaultPostConf ::
Args
-> ConfigFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()defaultPostConf,
preBuild = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook buildVerbosity :: BuildFlags -> Flag VerbositybuildVerbosity,
preClean = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook cleanVerbosity :: CleanFlags -> Flag VerbositycleanVerbosity,
preCopy = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook copyVerbosity :: CopyFlags -> Flag VerbositycopyVerbosity,
preInst = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook installVerbosity :: InstallFlags -> Flag VerbosityinstallVerbosity,
preHscolour = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook hscolourVerbosity :: HscolourFlags -> Flag VerbosityhscolourVerbosity,
preHaddock = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook haddockVerbosity :: HaddockFlags -> Flag VerbosityhaddockVerbosity,
preReg = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook regVerbosity :: RegisterFlags -> Flag VerbosityregVerbosity,
preUnreg = readHook ::
(a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInforeadHook regVerbosity :: RegisterFlags -> Flag VerbosityregVerbosity
}
where defaultPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
defaultPostConf args flags pkg_descr lbi
= do let verbosity = fromFlag :: Flag a -> afromFlag (configVerbosity :: ConfigFlags -> Flag VerbosityconfigVerbosity flags :: GlobalFlagsflags)
noExtraFlags :: [String] -> IO ()noExtraFlags args :: Argsargs
confExists <- doesFileExist :: FilePath -> IO BooldoesFileExist "configure"
if confExists :: BoolconfExists
then runConfigureScript ::
Verbosity -> Bool -> ConfigFlags -> LocalBuildInfo -> IO ()runConfigureScript verbosity :: Verbosityverbosity
backwardsCompatHack :: BoolbackwardsCompatHack flags :: GlobalFlagsflags lbi :: LocalBuildInfolbi
else die :: String -> IO adie "configure script not found."
pbi <- getHookedBuildInfo :: Verbosity -> IO HookedBuildInfogetHookedBuildInfo verbosity :: Verbosityverbosity
sanityCheckHookedBuildInfo ::
PackageDescription -> HookedBuildInfo -> IO ()sanityCheckHookedBuildInfo pkg_descr :: GenericPackageDescriptionpkg_descr pbi :: HookedBuildInfopbi
let pkg_descr' = updatePackageDescription ::
HookedBuildInfo -> PackageDescription -> PackageDescriptionupdatePackageDescription pbi :: HookedBuildInfopbi pkg_descr :: GenericPackageDescriptionpkg_descr
postConf ::
UserHooks
-> Args
-> ConfigFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()postConf simpleUserHooks :: UserHookssimpleUserHooks args :: Argsargs flags :: GlobalFlagsflags pkg_descr' :: PackageDescriptionpkg_descr' lbi :: LocalBuildInfolbi
backwardsCompatHack = False :: BoolFalse
readHook :: (a -> Flag Verbosity) -> Args -> a -> IO HookedBuildInfo
readHook get_verbosity a flags = do
noExtraFlags :: [String] -> IO ()noExtraFlags a :: Argsa
getHookedBuildInfo :: Verbosity -> IO HookedBuildInfogetHookedBuildInfo verbosity :: Verbosityverbosity
where
verbosity = fromFlag :: Flag a -> afromFlag (get_verbosity :: a -> Flag Verbosityget_verbosity flags :: GlobalFlagsflags)
runConfigureScript :: Verbosity -> Bool -> ConfigFlags -> LocalBuildInfo
-> IO ()
runConfigureScript verbosity backwardsCompatHack flags lbi = do
env <- getEnvironment :: IO [(String, String)]getEnvironment
let programConfig = withPrograms :: LocalBuildInfo -> ProgramConfigurationwithPrograms lbi :: LocalBuildInfolbi
(ccProg, ccFlags) <- configureCCompiler ::
Verbosity -> ProgramConfiguration -> IO (FilePath, [String])configureCCompiler verbosity :: Verbosityverbosity programConfig :: ProgramConfigurationprogramConfig
let env' = appendToEnvironment ::
(a, [Char]) -> [(a, [Char])] -> [(a, [Char])]appendToEnvironment ("CFLAGS", unwords :: [String] -> Stringunwords ccFlags :: [String]ccFlags)
env :: [(String, String)]env
args' = args :: Argsargs (++) :: [a] -> [a] -> [a]++ ["--with-gcc=" (++) :: [a] -> [a] -> [a]++ ccProg :: FilePathccProg]
handleNoWindowsSH :: IO a -> IO ahandleNoWindowsSH ($) :: (a -> b) -> a -> b$
rawSystemExitWithEnv ::
Verbosity -> FilePath -> [String] -> [(String, String)] -> IO ()rawSystemExitWithEnv verbosity :: Verbosityverbosity "sh" args' :: [[Char]]args' env' :: [([Char], [Char])]env'
where
args = "configure" (:) :: a -> [a] -> [a]: configureArgs :: Bool -> ConfigFlags -> [String]configureArgs backwardsCompatHack :: BoolbackwardsCompatHack flags :: GlobalFlagsflags
appendToEnvironment (key, val) [] = [(key :: akey, val :: [Char]val)]
appendToEnvironment (key, val) (kv@(k, v) : rest)
| key :: akey (==) :: Eq a => a -> a -> Bool== k :: ak = (key :: akey, v :: [Char]v (++) :: [a] -> [a] -> [a]++ " " (++) :: [a] -> [a] -> [a]++ val :: [Char]val) (:) :: a -> [a] -> [a]: rest :: [(a, [Char])]rest
| otherwise :: Boolotherwise = kv :: (a, [Char])kv (:) :: a -> [a] -> [a]: appendToEnvironment ::
(a, [Char]) -> [(a, [Char])] -> [(a, [Char])]appendToEnvironment (key :: akey, val :: [Char]val) rest :: [(a, [Char])]rest
handleNoWindowsSH action
| buildOS :: OSbuildOS (/=) :: Eq a => a -> a -> Bool/= Windows :: OSWindows
= action :: IO ()action
| otherwise :: Boolotherwise
= action :: IO ()action
catchIO :: IO a -> (IOException -> IO a) -> IO a`catchIO` \ioe -> if isDoesNotExistError :: IOError -> BoolisDoesNotExistError ioe :: IOExceptionioe
then die :: String -> IO adie notFoundMsg :: [Char]notFoundMsg
else throwIOIO :: IOException -> IO athrowIOIO ioe :: IOExceptionioe
notFoundMsg = "The package has a './configure' script. This requires a "
(++) :: [a] -> [a] -> [a]++ "Unix compatibility toolchain such as MinGW+MSYS or Cygwin."
getHookedBuildInfo :: Verbosity -> IO HookedBuildInfo
getHookedBuildInfo verbosity = do
maybe_infoFile <- defaultHookedPackageDesc :: IO (Maybe FilePath)defaultHookedPackageDesc
case maybe_infoFile :: Maybe FilePathmaybe_infoFile of
Nothing -> return :: Monad m => forall a. a -> m areturn emptyHookedBuildInfo :: HookedBuildInfoemptyHookedBuildInfo
Just infoFile -> do
info :: Verbosity -> String -> IO ()info verbosity :: Verbosityverbosity ($) :: (a -> b) -> a -> b$ "Reading parameters from " (++) :: [a] -> [a] -> [a]++ infoFile :: FilePathinfoFile
readHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInforeadHookedBuildInfo verbosity :: Verbosityverbosity infoFile :: FilePathinfoFile
defaultTestHook :: PackageDescription -> LocalBuildInfo
-> UserHooks -> TestFlags -> IO ()
defaultTestHook pkg_descr localbuildinfo _ flags =
test :: PackageDescription -> LocalBuildInfo -> TestFlags -> IO ()test pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo flags :: GlobalFlagsflags
defaultInstallHook :: PackageDescription -> LocalBuildInfo
-> UserHooks -> InstallFlags -> IO ()
defaultInstallHook pkg_descr localbuildinfo _ flags = do
let copyFlags = defaultCopyFlags :: CopyFlagsdefaultCopyFlags {
copyDistPref = installDistPref :: InstallFlags -> Flag FilePathinstallDistPref flags :: GlobalFlagsflags,
copyDest = toFlag :: a -> Flag atoFlag NoCopyDest :: CopyDestNoCopyDest,
copyVerbosity = installVerbosity :: InstallFlags -> Flag VerbosityinstallVerbosity flags :: GlobalFlagsflags
}
install ::
PackageDescription -> LocalBuildInfo -> CopyFlags -> IO ()install pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo copyFlags :: CopyFlagscopyFlags
let registerFlags = defaultRegisterFlags :: RegisterFlagsdefaultRegisterFlags {
regDistPref = installDistPref :: InstallFlags -> Flag FilePathinstallDistPref flags :: GlobalFlagsflags,
regInPlace = installInPlace :: InstallFlags -> Flag BoolinstallInPlace flags :: GlobalFlagsflags,
regPackageDB = installPackageDB :: InstallFlags -> Flag PackageDBinstallPackageDB flags :: GlobalFlagsflags,
regVerbosity = installVerbosity :: InstallFlags -> Flag VerbosityinstallVerbosity flags :: GlobalFlagsflags
}
when :: Monad m => Bool -> m () -> m ()when (hasLibs :: PackageDescription -> BoolhasLibs pkg_descr :: GenericPackageDescriptionpkg_descr) ($) :: (a -> b) -> a -> b$ register ::
PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO ()register pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo registerFlags :: RegisterFlagsregisterFlags
defaultBuildHook :: PackageDescription -> LocalBuildInfo
-> UserHooks -> BuildFlags -> IO ()
defaultBuildHook pkg_descr localbuildinfo hooks flags =
build ::
PackageDescription
-> LocalBuildInfo
-> BuildFlags
-> [PPSuffixHandler]
-> IO ()build pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo flags :: GlobalFlagsflags (allSuffixHandlers :: UserHooks -> [PPSuffixHandler]allSuffixHandlers hooks :: UserHookshooks)
defaultRegHook :: PackageDescription -> LocalBuildInfo
-> UserHooks -> RegisterFlags -> IO ()
defaultRegHook pkg_descr localbuildinfo _ flags =
if hasLibs :: PackageDescription -> BoolhasLibs pkg_descr :: GenericPackageDescriptionpkg_descr
then register ::
PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO ()register pkg_descr :: GenericPackageDescriptionpkg_descr localbuildinfo :: LocalBuildInfolocalbuildinfo flags :: GlobalFlagsflags
else setupMessage :: Verbosity -> String -> PackageIdentifier -> IO ()setupMessage verbosity :: Verbosityverbosity
"Package contains no library to register:" (packageId :: Package pkg => pkg -> PackageIdentifierpackageId pkg_descr :: GenericPackageDescriptionpkg_descr)
where verbosity = fromFlag :: Flag a -> afromFlag (regVerbosity :: RegisterFlags -> Flag VerbosityregVerbosity flags :: GlobalFlagsflags)