diff options
-rw-r--r-- | scripts/ci/steps/00-config.sh | 2 | ||||
-rw-r--r-- | src/CabalHelper/Compiletime/Compile.hs | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/scripts/ci/steps/00-config.sh b/scripts/ci/steps/00-config.sh index b6c3140..eb8280a 100644 --- a/scripts/ci/steps/00-config.sh +++ b/scripts/ci/steps/00-config.sh @@ -8,3 +8,5 @@ fi source_dir="$(mktemp --tmpdir -d "cabal-helper.sdistXXXXXXXXX")" build_dir="$(mktemp --tmpdir -d "cabal-helper.distXXXXXXXXX")" + +NPROC=${NPROC:-1} diff --git a/src/CabalHelper/Compiletime/Compile.hs b/src/CabalHelper/Compiletime/Compile.hs index bd15537..b39e86f 100644 --- a/src/CabalHelper/Compiletime/Compile.hs +++ b/src/CabalHelper/Compiletime/Compile.hs @@ -36,10 +36,12 @@ import Data.String import Data.Version import GHC.IO.Exception (IOErrorType(OtherError)) import Text.Printf +import Text.Read import System.Directory import System.FilePath import System.Process import System.Exit +import System.Environment import System.IO import System.IO.Error import System.IO.Temp @@ -452,16 +454,20 @@ runSetupHs opts@Options {..} db srcdir ever CabalInstallVersion {..} SetupProgram {..} <- compileSetupHs opts db srcdir go $ callProcessStderr opts (Just srcdir) setupProgram where - parmake_opt - | Left _ <- ever = ["-j"] - | Right ver <- ever, ver >= Version [1,20] [] = ["-j"] + parmake_opt :: Maybe Int -> [String] + parmake_opt nproc' + | Left _ <- ever = ["-j"++nproc] + | Right ver <- ever, ver >= Version [1,20] [] = ["-j"++nproc] | otherwise = [] + where + nproc = fromMaybe "" $ show <$> nproc' go :: ([String] -> IO ()) -> IO () go run = do run $ [ "configure", "--package-db", db, "--prefix", db </> "prefix" ] ++ withGHCProgramOptions opts - run $ [ "build" ] ++ parmake_opt + mnproc <- join . fmap readMaybe <$> lookupEnv "NPROC" + run $ [ "build" ] ++ parmake_opt mnproc run [ "copy" ] run [ "register" ] |