Don't let build tools dependencies seep into environments

This commit is contained in:
Michael Snoyman 2013-08-22 07:15:59 +03:00
parent 8b3eb7b45d
commit 18df8d13d1
3 changed files with 18 additions and 5 deletions

View File

@ -48,11 +48,18 @@ build settings' bp = do
-- First install build tools so they can be used below.
let installBuildTool tool = do
let toolsDir = packageDir settings ++ "-tools"
rm_r toolsDir
ecInit <- rawSystem "ghc-pkg" ["init", toolsDir]
unless (ecInit == ExitSuccess) $ do
putStrLn "Unable to create package database via ghc-pkg init"
exitWith ecInit
putStrLn $ "Installing build tool: " ++ tool
ec <- withBinaryFile "build-tools.log" WriteMode $ \handle -> do
hSetBuffering handle NoBuffering
let args = addCabalArgs settings BSBuild
let args = addCabalArgs settings BSTools
$ "install"
: ("--cabal-lib-version=" ++ libVersion)
: "--build-log=logs-tools/$pkg.log"
@ -69,6 +76,7 @@ build settings' bp = do
]
exitWith ec
putStrLn $ tool ++ " built"
rm_r toolsDir
mapM_ installBuildTool $ bpTools bp
putStrLn "Beginning Stackage build"

View File

@ -122,7 +122,7 @@ data SelectSettings = SelectSettings
, selectGhcVersion :: GhcMajorVersion
}
data BuildStage = BSBuild | BSTest
data BuildStage = BSTools | BSBuild | BSTest
data BuildSettings = BuildSettings
{ sandboxRoot :: FilePath

View File

@ -115,12 +115,17 @@ addCabalArgsOnlyGlobal rest
addCabalArgs :: BuildSettings -> BuildStage -> [String] -> [String]
addCabalArgs settings bs rest
= addCabalArgsOnlyGlobal
$ ("--package-db=" ++ packageDir settings)
: ("--libdir=" ++ libDir settings)
$ ("--package-db=" ++ packageDir settings ++ toolsSuffix)
: ("--libdir=" ++ libDir settings ++ toolsSuffix)
: ("--bindir=" ++ binDir settings)
: ("--datadir=" ++ dataDir settings)
: ("--docdir=" ++ docDir settings)
: ("--docdir=" ++ docDir settings ++ toolsSuffix)
: extraArgs settings bs ++ rest
where
toolsSuffix =
case bs of
BSTools -> "-tools"
_ -> ""
-- | Modified environment that adds our sandboxed bin folder to PATH.
getModifiedEnv :: BuildSettings -> IO [(String, String)]