diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-08-04 21:14:45 +0200 |
---|---|---|
committer | Daniel Gröber (dxld) <dxld@darkboxed.org> | 2019-09-17 17:48:26 +0200 |
commit | 23864c59abfc6dad5a6b137941d618903817e1e3 (patch) | |
tree | 7a7394017e8ec0595acb8bb0a5ec3201b8bbaf47 /lib | |
parent | a93ed8c7d93df1860d2e56b400b724ac47edf470 (diff) |
Allow passing override-env to process functions
Unfortunately we need this to pass a custom GHC executable path to stack,
since it doesn't have an option to override it on the commandline (yet?).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Distribution/Helper.hs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs index c269a5c..209eb09 100644 --- a/lib/Distribution/Helper.hs +++ b/lib/Distribution/Helper.hs @@ -196,12 +196,16 @@ mkQueryEnv mkQueryEnv projloc distdir = do cr <- newIORef $ QueryCache Nothing Map.empty return $ QueryEnv - { qeReadProcess = \stdin mcwd exe args -> - readCreateProcess (proc exe args){ cwd = mcwd } stdin - , qeCallProcess = \mcwd exe args -> do + { qeReadProcess = \stdin mcwd env exe args -> + let cp = (proc exe args) + { cwd = mcwd + , env = if env == [] then Nothing else Just env + } + in readCreateProcess cp stdin + , qeCallProcess = \mcwd env exe args -> do let ?verbose = \_ -> False -- TODO: we should get this from env or -- something - callProcessStderr mcwd exe args + callProcessStderr mcwd env exe args , qePrograms = defaultPrograms , qeProjLoc = projloc , qeDistDir = distdir @@ -378,13 +382,13 @@ shallowReconfigureProject QueryEnv { qeProjLoc = ProjLocV2File projfile , qeDistDir = DistDirCabal SCV2 _distdirv2, .. } = do let projdir = takeDirectory projfile - _ <- qeCallProcess (Just projdir) (cabalProgram qePrograms) + _ <- qeCallProcess (Just projdir) [] (cabalProgram qePrograms) ["new-build", "--dry-run", "--project-file="++projfile, "all"] return () shallowReconfigureProject QueryEnv { qeProjLoc = ProjLocV2Dir projdir , qeDistDir = DistDirCabal SCV2 _distdirv2, .. } = do - _ <- qeCallProcess (Just projdir) (cabalProgram qePrograms) + _ <- qeCallProcess (Just projdir) [] (cabalProgram qePrograms) ["new-build", "--dry-run", "all"] return () shallowReconfigureProject QueryEnv @@ -403,7 +407,7 @@ reconfigureUnit QueryEnv{qeProjLoc=ProjLocV2File projfile, ..} Unit{uPackageDir, uImpl} = do - _ <- qeCallProcess (Just uPackageDir) (cabalProgram qePrograms) + _ <- qeCallProcess (Just uPackageDir) [] (cabalProgram qePrograms) (["new-build", "--project-file="++projfile] ++ uiV2Components uImpl) return () @@ -411,7 +415,7 @@ reconfigureUnit QueryEnv{qeProjLoc=ProjLocV2Dir{}, ..} Unit{uPackageDir, uImpl} = do - _ <- qeCallProcess (Just uPackageDir) (cabalProgram qePrograms) + _ <- qeCallProcess (Just uPackageDir) [] (cabalProgram qePrograms) (["new-build"] ++ uiV2Components uImpl) -- TODO: version check for --only-configure return () @@ -546,7 +550,7 @@ invokeHelper args0 = do let args1 = cabal_file_path : distdir : args0 - evaluate =<< qeReadProcess "" Nothing exe args1 `E.catch` + evaluate =<< qeReadProcess "" Nothing [] exe args1 `E.catch` \(_ :: E.IOException) -> panicIO $ concat ["invokeHelper", ": ", exe, " " |