3{-# OPTIONS_GHC -Wall #-}
4module Main (main) where
6import Data.List ( nub )
7import Data.Version ( showVersion )
8import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )
9import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
10import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
11import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
12import Distribution.Simple.BuildPaths ( autogenModulesDir )
13import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )
14import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
15import Distribution.Verbosity ( Verbosity )
16import System.FilePath ( (</>) )
19main = defaultMainWithHooks simpleUserHooks
20 { buildHook = \pkg lbi hooks flags -> do
21 generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
22 buildHook simpleUserHooks pkg lbi hooks flags
25generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
26generateBuildModule verbosity pkg lbi = do
27 let dir = autogenModulesDir lbi
28 createDirectoryIfMissingVerbose verbosity True dir
29 withLibLBI pkg lbi $ \_ libcfg -> do
30 withTestLBI pkg lbi $ \suite suitecfg -> do
31 rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
32 [ "module Build_" ++ testName suite ++ " where"
34 , "autogen_dir :: String"
35 , "autogen_dir = " ++ show dir
38 , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
41 formatdeps = map (formatone . snd)
42 formatone p = case packageName p of
43 PackageName n -> n ++ "-" ++ showVersion (packageVersion p)
45testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
46testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list