mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-11 23:08:30 +01:00
Allow user control of -j argument #141
This commit is contained in:
parent
5b6cff89e3
commit
2d420cc03b
@ -18,11 +18,20 @@ import System.IO (BufferMode (NoBuffering),
|
|||||||
import System.Process (rawSystem, runProcess,
|
import System.Process (rawSystem, runProcess,
|
||||||
waitForProcess)
|
waitForProcess)
|
||||||
|
|
||||||
defaultBuildSettings :: GhcMajorVersion -> BuildSettings
|
defaultBuildSettings :: Maybe Int -- ^ argument to -j
|
||||||
defaultBuildSettings version = BuildSettings
|
-> GhcMajorVersion
|
||||||
|
-> BuildSettings
|
||||||
|
defaultBuildSettings cores version = BuildSettings
|
||||||
{ sandboxRoot = "sandbox"
|
{ sandboxRoot = "sandbox"
|
||||||
, expectedFailuresBuild = defaultExpectedFailures version
|
, expectedFailuresBuild = defaultExpectedFailures version
|
||||||
, extraArgs = const ["-fnetwork23"]
|
, extraArgs = \bs -> "-fnetwork23" :
|
||||||
|
case bs of
|
||||||
|
BSTest -> []
|
||||||
|
_ ->
|
||||||
|
case cores of
|
||||||
|
Nothing -> ["-j"]
|
||||||
|
Just 1 -> []
|
||||||
|
Just j -> ["-j", show j]
|
||||||
, testWorkerThreads = 4
|
, testWorkerThreads = 4
|
||||||
, buildDocs = True
|
, buildDocs = True
|
||||||
, tarballDir = "patching/tarballs"
|
, tarballDir = "patching/tarballs"
|
||||||
@ -64,7 +73,6 @@ build settings' bp = do
|
|||||||
$ "install"
|
$ "install"
|
||||||
: ("--cabal-lib-version=" ++ libVersion)
|
: ("--cabal-lib-version=" ++ libVersion)
|
||||||
: "--build-log=logs-tools/$pkg.log"
|
: "--build-log=logs-tools/$pkg.log"
|
||||||
: "-j"
|
|
||||||
: [tool]
|
: [tool]
|
||||||
hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
|
hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
|
||||||
ph <- runCabal args handle
|
ph <- runCabal args handle
|
||||||
@ -89,7 +97,6 @@ build settings' bp = do
|
|||||||
: "--build-log=logs/$pkg.log"
|
: "--build-log=logs/$pkg.log"
|
||||||
: "--max-backjumps=-1"
|
: "--max-backjumps=-1"
|
||||||
: "--reorder-goals"
|
: "--reorder-goals"
|
||||||
: "-j"
|
|
||||||
: packageList
|
: packageList
|
||||||
hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
|
hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
|
||||||
runCabal args handle
|
runCabal args handle
|
||||||
|
|||||||
@ -47,15 +47,17 @@ data BuildArgs = BuildArgs
|
|||||||
, buildPlanSrc :: FilePath
|
, buildPlanSrc :: FilePath
|
||||||
, extraArgs' :: [String] -> [String]
|
, extraArgs' :: [String] -> [String]
|
||||||
, noDocs :: Bool
|
, noDocs :: Bool
|
||||||
|
, buildCores :: Maybe Int
|
||||||
}
|
}
|
||||||
|
|
||||||
parseBuildArgs :: GhcMajorVersion -> [String] -> IO BuildArgs
|
parseBuildArgs :: GhcMajorVersion -> [String] -> IO BuildArgs
|
||||||
parseBuildArgs version =
|
parseBuildArgs version =
|
||||||
loop BuildArgs
|
loop BuildArgs
|
||||||
{ sandbox = sandboxRoot $ defaultBuildSettings version
|
{ sandbox = sandboxRoot $ defaultBuildSettings Nothing version
|
||||||
, buildPlanSrc = defaultBuildPlan
|
, buildPlanSrc = defaultBuildPlan
|
||||||
, extraArgs' = id
|
, extraArgs' = id
|
||||||
, noDocs = False
|
, noDocs = False
|
||||||
|
, buildCores = Nothing
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
loop x [] = return x
|
loop x [] = return x
|
||||||
@ -63,6 +65,7 @@ parseBuildArgs version =
|
|||||||
loop x ("--build-plan":y:rest) = loop x { buildPlanSrc = y } rest
|
loop x ("--build-plan":y:rest) = loop x { buildPlanSrc = y } rest
|
||||||
loop x ("--arg":y:rest) = loop x { extraArgs' = extraArgs' x . (y:) } rest
|
loop x ("--arg":y:rest) = loop x { extraArgs' = extraArgs' x . (y:) } rest
|
||||||
loop x ("--no-docs":rest) = loop x { noDocs = True } rest
|
loop x ("--no-docs":rest) = loop x { noDocs = True } rest
|
||||||
|
loop x ("-j":y:rest) = loop x { buildCores = Just $ read y } rest
|
||||||
loop _ (y:_) = error $ "Did not understand argument: " ++ y
|
loop _ (y:_) = error $ "Did not understand argument: " ++ y
|
||||||
|
|
||||||
defaultBuildPlan :: FilePath
|
defaultBuildPlan :: FilePath
|
||||||
@ -73,9 +76,10 @@ withBuildSettings args f = do
|
|||||||
version <- getGhcVersion
|
version <- getGhcVersion
|
||||||
BuildArgs {..} <- parseBuildArgs version args
|
BuildArgs {..} <- parseBuildArgs version args
|
||||||
bp <- readBuildPlan buildPlanSrc
|
bp <- readBuildPlan buildPlanSrc
|
||||||
let settings = (defaultBuildSettings version)
|
let bs = defaultBuildSettings buildCores version
|
||||||
|
let settings = bs
|
||||||
{ sandboxRoot = sandbox
|
{ sandboxRoot = sandbox
|
||||||
, extraArgs = extraArgs' . extraArgs (defaultBuildSettings version)
|
, extraArgs = extraArgs' . extraArgs bs
|
||||||
, buildDocs = not noDocs
|
, buildDocs = not noDocs
|
||||||
}
|
}
|
||||||
f settings bp
|
f settings bp
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user