@@ -4,31 +4,17 @@ module Stackage.Build
44 , BuildSettings (..)
55 ) where
66
7−import Control.Exception (assert)
8−import Control.Monad (unless, when)
9−import qualified Data.Map as Map
10−import Data.Maybe (mapMaybe)
11−import Data.Set (empty)
12−import qualified Data.Set as Set
13−import Distribution.Text (simpleParse)
14−import Distribution.Version (withinRange)
7+import Control.Monad (unless)
158import Prelude hiding (pi)
16−import Stackage.CheckPlan
179import Stackage.Config
1810import Stackage.InstallInfo
19−import Stackage.Tarballs
20−import Stackage.Test
2111import Stackage.Types
2212import Stackage.Util
23−import System.Directory (canonicalizePath,
24− createDirectoryIfMissing,
25− doesDirectoryExist)
2613import System.Exit (ExitCode (ExitSuccess), exitWith)
2714import System.IO (IOMode (WriteMode), hPutStrLn,
2815 withBinaryFile)
29−import System.Process (rawSystem, readProcess, runProcess,
16+import System.Process (rawSystem, runProcess,
3017 waitForProcess)
31−import Stackage.Select (select)
3218import Stackage.CheckCabalVersion (checkCabalVersion)
3319
3420defaultBuildSettings :: BuildSettings
@@ -74,10 +60,10 @@ build settings' bp = do
7460 ]
7561 hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
7662 runCabal args handle
77− ec1 <- waitForProcess ph1
78− unless (ec1 == ExitSuccess) $ do
63+ ec2 <- waitForProcess ph1
64+ unless (ec2 == ExitSuccess) $ do
7965 putStrLn "Building of build tools failed, please see build-tools.log"
80− exitWith ec1
66+ exitWith ec2
8167 putStrLn "Build tools built"
8268
8369 ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
@@ -96,33 +82,3 @@ build settings' bp = do
9682 unless (ec == ExitSuccess) $ do
9783 putStrLn "Build failed, please see build.log"
9884 exitWith ec
99−
100−-- | Get all of the build tools required.
101−iiBuildTools :: InstallInfo -> [String]
102−iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
103− -- FIXME possible improvement: track the dependencies between the build
104− -- tools themselves, and install them in the correct order.
105− map unPackageName
106− $ filter (flip Set.notMember coreTools)
107− $ mapMaybe (flip Map.lookup buildToolMap)
108− $ Set.toList
109− $ Set.unions
110− $ map piBuildTools
111− $ Map.elems
112− $ Map.filterWithKey isSelected m
113− where
114− unPackageName (PackageName pn) = pn
115− isSelected name _ = name `Set.member` selected
116− selected = Set.fromList $ Map.keys packages
117−
118− -- Build tools shipped with GHC which we should not attempt to build
119− -- ourselves.
120− coreTools = Set.fromList $ map PackageName $ words "hsc2hs"
121−
122− -- The map from build tool name to the package it comes from.
123− buildToolMap = Map.unions $ map toBuildToolMap $ Map.toList m
124− toBuildToolMap :: (PackageName, PackageInfo) -> Map Executable PackageName
125− toBuildToolMap (pn, pi) = Map.unions
126− $ map (flip Map.singleton pn)
127− $ Set.toList
128− $ piExecs pi