1{-# LANGUAGE PatternGuards #-}
5 , defaultSelectSettings
8import Data.Either (partitionEithers)
9import qualified Data.Map as Map
10import Data.Maybe (mapMaybe)
11import Data.Set (empty)
12import qualified Data.Set as Set
13import Distribution.Text (simpleParse)
14import Distribution.Version (withinRange)
15import Prelude hiding (pi)
17import Stackage.InstallInfo
21defaultSelectSettings :: GhcMajorVersion
22 -> Bool -- ^ haskell platform?
24defaultSelectSettings version requireHP = SelectSettings
25 { extraCore = defaultExtraCore version
26 , expectedFailures = defaultExpectedFailures version requireHP
27 , stablePackages = defaultStablePackages version
28 , haskellPlatformDir = "hp"
29 , requireHaskellPlatform = requireHP
30 , ignoreUpgradeableCore = False
31 , excludedPackages = empty
33 Set.fromList (words "blaze_html_0_5 small_base https splitbase old-locale") `Set.union`
35#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
36 -- Needed on Windows to get unix-compat to compile
37 (if version >= GhcMajorVersion 7 6 then Set.empty else Set.fromList (words "old-time"))
40 -- Support for containers-unicode-symbols
41 (case Map.lookup (PackageName "containers") coreMap of
42 Just v | Just range <- simpleParse "< 0.5", v `withinRange` range
43 -> Set.singleton "containers-old"
44 _ -> Set.empty) `Set.union`
46 -- Support for network 2.6
47 (if version >= GhcMajorVersion 7 8 && not requireHP
48 then Set.singleton "network-uri"
50 , disabledFlags = Set.fromList (words "bytestring-in-base test-hlint")
52 (if version <= GhcMajorVersion 7 4
53 then Set.singleton "bytestring-builder"
59 (if version <= GhcMajorVersion 7 6
60 then Set.singleton "decoderinterface"
61 else Set.empty) `Set.union`
63 -- Support for network 2.6
64 (if version >= GhcMajorVersion 7 8 && not requireHP
66 else Set.singleton "network-uri")
67 , allowedPackage = const $ Right ()
68 , useGlobalDatabase = False
70 Set.insert (PackageName "ReadArgs") $ -- old version of hspec
71 if version >= GhcMajorVersion 7 8
73 [ PackageName "punycode" -- pulls in encoding
74 , PackageName "ersatz" -- old QuickCheck
77 , selectGhcVersion = version
78 , selectTarballDir = "patching/tarballs"
79 , selectUnderlayPackageDirs = []
82select :: SelectSettings -> IO BuildPlan
84 ii <- getInstallInfo settings'
87 case iiBuildTools ii of
88 Left s -> error $ "Could not topologically sort build tools: " ++ s
93 , bpPackages = iiPackages ii
94 , bpOptionalCore = iiOptionalCore ii
96 , bpSkippedTests = skippedTests settings'
97 , bpExpectedFailures = expectedFailures settings'
100-- | Get all of the build tools required.
101iiBuildTools :: InstallInfo -> Either String [String]
102iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
103 fmap (map packageVersionString)
105 $ map addDependencies
106 $ filter (flip Set.notMember coreTools . fst)
109 $ mapMaybe (flip Map.lookup buildToolMap)
112 $ map piBuildToolsAll
114 $ Map.filterWithKey isSelected m
116 isSelected name _ = name `Set.member` selected
117 selected = Set.fromList $ Map.keys packages
119 -- Build tools shipped with GHC which we should not attempt to build
121 coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
123 -- The map from build tool name to the package it comes from.
124 buildToolMap :: Map Executable (PackageName, Version)
125 buildToolMap = Map.unions $ map toBuildToolMap $ Map.toList m
127 toBuildToolMap :: (PackageName, PackageInfo) -> Map Executable (PackageName, Version)
128 toBuildToolMap (pn, pi) = Map.unions
129 $ map (flip Map.singleton (pn, piVersion pi))
133 addDependencies :: (PackageName, Version) -> ((PackageName, Version), Set (PackageName, Version))
134 addDependencies (pn, pv) =
138 case Map.lookup pn m of
140 Just pi -> Set.fromList
141 $ mapMaybe (flip Map.lookup buildToolMap)
143 $ piBuildToolsExe pi `Set.union` manualDeps
146 | pn == PackageName "c2hs" = Set.singleton $ Executable "happy"
147 | otherwise = Set.empty
149topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a]
151 uncurry go . partitionEithers . map (splitter . limitDeps) $ orig
154 | Set.null y = Left x
155 | otherwise = Right (x, y)
158 go [] y = Left $ "The following form a cycle: " ++ show (map fst y)
160 let (xs', ys') = partitionEithers $ map (splitter . dropDep x) ys
161 rest <- go (xs ++ xs') ys'
164 dropDep x (y, z) = (y, Set.delete x z)
166 allVertices = Set.fromList $ map fst orig
167 limitDeps (x, y) = (x, Set.intersection allVertices y)
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