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 :: GhcMajorVersion -> BuildSettings
22defaultBuildSettings version = BuildSettings
23 { sandboxRoot = "sandbox"
24 , expectedFailuresBuild = defaultExpectedFailures version
25 , extraArgs = const ["-fnetwork23"]
26 , testWorkerThreads = 4
28 , tarballDir = "patching/tarballs"
29 , cabalFileDir = Nothing
32build :: BuildSettings -> BuildPlan -> IO ()
33build settings' bp = do
34 libVersion <- checkCabalVersion
36 putStrLn "Wiping out old sandbox folder"
37 rm_r $ sandboxRoot settings'
39 settings <- fixBuildSettings settings'
41 putStrLn "Creating new package database"
42 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
43 unless (ec1 == ExitSuccess) $ do
44 putStrLn "Unable to create package database via ghc-pkg init"
47 menv <- fmap Just $ getModifiedEnv settings
48 let runCabal args handle = runProcess "cabal" args Nothing menv Nothing (Just handle) (Just handle)
50 -- First install build tools so they can be used below.
51 let installBuildTool tool = do
52 let toolsDir = packageDir settings ++ "-tools"
54 ecInit <- rawSystem "ghc-pkg" ["init", toolsDir]
55 unless (ecInit == ExitSuccess) $ do
56 putStrLn "Unable to create package database via ghc-pkg init"
59 putStrLn $ "Installing build tool: " ++ tool
60 ec <- withBinaryFile "build-tools.log" WriteMode $ \handle -> do
61 hSetBuffering handle NoBuffering
63 let args = addCabalArgs settings BSTools
65 : ("--cabal-lib-version=" ++ libVersion)
66 : "--build-log=logs-tools/$pkg.log"
69 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
70 ph <- runCabal args handle
72 unless (ec == ExitSuccess) $ do
76 , " failed, please see build-tools.log"
79 putStrLn $ tool ++ " built"
81 mapM_ installBuildTool $ bpTools bp
83 putStrLn "Beginning Stackage build"
84 ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
85 packageList <- mapM (replaceTarball $ tarballDir settings) $ bpPackageList bp
86 let args = addCabalArgs settings BSBuild
88 : ("--cabal-lib-version=" ++ libVersion)
89 : "--build-log=logs/$pkg.log"
90 : "--max-backjumps=-1"
94 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
96 ec <- waitForProcess ph
97 unless (ec == ExitSuccess) $ do
98 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