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)
23defaultBuildSettings :: BuildSettings
24defaultBuildSettings = BuildSettings
25 { sandboxRoot = "sandbox"
27 , extraCore = defaultExtraCore
28 , expectedFailures = defaultExpectedFailures
29 , stablePackages = defaultStablePackages
30 , extraArgs = ["-fnetwork23"]
31 , haskellPlatformCabal = "haskell-platform/haskell-platform.cabal"
32 , requireHaskellPlatform = True
33 , cleanBeforeBuild = True
36build :: BuildSettings -> IO ()
38 putStrLn "Creating a build plan"
39 ii <- getInstallInfo settings'
41 let root' = sandboxRoot settings'
42 initPkgDb <- if cleanBeforeBuild settings'
44 putStrLn "Wiping out old sandbox folder"
49 b <- doesDirectoryExist root'
50 when b (putStrLn "Re-using existing sandbox")
52 createDirectoryIfMissing True root'
53 root <- canonicalizePath root'
54 let settings = settings' { sandboxRoot = root }
57 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
58 unless (ec1 == ExitSuccess) $ do
59 putStrLn "Unable to create package database via ghc-pkg init"
62 putStrLn "No mismatches, starting the sandboxed build."
64 versionString <- readProcess "cabal" ["--version"] ""
66 case map words $ lines versionString of
67 [_,["using","version",libVersion,"of","the","Cabal","library"]] -> return libVersion
68 _ -> error "Did not understand cabal --version output"
70 case (simpleParse libVersion, simpleParse ">= 1.16") of
71 (Nothing, _) -> error $ "Invalid Cabal library version: " ++ libVersion
72 (_, Nothing) -> assert False $ return ()
74 | v `withinRange` vr -> return ()
75 | otherwise -> error $ "Unsupported Cabal version: " ++ libVersion
77 ph <- withBinaryFile "build.log" WriteMode $ \handle ->
78 let args = addCabalArgs settings
80 : ("--cabal-lib-version=" ++ libVersion)
81 : "--build-log=logs/$pkg.log"
84 [ extraBuildArgs settings
88 in do hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
89 runProcess "cabal" args Nothing Nothing Nothing (Just handle) (Just handle)
90 ec <- waitForProcess ph
91 unless (ec == ExitSuccess) $ do
92 putStrLn "Build failed, please see build.log"
95 putStrLn "Sandbox built, beginning individual test suites"
96 runTestSuites settings ii
98 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