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 /src/CabalHelper/Compiletime/Process.hs | |
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 'src/CabalHelper/Compiletime/Process.hs')
-rw-r--r-- | src/CabalHelper/Compiletime/Process.hs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/CabalHelper/Compiletime/Process.hs b/src/CabalHelper/Compiletime/Process.hs index 43c3cd5..5e9bbbd 100644 --- a/src/CabalHelper/Compiletime/Process.hs +++ b/src/CabalHelper/Compiletime/Process.hs @@ -44,19 +44,28 @@ readProcess' exe args inp = do return outp +-- | Essentially 'System.Process.callProcess' but returns exit code, has +-- additional options and logging to stderr when verbosity is enabled. callProcessStderr' - :: Verbose => Maybe FilePath -> FilePath -> [String] -> IO ExitCode -callProcessStderr' mwd exe args = do + :: Verbose => Maybe FilePath -> [(String, String)] + -> FilePath -> [String] -> IO ExitCode +callProcessStderr' mwd env exe args = do let cd = case mwd of Nothing -> []; Just wd -> [ "cd", formatProcessArg wd++";" ] vLog $ intercalate " " $ cd ++ map formatProcessArg (exe:args) - (_, _, _, h) <- createProcess (proc exe args) { std_out = UseHandle stderr - , cwd = mwd } + (_, _, _, h) <- createProcess (proc exe args) + { std_out = UseHandle stderr + , env = if env == [] then Nothing else Just env + , cwd = mwd + } waitForProcess h -callProcessStderr :: Verbose => Maybe FilePath -> FilePath -> [String] -> IO () -callProcessStderr mwd exe args = do - rv <- callProcessStderr' mwd exe args +-- | Essentially 'System.Process.callProcess' but with additional options +-- and logging to stderr when verbosity is enabled. +callProcessStderr :: Verbose => Maybe FilePath -> [(String, String)] + -> FilePath -> [String] -> IO () +callProcessStderr mwd env exe args = do + rv <- callProcessStderr' mwd env exe args case rv of ExitSuccess -> return () ExitFailure v -> processFailedException "callProcessStderr" exe args v |