aboutsummaryrefslogtreecommitdiff
path: root/src/CabalHelper/Compiletime/Process.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CabalHelper/Compiletime/Process.hs')
-rw-r--r--src/CabalHelper/Compiletime/Process.hs23
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