{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.Simple.UserHooks
( UserHooks (..)
, Args
, emptyUserHooks
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.PackageDescription
import Distribution.Simple.Command
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.PreProcess
import Distribution.Simple.Program
import Distribution.Simple.Setup
type Args = [String]
data UserHooks = UserHooks
{ UserHooks -> IO (Maybe GenericPackageDescription)
readDesc :: IO (Maybe GenericPackageDescription)
, UserHooks -> [PPSuffixHandler]
hookedPreProcessors :: [PPSuffixHandler]
, UserHooks -> [Program]
hookedPrograms :: [Program]
, UserHooks -> Args -> ConfigFlags -> IO HookedBuildInfo
preConf :: Args -> ConfigFlags -> IO HookedBuildInfo
, UserHooks
-> (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfo
confHook
:: (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags
-> IO LocalBuildInfo
, UserHooks
-> Args
-> ConfigFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> BuildFlags -> IO HookedBuildInfo
preBuild :: Args -> BuildFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> BuildFlags
-> IO ()
buildHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
, UserHooks
-> Args
-> BuildFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postBuild :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> ReplFlags -> IO HookedBuildInfo
preRepl :: Args -> ReplFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> ReplFlags
-> Args
-> IO ()
replHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> ReplFlags -> [String] -> IO ()
, UserHooks
-> Args
-> ReplFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postRepl :: Args -> ReplFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> CleanFlags -> IO HookedBuildInfo
preClean :: Args -> CleanFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()
cleanHook :: PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()
, UserHooks
-> Args -> CleanFlags -> PackageDescription -> () -> IO ()
postClean :: Args -> CleanFlags -> PackageDescription -> () -> IO ()
, UserHooks -> Args -> CopyFlags -> IO HookedBuildInfo
preCopy :: Args -> CopyFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> CopyFlags
-> IO ()
copyHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()
, UserHooks
-> Args
-> CopyFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> InstallFlags -> IO HookedBuildInfo
preInst :: Args -> InstallFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> InstallFlags
-> IO ()
instHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()
, UserHooks
-> Args
-> InstallFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfo
preReg :: Args -> RegisterFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> RegisterFlags
-> IO ()
regHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()
, UserHooks
-> Args
-> RegisterFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postReg :: Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> RegisterFlags -> IO HookedBuildInfo
preUnreg :: Args -> RegisterFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> RegisterFlags
-> IO ()
unregHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()
, UserHooks
-> Args
-> RegisterFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postUnreg :: Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> HscolourFlags -> IO HookedBuildInfo
preHscolour :: Args -> HscolourFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> HscolourFlags
-> IO ()
hscolourHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()
, UserHooks
-> Args
-> HscolourFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postHscolour :: Args -> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> HaddockFlags -> IO HookedBuildInfo
preHaddock :: Args -> HaddockFlags -> IO HookedBuildInfo
, UserHooks
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> HaddockFlags
-> IO ()
haddockHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()
, UserHooks
-> Args
-> HaddockFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postHaddock :: Args -> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> TestFlags -> IO HookedBuildInfo
preTest :: Args -> TestFlags -> IO HookedBuildInfo
, UserHooks
-> Args
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> TestFlags
-> IO ()
testHook :: Args -> PackageDescription -> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()
, UserHooks
-> Args
-> TestFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postTest :: Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()
, UserHooks -> Args -> BenchmarkFlags -> IO HookedBuildInfo
preBench :: Args -> BenchmarkFlags -> IO HookedBuildInfo
, UserHooks
-> Args
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> BenchmarkFlags
-> IO ()
benchHook :: Args -> PackageDescription -> LocalBuildInfo -> UserHooks -> BenchmarkFlags -> IO ()
, UserHooks
-> Args
-> BenchmarkFlags
-> PackageDescription
-> LocalBuildInfo
-> IO ()
postBench :: Args -> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()
}
emptyUserHooks :: UserHooks
emptyUserHooks :: UserHooks
emptyUserHooks =
UserHooks
{ readDesc :: IO (Maybe GenericPackageDescription)
readDesc = Maybe GenericPackageDescription
-> IO (Maybe GenericPackageDescription)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GenericPackageDescription
forall a. Maybe a
Nothing
, hookedPreProcessors :: [PPSuffixHandler]
hookedPreProcessors = []
, hookedPrograms :: [Program]
hookedPrograms = []
, preConf :: Args -> ConfigFlags -> IO HookedBuildInfo
preConf = Args -> ConfigFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, confHook :: (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags -> IO LocalBuildInfo
confHook = (\(GenericPackageDescription, HookedBuildInfo)
_ ConfigFlags
_ -> LocalBuildInfo -> IO LocalBuildInfo
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> LocalBuildInfo
forall a. HasCallStack => [Char] -> a
error [Char]
"No local build info generated during configure. Over-ride empty configure hook."))
, postConf :: Args
-> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postConf = Args
-> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preBuild :: Args -> BuildFlags -> IO HookedBuildInfo
preBuild = Args -> BuildFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, buildHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
buildHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> BuildFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postBuild :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postBuild = Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preRepl :: Args -> ReplFlags -> IO HookedBuildInfo
preRepl = \Args
_ ReplFlags
_ -> HookedBuildInfo -> IO HookedBuildInfo
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HookedBuildInfo
emptyHookedBuildInfo
, replHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> ReplFlags -> Args -> IO ()
replHook = \PackageDescription
_ LocalBuildInfo
_ UserHooks
_ ReplFlags
_ Args
_ -> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
, postRepl :: Args -> ReplFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postRepl = Args -> ReplFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preClean :: Args -> CleanFlags -> IO HookedBuildInfo
preClean = Args -> CleanFlags -> IO HookedBuildInfo
forall {p}. Args -> p -> IO HookedBuildInfo
rn
, cleanHook :: PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()
cleanHook = PackageDescription -> () -> UserHooks -> CleanFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postClean :: Args -> CleanFlags -> PackageDescription -> () -> IO ()
postClean = Args -> CleanFlags -> PackageDescription -> () -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preCopy :: Args -> CopyFlags -> IO HookedBuildInfo
preCopy = Args -> CopyFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, copyHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()
copyHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postCopy = Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preInst :: Args -> InstallFlags -> IO HookedBuildInfo
preInst = Args -> InstallFlags -> IO HookedBuildInfo
forall {p}. Args -> p -> IO HookedBuildInfo
rn
, instHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()
instHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> InstallFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postInst :: Args
-> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postInst = Args
-> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preReg :: Args -> RegisterFlags -> IO HookedBuildInfo
preReg = Args -> RegisterFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, regHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()
regHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postReg :: Args
-> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postReg = Args
-> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preUnreg :: Args -> RegisterFlags -> IO HookedBuildInfo
preUnreg = Args -> RegisterFlags -> IO HookedBuildInfo
forall {p}. Args -> p -> IO HookedBuildInfo
rn
, unregHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()
unregHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> RegisterFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postUnreg :: Args
-> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postUnreg = Args
-> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preHscolour :: Args -> HscolourFlags -> IO HookedBuildInfo
preHscolour = Args -> HscolourFlags -> IO HookedBuildInfo
forall {p}. Args -> p -> IO HookedBuildInfo
rn
, hscolourHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()
hscolourHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> HscolourFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postHscolour :: Args
-> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postHscolour = Args
-> HscolourFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preHaddock :: Args -> HaddockFlags -> IO HookedBuildInfo
preHaddock = Args -> HaddockFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, haddockHook :: PackageDescription
-> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()
haddockHook = PackageDescription
-> LocalBuildInfo -> UserHooks -> HaddockFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postHaddock :: Args
-> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postHaddock = Args
-> HaddockFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preTest :: Args -> TestFlags -> IO HookedBuildInfo
preTest = Args -> TestFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, testHook :: Args
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> TestFlags
-> IO ()
testHook = \Args
_ -> PackageDescription
-> LocalBuildInfo -> UserHooks -> TestFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postTest :: Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postTest = Args -> TestFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, preBench :: Args -> BenchmarkFlags -> IO HookedBuildInfo
preBench = Args -> BenchmarkFlags -> IO HookedBuildInfo
forall {m :: * -> *} {p} {p}.
Monad m =>
p -> p -> m HookedBuildInfo
rn'
, benchHook :: Args
-> PackageDescription
-> LocalBuildInfo
-> UserHooks
-> BenchmarkFlags
-> IO ()
benchHook = \Args
_ -> PackageDescription
-> LocalBuildInfo -> UserHooks -> BenchmarkFlags -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
, postBench :: Args
-> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postBench = Args
-> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO ()
forall {m :: * -> *} {p} {p} {p} {p}.
Monad m =>
p -> p -> p -> p -> m ()
ru
}
where
rn :: Args -> p -> IO HookedBuildInfo
rn Args
args p
_ = Args -> IO ()
noExtraFlags Args
args IO () -> IO HookedBuildInfo -> IO HookedBuildInfo
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> HookedBuildInfo -> IO HookedBuildInfo
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return HookedBuildInfo
emptyHookedBuildInfo
rn' :: p -> p -> m HookedBuildInfo
rn' p
_ p
_ = HookedBuildInfo -> m HookedBuildInfo
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return HookedBuildInfo
emptyHookedBuildInfo
ru :: p -> p -> p -> p -> m ()
ru p
_ p
_ p
_ p
_ = () -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()