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,
23defaultBuildSettings :: Maybe Int -- ^ argument to -j
26defaultBuildSettings cores version = BuildSettings
27 { sandboxRoot = "sandbox"
28 , expectedFailuresBuild = defaultExpectedFailures version
29 , extraArgs = \bs -> "-fnetwork23" :
36 Just j -> ["-j" ++ show j]
37 , testWorkerThreads = 4
39 , tarballDir = "patching/tarballs"
40 , cabalFileDir = Nothing
43build :: BuildSettings -> BuildPlan -> IO ()
44build settings' bp = do
45 libVersion <- checkCabalVersion
47 putStrLn "Wiping out old sandbox folder"
48 rm_r $ sandboxRoot settings'
50 settings <- fixBuildSettings settings'
52 putStrLn "Creating new package database"
53 ec1 <- rawSystem "ghc-pkg" ["init", packageDir settings]
54 unless (ec1 == ExitSuccess) $ do
55 putStrLn "Unable to create package database via ghc-pkg init"
58 menv <- fmap Just $ getModifiedEnv settings
59 let runCabal args handle = runProcess "cabal" args Nothing menv Nothing (Just handle) (Just handle)
61 -- First install build tools so they can be used below.
62 let installBuildTool tool = do
63 let toolsDir = packageDir settings ++ "-tools"
65 ecInit <- rawSystem "ghc-pkg" ["init", toolsDir]
66 unless (ecInit == ExitSuccess) $ do
67 putStrLn "Unable to create package database via ghc-pkg init"
70 putStrLn $ "Installing build tool: " ++ tool
71 ec <- withBinaryFile "build-tools.log" WriteMode $ \handle -> do
72 hSetBuffering handle NoBuffering
74 let args = addCabalArgs settings BSTools
76 : ("--cabal-lib-version=" ++ libVersion)
77 : "--build-log=logs-tools/$pkg.log"
79 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
80 ph <- runCabal args handle
82 unless (ec == ExitSuccess) $ do
86 , " failed, please see build-tools.log"
89 putStrLn $ tool ++ " built"
91 mapM_ installBuildTool $ bpTools bp
93 putStrLn "Beginning Stackage build"
94 ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
95 packageList <- mapM (replaceTarball $ tarballDir settings) $ bpPackageList bp
96 let args = addCabalArgs settings BSBuild
98 : ("--cabal-lib-version=" ++ libVersion)
99 : "--build-log=logs/$pkg.log"
100 : "--max-backjumps=-1"
103 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
105 ec <- waitForProcess ph
106 unless (ec == ExitSuccess) $ do
107 putStrLn "Build failed, please see build.log"
110 putStrLn "Build completed successfully, checking for module name conflicts"
111 conflicts <- getModuleNameConflicts $ packageDir settings
112 System.IO.UTF8.writeFile "module-name-conflicts.txt"
113 $ 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