on master help sign in
Track multiple haskell-platform versions and determine GHC version
f90bccfMichael Snoyman
.gitmodulesdeleted−3
@@ -1,3 +0,0 @@
1−[submodule "haskell-platform"]
2− path = haskell-platform
3− url = https://github.com/haskell/haskell-platform.git
Stackage/Build.hs+3−3
@@ -18,10 +18,10 @@ import System.IO (BufferMode (NoBuffering),
18import System.Process (rawSystem, runProcess,
18import System.Process (rawSystem, runProcess,
19 waitForProcess)
19 waitForProcess)
20
20
21−defaultBuildSettings :: BuildSettings
21+defaultBuildSettings :: GhcMajorVersion -> BuildSettings
22−defaultBuildSettings = BuildSettings
22+defaultBuildSettings version = BuildSettings
23 { sandboxRoot = "sandbox"
23 { sandboxRoot = "sandbox"
24− , expectedFailuresBuild = defaultExpectedFailures
24+ , expectedFailuresBuild = defaultExpectedFailures version
25 , extraArgs = const ["-fnetwork23"]
25 , extraArgs = const ["-fnetwork23"]
26 , testWorkerThreads = 4
26 , testWorkerThreads = 4
27 , buildDocs = True
27 , buildDocs = True
Stackage/Config.hs+7−12
@@ -7,23 +7,18 @@ import Data.Set (fromList)
7import Distribution.Text (simpleParse)
7import Distribution.Text (simpleParse)
8import Stackage.Types
8import Stackage.Types
9
9
10−targetCompilerVersion :: Version
11−targetCompilerVersion =
12− case simpleParse "7.4.2" of
13− Nothing -> error "Invalid targetCompilerVersion"
14− Just v -> v
15−
16-- | Packages which are shipped with GHC but are not included in the
10-- | Packages which are shipped with GHC but are not included in the
17-- Haskell Platform list of core packages.
11-- Haskell Platform list of core packages.
18−defaultExtraCore :: Set PackageName
12+defaultExtraCore :: GhcMajorVersion -> Set PackageName
19−defaultExtraCore = fromList $ map PackageName $ words
13+defaultExtraCore _ = fromList $ map PackageName $ words
20 "binary Win32"
14 "binary Win32"
21
15
22-- | Test suites which are expected to fail for some reason. The test suite
16-- | Test suites which are expected to fail for some reason. The test suite
23-- will still be run and logs kept, but a failure will not indicate an
17-- will still be run and logs kept, but a failure will not indicate an
24-- error in our package combination.
18-- error in our package combination.
25−defaultExpectedFailures :: Set PackageName
19+defaultExpectedFailures :: GhcMajorVersion
20+ -> Set PackageName
26−defaultExpectedFailures = fromList $ map PackageName
21+defaultExpectedFailures _ = fromList $ map PackageName
27 [ -- Requires an old version of WAI and Warp for tests
22 [ -- Requires an old version of WAI and Warp for tests
28 "HTTP"
23 "HTTP"
29
24
@@ -93,8 +88,8 @@ defaultExpectedFailures = fromList $ map PackageName
93-- | List of packages for our stable Hackage. All dependencies will be
88-- | List of packages for our stable Hackage. All dependencies will be
94-- included as well. Please indicate who will be maintaining the package
89-- included as well. Please indicate who will be maintaining the package
95-- via comments.
90-- via comments.
96−defaultStablePackages :: Map PackageName (VersionRange, Maintainer)
91+defaultStablePackages :: GhcMajorVersion -> Map PackageName (VersionRange, Maintainer)
97−defaultStablePackages = unPackageMap $ execWriter $ do
92+defaultStablePackages _ = unPackageMap $ execWriter $ do
98 mapM_ (add "michael@snoyman.com") $ words =<<
93 mapM_ (add "michael@snoyman.com") $ words =<<
99 [ "yesod yesod-newsfeed yesod-sitemap yesod-static yesod-test yesod-bin"
94 [ "yesod yesod-newsfeed yesod-sitemap yesod-static yesod-test yesod-bin"
100 , "markdown filesystem-conduit mime-mail-ses"
95 , "markdown filesystem-conduit mime-mail-ses"
Stackage/GhcPkg.hs+15−10
@@ -3,24 +3,21 @@ module Stackage.GhcPkg where
3import Stackage.Types
3import Stackage.Types
4import System.Process
4import System.Process
5import Distribution.Text (simpleParse)
5import Distribution.Text (simpleParse)
6+import Distribution.Version (Version (Version))
6import Data.Char (isSpace)
7import Data.Char (isSpace)
7import qualified Data.Set as Set
8import qualified Data.Set as Set
8import Data.Maybe (fromMaybe)
9import Data.Maybe (fromMaybe)
9import Control.Monad (guard)
10import Control.Monad (guard)
10
11
11−getGlobalPackages :: IO (Set PackageIdentifier)
12+getGlobalPackages :: GhcMajorVersion -> IO (Set PackageIdentifier)
12−getGlobalPackages = do
13+getGlobalPackages version = do
13− -- Account for a change in command line option name
14− versionOutput <- readProcess "ghc-pkg" ["--version"] ""
15− let arg = fromMaybe "--no-user-package-db" $ do
16− verS:_ <- Just $ reverse $ words versionOutput
17− v76 <- simpleParse "7.6"
18− ver <- simpleParse verS
19− guard $ ver < (v76 :: Version)
20− return "--no-user-package-conf"
21 output <- readProcess "ghc-pkg" [arg, "list"] ""
14 output <- readProcess "ghc-pkg" [arg, "list"] ""
22 fmap Set.unions $ mapM parse $ drop 1 $ lines output
15 fmap Set.unions $ mapM parse $ drop 1 $ lines output
23 where
16 where
17+ -- Account for a change in command line option name
18+ arg
19+ | version >= GhcMajorVersion 7 6 = "--no-user-package-db"
20+ | otherwise = "--no-user-package-conf"
24 parse s =
21 parse s =
25 case clean s of
22 case clean s of
26 "" -> return Set.empty
23 "" -> return Set.empty
@@ -32,3 +29,11 @@ getGlobalPackages = do
32 stripParens x@('(':_:_)
29 stripParens x@('(':_:_)
33 | last x == ')' = tail $ init $ x
30 | last x == ')' = tail $ init $ x
34 stripParens x = x
31 stripParens x = x
32+
33+getGhcVersion :: IO GhcMajorVersion
34+getGhcVersion = do
35+ versionOutput <- readProcess "ghc-pkg" ["--version"] ""
36+ maybe (error $ "Invalid version output: " ++ show versionOutput) return $ do
37+ verS:_ <- Just $ reverse $ words versionOutput
38+ Version (x:y:_) _ <- simpleParse verS
39+ return $ GhcMajorVersion x y
Stackage/HaskellPlatform.hs+18−2
@@ -10,9 +10,25 @@ import Data.Monoid (Monoid (..))
10import Data.Set (singleton)
10import Data.Set (singleton)
11import Distribution.Text (simpleParse)
11import Distribution.Text (simpleParse)
12import Stackage.Types
12import Stackage.Types
13+import System.Directory (doesFileExist)
14+import System.FilePath ((</>))
13
15
14−loadHaskellPlatform :: SelectSettings -> IO HaskellPlatform
16+loadHaskellPlatform :: SelectSettings -> IO (Maybe HaskellPlatform)
15−loadHaskellPlatform = fmap parseHP . readFile . haskellPlatformCabal
17+loadHaskellPlatform ss = do
18+ e <- doesFileExist fp
19+ if e
20+ then fmap (Just . parseHP) $ readFile fp
21+ else return Nothing
22+ where
23+ GhcMajorVersion x y = selectGhcVersion ss
24+
25+ fp = haskellPlatformDir ss </> (concat
26+ [ "haskell-platform-"
27+ , show x
28+ , "."
29+ , show y
30+ , ".cabal"
31+ ])
16
32
17data HPLine = HPLPackage PackageIdentifier
33data HPLine = HPLPackage PackageIdentifier
18 | HPLBeginCore
34 | HPLBeginCore
Stackage/InstallInfo.hs+14−9
@@ -27,21 +27,23 @@ dropExcluded bs m0 =
27getInstallInfo :: SelectSettings -> IO InstallInfo
27getInstallInfo :: SelectSettings -> IO InstallInfo
28getInstallInfo settings = do
28getInstallInfo settings = do
29 putStrLn "Loading Haskell Platform"
29 putStrLn "Loading Haskell Platform"
30− hp <- loadHaskellPlatform settings
30+ mhp <- loadHaskellPlatform settings
31
31
32 core <-
32 core <-
33+ case mhp of
33− if useGlobalDatabase settings
34+ Just hp | not (useGlobalDatabase settings) -> return $ hpcore hp
34− then do
35+ _ -> do
35 putStrLn "Loading core packages from global database"
36 putStrLn "Loading core packages from global database"
36− getGlobalPackages
37+ getGlobalPackages $ selectGhcVersion settings
37− else return $ hpcore hp
38 let coreMap = Map.unions
38 let coreMap = Map.unions
39 $ map (\(PackageIdentifier k v) -> Map.singleton k v)
39 $ map (\(PackageIdentifier k v) -> Map.singleton k v)
40 $ Set.toList core
40 $ Set.toList core
41
41
42− let allPackages'
42+ let allPackages' =
43+ case mhp of
44+ Just hp | requireHaskellPlatform settings ->
43− | requireHaskellPlatform settings = Map.union (stablePackages settings) $ identsToRanges (hplibs hp)
45+ Map.union (stablePackages settings) $ identsToRanges (hplibs hp)
44− | otherwise = stablePackages settings
46+ _ -> stablePackages settings
45 allPackages = dropExcluded settings allPackages'
47 allPackages = dropExcluded settings allPackages'
46 let totalCore = extraCore settings `Set.union` Set.map (\(PackageIdentifier p _) -> p) core
48 let totalCore = extraCore settings `Set.union` Set.map (\(PackageIdentifier p _) -> p) core
47
49
@@ -80,7 +82,10 @@ getInstallInfo settings = do
80 return InstallInfo
82 return InstallInfo
81 { iiCore = totalCore
83 { iiCore = totalCore
82 , iiPackages = Map.map biToSPI final
84 , iiPackages = Map.map biToSPI final
85+ , iiOptionalCore = maybe
86+ Map.empty
83− , iiOptionalCore = Map.fromList $ map (\(PackageIdentifier p v) -> (p, v)) $ Set.toList $ hplibs hp
87+ (Map.fromList . map (\(PackageIdentifier p v) -> (p, v)) . Set.toList . hplibs)
88+ mhp
84 , iiPackageDB = pdb
89 , iiPackageDB = pdb
85 }
90 }
86
91
Stackage/LoadDatabase.hs+6−2
@@ -37,7 +37,7 @@ import Distribution.PackageDescription.Parse (ParseResult (ParseOk),
37 parsePackageDescription)
37 parsePackageDescription)
38import Distribution.System (buildArch, buildOS)
38import Distribution.System (buildArch, buildOS)
39import Distribution.Version (unionVersionRanges,
39import Distribution.Version (unionVersionRanges,
40− withinRange)
40+ withinRange, Version (Version))
41import Stackage.Config
41import Stackage.Config
42import Stackage.Types
42import Stackage.Types
43import Stackage.Util
43import Stackage.Util
@@ -67,6 +67,10 @@ loadPackageDB settings coreMap core deps = do
67 addEntries db Tar.Done = return db
67 addEntries db Tar.Done = return db
68 addEntries db (Tar.Next e es) = addEntry db e >>= flip addEntries es
68 addEntries db (Tar.Next e es) = addEntry db e >>= flip addEntries es
69
69
70+ ghcVersion' =
71+ let GhcMajorVersion x y = selectGhcVersion settings
72+ in Version [x, y, 2] []
73+
70 addEntry :: PackageDB -> Tar.Entry -> IO PackageDB
74 addEntry :: PackageDB -> Tar.Entry -> IO PackageDB
71 addEntry pdb e =
75 addEntry pdb e =
72 case getPackageVersion e of
76 case getPackageVersion e of
@@ -144,7 +148,7 @@ loadPackageDB settings coreMap core deps = do
144 flag' `Set.notMember` disabledFlags settings &&
148 flag' `Set.notMember` disabledFlags settings &&
145 flag `elem` flags'
149 flag `elem` flags'
146 checkCond' (Var (Impl compiler range)) =
150 checkCond' (Var (Impl compiler range)) =
147− compiler == GHC && withinRange targetCompilerVersion range
151+ compiler == GHC && withinRange ghcVersion' range
148 checkCond' (Lit b) = b
152 checkCond' (Lit b) = b
149 checkCond' (CNot c) = not $ checkCond' c
153 checkCond' (CNot c) = not $ checkCond' c
150 checkCond' (COr c1 c2) = checkCond' c1 || checkCond' c2
154 checkCond' (COr c1 c2) = checkCond' c1 || checkCond' c2
Stackage/Select.hs+7−6
@@ -18,12 +18,12 @@ import Stackage.InstallInfo
18import Stackage.Types
18import Stackage.Types
19import Stackage.Util
19import Stackage.Util
20
20
21−defaultSelectSettings :: SelectSettings
21+defaultSelectSettings :: GhcMajorVersion -> SelectSettings
22−defaultSelectSettings = SelectSettings
22+defaultSelectSettings version = SelectSettings
23− { extraCore = defaultExtraCore
23+ { extraCore = defaultExtraCore version
24− , expectedFailuresSelect = defaultExpectedFailures
24+ , expectedFailuresSelect = defaultExpectedFailures version
25− , stablePackages = defaultStablePackages
25+ , stablePackages = defaultStablePackages version
26− , haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
26+ , haskellPlatformDir = "haskell-platform"
27 , requireHaskellPlatform = True
27 , requireHaskellPlatform = True
28 , excludedPackages = empty
28 , excludedPackages = empty
29 , flags = \coreMap ->
29 , flags = \coreMap ->
@@ -42,6 +42,7 @@ defaultSelectSettings = SelectSettings
42 , allowedPackage = const $ Right ()
42 , allowedPackage = const $ Right ()
43 , useGlobalDatabase = False
43 , useGlobalDatabase = False
44 , skippedTests = empty
44 , skippedTests = empty
45+ , selectGhcVersion = version
45 }
46 }
46
47
47select :: SelectSettings -> IO BuildPlan
48select :: SelectSettings -> IO BuildPlan
Stackage/Types.hs+6−1
@@ -91,7 +91,7 @@ newtype Maintainer = Maintainer { unMaintainer :: String }
91 deriving (Show, Eq, Ord, Read)
91 deriving (Show, Eq, Ord, Read)
92
92
93data SelectSettings = SelectSettings
93data SelectSettings = SelectSettings
94− { haskellPlatformCabal :: FilePath
94+ { haskellPlatformDir :: FilePath
95 , flags :: Map PackageName Version -> Set String
95 , flags :: Map PackageName Version -> Set String
96 -- ^ Compile flags which should be turned on. Takes a Map providing the
96 -- ^ Compile flags which should be turned on. Takes a Map providing the
97 -- core packages so that flags can be set appropriately.
97 -- core packages so that flags can be set appropriately.
@@ -119,6 +119,7 @@ data SelectSettings = SelectSettings
119 , skippedTests :: Set PackageName
119 , skippedTests :: Set PackageName
120 -- ^ Do not build or run test suites, usually in order to avoid a
120 -- ^ Do not build or run test suites, usually in order to avoid a
121 -- dependency.
121 -- dependency.
122+ , selectGhcVersion :: GhcMajorVersion
122 }
123 }
123
124
124data BuildStage = BSBuild | BSTest
125data BuildStage = BSBuild | BSTest
@@ -142,3 +143,7 @@ instance Monoid PackageMap where
142 PackageMap $ unionWith go x y
143 PackageMap $ unionWith go x y
143 where
144 where
144 go (r1, m1) (r2, _) = (intersectVersionRanges r1 r2, m1)
145 go (r1, m1) (r2, _) = (intersectVersionRanges r1 r2, m1)
146+
147+-- | GHC major version. For example, for GHC 7.4.2, this would be 7 4.
148+data GhcMajorVersion = GhcMajorVersion Int Int
149+ deriving (Show, Ord, Eq)
app/stackage.hs+10−7
@@ -3,6 +3,7 @@ import Data.Set (fromList)
3import Stackage.Build (build, defaultBuildSettings)
3import Stackage.Build (build, defaultBuildSettings)
4import Stackage.BuildPlan (readBuildPlan, writeBuildPlan)
4import Stackage.BuildPlan (readBuildPlan, writeBuildPlan)
5import Stackage.CheckPlan (checkPlan)
5import Stackage.CheckPlan (checkPlan)
6+import Stackage.GhcPkg (getGhcVersion)
6import Stackage.Init (stackageInit)
7import Stackage.Init (stackageInit)
7import Stackage.Select (defaultSelectSettings, select)
8import Stackage.Select (defaultSelectSettings, select)
8import Stackage.Tarballs (makeTarballs)
9import Stackage.Tarballs (makeTarballs)
@@ -49,10 +50,10 @@ data BuildArgs = BuildArgs
49 , noDocs :: Bool
50 , noDocs :: Bool
50 }
51 }
51
52
52−parseBuildArgs :: [String] -> IO BuildArgs
53+parseBuildArgs :: GhcMajorVersion -> [String] -> IO BuildArgs
53−parseBuildArgs =
54+parseBuildArgs version =
54 loop BuildArgs
55 loop BuildArgs
55− { sandbox = sandboxRoot defaultBuildSettings
56+ { sandbox = sandboxRoot $ defaultBuildSettings version
56 , buildPlanSrc = defaultBuildPlan
57 , buildPlanSrc = defaultBuildPlan
57 , extraArgs' = id
58 , extraArgs' = id
58 , noDocs = False
59 , noDocs = False
@@ -70,11 +71,12 @@ defaultBuildPlan = "build-plan.txt"
70
71
71withBuildSettings :: [String] -> (BuildSettings -> BuildPlan -> IO a) -> IO a
72withBuildSettings :: [String] -> (BuildSettings -> BuildPlan -> IO a) -> IO a
72withBuildSettings args f = do
73withBuildSettings args f = do
74+ version <- getGhcVersion
73− BuildArgs {..} <- parseBuildArgs args
75+ BuildArgs {..} <- parseBuildArgs version args
74 bp <- readBuildPlan buildPlanSrc
76 bp <- readBuildPlan buildPlanSrc
75− let settings = defaultBuildSettings
77+ let settings = (defaultBuildSettings version)
76 { sandboxRoot = sandbox
78 { sandboxRoot = sandbox
77− , extraArgs = extraArgs' . extraArgs defaultBuildSettings
79+ , extraArgs = extraArgs' . extraArgs (defaultBuildSettings version)
78 , buildDocs = not noDocs
80 , buildDocs = not noDocs
79 }
81 }
80 f settings bp
82 f settings bp
@@ -86,8 +88,9 @@ main = do
86 ["uploads"] -> checkUploads "allowed.txt" "new-allowed.txt"
88 ["uploads"] -> checkUploads "allowed.txt" "new-allowed.txt"
87 "select":rest -> do
89 "select":rest -> do
88 SelectArgs {..} <- parseSelectArgs rest
90 SelectArgs {..} <- parseSelectArgs rest
91+ ghcVersion <- getGhcVersion
89 bp <- select
92 bp <- select
90− defaultSelectSettings
93+ (defaultSelectSettings ghcVersion)
91 { excludedPackages = fromList $ map PackageName excluded
94 { excludedPackages = fromList $ map PackageName excluded
92 , requireHaskellPlatform = not noPlatform
95 , requireHaskellPlatform = not noPlatform
93 , allowedPackage =
96 , allowedPackage =