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 -> SelectSettings
22defaultSelectSettings version = SelectSettings
23 { extraCore = defaultExtraCore version
24 , expectedFailuresSelect = defaultExpectedFailures version
25 , stablePackages = defaultStablePackages version
26 , haskellPlatformDir = "hp"
27 , requireHaskellPlatform = True
28 , ignoreUpgradeableCore = False
29 , excludedPackages = empty
31 Set.fromList (words "blaze_html_0_5 small_base") `Set.union`
33#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
34 -- Needed on Windows to get unix-compat to compile
35 (if version >= GhcMajorVersion 7 6 then Set.empty else Set.fromList (words "old-time"))
38 -- Support for containers-unicode-symbols
39 (case Map.lookup (PackageName "containers") coreMap of
40 Just v | Just range <- simpleParse "< 0.5", v `withinRange` range
41 -> Set.singleton "containers-old"
43 , disabledFlags = Set.fromList (words "bytestring-in-base test-hlint network-uri")
45 (if version <= GhcMajorVersion 7 4
46 then Set.singleton "bytestring-builder"
52 (if version <= GhcMajorVersion 7 6
53 then Set.singleton "decoderinterface"
55 , allowedPackage = const $ Right ()
56 , useGlobalDatabase = False
58 if version >= GhcMajorVersion 7 8
60 [ PackageName "punycode" -- pulls in encoding
61 , PackageName "scientific" -- pulls in tasty-ant-xml
64 , selectGhcVersion = version
65 , selectTarballDir = "patching/tarballs"
66 , selectUnderlayPackageDirs = []
69select :: SelectSettings -> IO BuildPlan
71 ii <- getInstallInfo settings'
74 case iiBuildTools ii of
75 Left s -> error $ "Could not topologically sort build tools: " ++ s
80 , bpPackages = iiPackages ii
81 , bpOptionalCore = iiOptionalCore ii
83 , bpSkippedTests = skippedTests settings'
86-- | Get all of the build tools required.
87iiBuildTools :: InstallInfo -> Either String [String]
88iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
89 fmap (map packageVersionString)
92 $ filter (flip Set.notMember coreTools . fst)
95 $ mapMaybe (flip Map.lookup buildToolMap)
100 $ Map.filterWithKey isSelected m
102 isSelected name _ = name `Set.member` selected
103 selected = Set.fromList $ Map.keys packages
105 -- Build tools shipped with GHC which we should not attempt to build
107 coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
109 -- The map from build tool name to the package it comes from.
110 buildToolMap :: Map Executable (PackageName, Version)
111 buildToolMap = Map.unions $ map toBuildToolMap $ Map.toList m
113 toBuildToolMap :: (PackageName, PackageInfo) -> Map Executable (PackageName, Version)
114 toBuildToolMap (pn, pi) = Map.unions
115 $ map (flip Map.singleton (pn, piVersion pi))
119 addDependencies :: (PackageName, Version) -> ((PackageName, Version), Set (PackageName, Version))
120 addDependencies (pn, pv) =
124 case Map.lookup pn m of
126 Just pi -> Set.fromList
127 $ mapMaybe (flip Map.lookup buildToolMap)
131topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a]
133 uncurry go . partitionEithers . map (splitter . limitDeps) $ orig
136 | Set.null y = Left x
137 | otherwise = Right (x, y)
140 go [] y = Left $ "The following form a cycle: " ++ show (map fst y)
142 let (xs', ys') = partitionEithers $ map (splitter . dropDep x) ys
143 rest <- go (xs ++ xs') ys'
146 dropDep x (y, z) = (y, Set.delete x z)
148 allVertices = Set.fromList $ map fst orig
149 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