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