7import Control.Monad (unless)
8import Prelude hiding (pi)
9import Stackage.CheckCabalVersion (checkCabalVersion)
11import Stackage.InstallInfo
12import Stackage.ModuleNameConflict
15import System.Exit (ExitCode (ExitSuccess), exitWith)
16import System.IO (BufferMode (NoBuffering),
17 IOMode (WriteMode), hPutStrLn,
18 hSetBuffering, withBinaryFile)
19import qualified System.IO.UTF8
20import System.Process (rawSystem, runProcess,
22import qualified Data.ByteString.Lazy.Char8 as L8
24defaultBuildSettings :: Maybe Int -- ^ argument to -j
27defaultBuildSettings cores version = BuildSettings
28 { sandboxRoot = "sandbox"
29 , expectedFailuresBuild = defaultExpectedFailures version
30 , extraArgs = \bs -> "-fnetwork23" :
37 Just j -> ["-j" ++ show j]
38 , testWorkerThreads = 4
40 , tarballDir = "patching/tarballs"
41 , cabalFileDir = Nothing
42 , underlayPackageDirs = []
45build :: BuildSettings -> BuildPlan -> IO ()
46build settings' bp = do
47 libVersion <- checkCabalVersion
49 putStrLn "Wiping out old sandbox folder"
50 rm_r $ sandboxRoot settings'
52 settings <- fixBuildSettings settings'
54 putStrLn "Creating new package database"
55 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
56 unless (ec1 == ExitSuccess) $ do
57 putStrLn "Unable to create package database via ghc-pkg init"
60 menv <- fmap Just $ getModifiedEnv settings
61 let runCabal args handle = runProcess "cabal" args Nothing menv Nothing (Just handle) (Just handle)
63 -- First install build tools so they can be used below.
64 let installBuildTool tool = do
65 let toolsDir = packageDir settings ++ "-tools"
67 ecInit <- rawSystem "ghc-pkg" ["init", toolsDir]
68 unless (ecInit == ExitSuccess) $ do
69 putStrLn "Unable to create package database via ghc-pkg init"
72 putStrLn $ "Installing build tool: " ++ tool
73 ec <- withBinaryFile "build-tools.log" WriteMode $ \handle -> do
74 hSetBuffering handle NoBuffering
76 let args = addCabalArgs settings BSTools
78 : ("--cabal-lib-version=" ++ libVersion)
79 : "--build-log=logs-tools/$pkg.log"
81 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
82 ph <- runCabal args handle
84 unless (ec == ExitSuccess) $ do
88 , " failed, please see build-tools.log"
91 putStrLn $ tool ++ " built"
93 mapM_ installBuildTool $ bpTools bp
95 putStrLn "Beginning Stackage build"
96 ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
97 packageList <- mapM (replaceTarball $ tarballDir settings) $ bpPackageList bp
98 let args = addCabalArgs settings BSBuild
100 : ("--cabal-lib-version=" ++ libVersion)
101 : "--build-log=logs/$pkg.log"
102 : "--max-backjumps=-1"
105 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
107 ec <- waitForProcess ph
108 unless (ec == ExitSuccess) $ do
109 putStrLn "Build failed, please see build.log"
110 L8.readFile "build.log" >>= L8.putStr
113 putStrLn "Build completed successfully, checking for module name conflicts"
114 conflicts <- getModuleNameConflicts $ packageDir settings
115 System.IO.UTF8.writeFile "module-name-conflicts.txt"
116 $ renderModuleNameConflicts conflicts
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