7import Control.Monad (unless)
8import Prelude hiding (pi)
9import Stackage.CheckCabalVersion (checkCabalVersion)
11import Stackage.InstallInfo
14import System.Exit (ExitCode (ExitSuccess), exitWith)
15import System.IO (BufferMode (NoBuffering),
16 IOMode (WriteMode), hPutStrLn,
17 hSetBuffering, withBinaryFile)
18import System.Process (rawSystem, runProcess,
21defaultBuildSettings :: Maybe Int -- ^ argument to -j
24defaultBuildSettings cores version = BuildSettings
25 { sandboxRoot = "sandbox"
26 , expectedFailuresBuild = defaultExpectedFailures version
27 , extraArgs = \bs -> "-fnetwork23" :
34 Just j -> ["-j" ++ show j]
35 , testWorkerThreads = 4
37 , tarballDir = "patching/tarballs"
38 , cabalFileDir = Nothing
41build :: BuildSettings -> BuildPlan -> IO ()
42build settings' bp = do
43 libVersion <- checkCabalVersion
45 putStrLn "Wiping out old sandbox folder"
46 rm_r $ sandboxRoot settings'
48 settings <- fixBuildSettings settings'
50 putStrLn "Creating new package database"
51 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
52 unless (ec1 == ExitSuccess) $ do
53 putStrLn "Unable to create package database via ghc-pkg init"
56 menv <- fmap Just $ getModifiedEnv settings
57 let runCabal args handle = runProcess "cabal" args Nothing menv Nothing (Just handle) (Just handle)
59 -- First install build tools so they can be used below.
60 let installBuildTool tool = do
61 let toolsDir = packageDir settings ++ "-tools"
63 ecInit <- rawSystem "ghc-pkg" ["init", toolsDir]
64 unless (ecInit == ExitSuccess) $ do
65 putStrLn "Unable to create package database via ghc-pkg init"
68 putStrLn $ "Installing build tool: " ++ tool
69 ec <- withBinaryFile "build-tools.log" WriteMode $ \handle -> do
70 hSetBuffering handle NoBuffering
72 let args = addCabalArgs settings BSTools
74 : ("--cabal-lib-version=" ++ libVersion)
75 : "--build-log=logs-tools/$pkg.log"
77 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
78 ph <- runCabal args handle
80 unless (ec == ExitSuccess) $ do
84 , " failed, please see build-tools.log"
87 putStrLn $ tool ++ " built"
89 mapM_ installBuildTool $ bpTools bp
91 putStrLn "Beginning Stackage build"
92 ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
93 packageList <- mapM (replaceTarball $ tarballDir settings) $ bpPackageList bp
94 let args = addCabalArgs settings BSBuild
96 : ("--cabal-lib-version=" ++ libVersion)
97 : "--build-log=logs/$pkg.log"
98 : "--max-backjumps=-1"
101 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
103 ec <- waitForProcess ph
104 unless (ec == ExitSuccess) $ do
105 putStrLn "Build failed, please see build.log"
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