From 23864c59abfc6dad5a6b137941d618903817e1e3 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Sun, 4 Aug 2019 21:14:45 +0200 Subject: 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?). --- src/CabalHelper/Compiletime/Types.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/CabalHelper/Compiletime/Types.hs') diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs index 1f3bd3d..330fdbc 100644 --- a/src/CabalHelper/Compiletime/Types.hs +++ b/src/CabalHelper/Compiletime/Types.hs @@ -231,12 +231,12 @@ data Ex a = forall x. Ex (a x) type QueryEnv = QueryEnvI QueryCache data QueryEnvI c (pt :: ProjType) = QueryEnv - { qeReadProcess :: !ReadProcessWithCwd + { qeReadProcess :: !ReadProcessWithCwdAndEnv -- ^ Field accessor for 'QueryEnv'. Function used to to start -- processes. Useful if you need to, for example, redirect standard error -- output of programs started by cabal-helper. - , qeCallProcess :: !(CallProcessWithCwd ()) + , qeCallProcess :: !(CallProcessWithCwdAndEnv ()) , qePrograms :: !Programs -- ^ Field accessor for 'QueryEnv'. @@ -255,8 +255,11 @@ data QueryEnvI c (pt :: ProjType) = QueryEnv -- 'QueryEnv' is used. } -type ReadProcessWithCwd = String -> CallProcessWithCwd String -type CallProcessWithCwd a = Maybe FilePath -> FilePath -> [String] -> IO a +type ReadProcessWithCwdAndEnv = + String -> CallProcessWithCwdAndEnv String + +type CallProcessWithCwdAndEnv a = + Maybe FilePath -> [(String, String)] -> FilePath -> [String] -> IO a data QueryCache pt = QueryCache { qcProjInfo :: !(Maybe (ProjInfo pt)) @@ -472,6 +475,10 @@ data Programs = Programs -- ^ The path to the @stack@ program. , stackArgsBefore :: ![String] , stackArgsAfter :: ![String] + , stackEnv :: ![(String, String)] + -- ^ TODO: Stack doesn't support passing the compiler as a + -- commandline option so we meddle with PATH instead. We should + -- patch that upstream. , ghcProgram :: !FilePath -- ^ The path to the @ghc@ program. @@ -484,7 +491,7 @@ data Programs = Programs -- | By default all programs use their unqualified names, i.e. they will be -- searched for on @PATH@. defaultPrograms :: Programs -defaultPrograms = Programs "cabal" [] [] "stack" [] [] "ghc" "ghc-pkg" +defaultPrograms = Programs "cabal" [] [] "stack" [] [] [] "ghc" "ghc-pkg" data CompileOptions = CompileOptions { oVerbose :: Bool -- cgit v1.2.3