7import Distribution.Text (simpleParse)
8import Control.Monad (unless, when)
10import Stackage.CheckPlan
11import Stackage.InstallInfo
12import Stackage.Tarballs
16import System.Exit (ExitCode (ExitSuccess), exitWith)
17import System.IO (IOMode (WriteMode), withBinaryFile, hPutStrLn)
18import System.Process (runProcess, waitForProcess, rawSystem, readProcess)
19import System.Directory (createDirectoryIfMissing, canonicalizePath, doesDirectoryExist)
20import Distribution.Version (thisVersion, withinRange)
21import Control.Exception (assert)
22import Data.Set (empty)
24defaultBuildSettings :: BuildSettings
25defaultBuildSettings = BuildSettings
26 { sandboxRoot = "sandbox"
28 , extraCore = defaultExtraCore
29 , expectedFailures = defaultExpectedFailures
30 , stablePackages = defaultStablePackages
31 , extraArgs = ["-fnetwork23"]
32 , haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
33 , requireHaskellPlatform = True
34 , cleanBeforeBuild = True
35 , excludedPackages = empty
38build :: BuildSettings -> IO ()
40 putStrLn "Creating a build plan"
41 ii <- getInstallInfo settings'
43 let root' = sandboxRoot settings'
44 initPkgDb <- if cleanBeforeBuild settings'
46 putStrLn "Wiping out old sandbox folder"
51 b <- doesDirectoryExist root'
52 when b (putStrLn "Re-using existing sandbox")
54 createDirectoryIfMissing True root'
55 root <- canonicalizePath root'
56 let settings = settings' { sandboxRoot = root }
59 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
60 unless (ec1 == ExitSuccess) $ do
61 putStrLn "Unable to create package database via ghc-pkg init"
64 putStrLn "No mismatches, starting the sandboxed build."
66 versionString <- readProcess "cabal" ["--version"] ""
68 case map words $ lines versionString of
69 [_,["using","version",libVersion,"of","the","Cabal","library"]] -> return libVersion
70 _ -> error "Did not understand cabal --version output"
72 case (simpleParse libVersion, simpleParse ">= 1.16") of
73 (Nothing, _) -> error $ "Invalid Cabal library version: " ++ libVersion
74 (_, Nothing) -> assert False $ return ()
76 | v `withinRange` vr -> return ()
77 | otherwise -> error $ "Unsupported Cabal version: " ++ libVersion
79 ph <- withBinaryFile "build.log" WriteMode $ \handle ->
80 let args = addCabalArgs settings
82 : ("--cabal-lib-version=" ++ libVersion)
83 : "--build-log=logs/$pkg.log"
86 [ extraBuildArgs settings
90 in do hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
91 runProcess "cabal" args Nothing Nothing Nothing (Just handle) (Just handle)
92 ec <- waitForProcess ph
93 unless (ec == ExitSuccess) $ do
94 putStrLn "Build failed, please see build.log"
97 putStrLn "Sandbox built, beginning individual test suites"
98 runTestSuites settings ii
100 putStrLn "All test suites that were expected to pass did pass, building tarballs."
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