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 , extraArgs = \bs -> "-fnetwork23" : "-fhttps" :
36 Just j -> ["-j" ++ show j]
37 , testWorkerThreads = 4
39 , tarballDir = "patching/tarballs"
40 , cabalFileDir = Nothing
41 , underlayPackageDirs = []
44build :: BuildSettings -> BuildPlan -> IO ()
45build settings' bp = do
46 libVersion <- checkCabalVersion
48 putStrLn "Wiping out old sandbox folder"
49 rm_r $ sandboxRoot settings'
51 settings <- fixBuildSettings settings'
53 putStrLn "Creating new package database"
54 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
55 unless (ec1 == ExitSuccess) $ do
56 putStrLn "Unable to create package database via ghc-pkg init"
59 menv <- fmap Just $ getModifiedEnv settings
60 let runCabal args handle = runProcess "cabal" args Nothing menv Nothing (Just handle) (Just handle)
62 -- First install build tools so they can be used below.
63 let installBuildTool tool = do
64 let toolsDir = packageDir settings ++ "-tools"
66 ecInit <- rawSystem "ghc-pkg" ["init", toolsDir]
67 unless (ecInit == ExitSuccess) $ do
68 putStrLn "Unable to create package database via ghc-pkg init"
71 putStrLn $ "Installing build tool: " ++ tool
72 ec <- withBinaryFile "build-tools.log" WriteMode $ \handle -> do
73 hSetBuffering handle NoBuffering
75 let args = addCabalArgs settings BSTools
77 : ("--cabal-lib-version=" ++ libVersion)
78 : "--build-log=logs-tools/$pkg.log"
80 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
81 ph <- runCabal args handle
83 unless (ec == ExitSuccess) $ do
87 , " failed, please see build-tools.log"
90 putStrLn $ tool ++ " built"
92 mapM_ installBuildTool $ bpTools bp
94 putStrLn "Beginning Stackage build"
95 ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
96 packageList <- mapM (replaceTarball $ tarballDir settings) $ bpPackageList bp
97 let args = addCabalArgs settings BSBuild
99 : ("--cabal-lib-version=" ++ libVersion)
100 : "--build-log=logs/$pkg.log"
101 : "--max-backjumps=-1"
104 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
106 ec <- waitForProcess ph
107 unless (ec == ExitSuccess) $ do
108 putStrLn "Build failed, please see build.log"
109 L8.readFile "build.log" >>= L8.putStr
112 putStrLn "Build completed successfully, checking for module name conflicts"
113 conflicts <- getModuleNameConflicts $ packageDir settings
114 System.IO.UTF8.writeFile "module-name-conflicts.txt"
115 $ 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