File tree Expand file tree Collapse file tree 6 files changed +18
-0
lines changed Expand file tree Collapse file tree 6 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1111* ` stack exec ` accepts the ` --no-ghc-package-path ` parameter
1212* Don't require build plan to upload [ #400 ] ( https://github.com/commercialhaskell/stack/issues/400 )
1313* Specifying test components only builds/runs those tests [ #398 ] ( https://github.com/commercialhaskell/stack/issues/398 )
14+ * ` STACK_EXE ` environment variable
1415
1516Bug fixes:
1617
Original file line number Diff line number Diff line change @@ -521,6 +521,7 @@ withSingleContext ActionContext {..} ExecuteEnv {..} task@Task {..} inner0 =
521521 menv <- liftIO $ configEnvOverride config EnvSettings
522522 { esIncludeLocals = taskLocation task == Local
523523 , esIncludeGhcPackagePath = False
524+ , esStackExe = False
524525 }
525526 exeName <- liftIO $ join $ findExecutable menv " runhaskell"
526527 distRelativeDir' <- distRelativeDir
@@ -716,6 +717,7 @@ singleTest ac ee task =
716717 menv <- liftIO $ configEnvOverride config EnvSettings
717718 { esIncludeLocals = taskLocation task == Local
718719 , esIncludeGhcPackagePath = True
720+ , esStackExe = True
719721 }
720722 if exists
721723 then do
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ defaultEnvSettings :: EnvSettings
2323defaultEnvSettings = EnvSettings
2424 { esIncludeLocals = True
2525 , esIncludeGhcPackagePath = True
26+ , esStackExe = True
2627 }
2728
2829-- | Execute a process within the Stack configured environment.
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ import Stack.Solver (getGhcVersion)
5656import Stack.Types
5757import Stack.Types.StackT
5858import System.Directory (doesDirectoryExist , createDirectoryIfMissing , removeFile )
59+ import System.Environment (getExecutablePath )
5960import System.Exit (ExitCode (ExitSuccess ))
6061import System.FilePath (searchPathSeparator )
6162import qualified System.FilePath as FP
@@ -170,6 +171,8 @@ setupEnv = do
170171 , [toFilePath globalDB]
171172 ]
172173
174+ executablePath <- liftIO getExecutablePath
175+
173176 envRef <- liftIO $ newIORef Map. empty
174177 let getEnvOverride' es = do
175178 m <- readIORef envRef
@@ -182,6 +185,10 @@ setupEnv = do
182185 then Map. insert " GHC_PACKAGE_PATH" (mkGPP (esIncludeLocals es))
183186 else id )
184187
188+ $ (if esStackExe es
189+ then Map. insert " STACK_EXE" (T. pack executablePath)
190+ else id )
191+
185192 -- For reasoning and duplication, see: https://github.com/fpco/stack/issues/70
186193 $ Map. insert " HASKELL_PACKAGE_SANDBOX" (T. pack $ toFilePath deps)
187194 $ Map. insert " HASKELL_PACKAGE_SANDBOXES"
Original file line number Diff line number Diff line change @@ -158,6 +158,8 @@ data EnvSettings = EnvSettings
158158 -- ^ include local project bin directory, GHC_PACKAGE_PATH, etc
159159 , esIncludeGhcPackagePath :: ! Bool
160160 -- ^ include the GHC_PACKAGE_PATH variable
161+ , esStackExe :: ! Bool
162+ -- ^ set the STACK_EXE variable to the current executable name
161163 }
162164 deriving (Show , Eq , Ord )
163165
@@ -689,6 +691,7 @@ getMinimalEnvOverride = do
689691 liftIO $ configEnvOverride config EnvSettings
690692 { esIncludeLocals = False
691693 , esIncludeGhcPackagePath = False
694+ , esStackExe = False
692695 }
693696
694697data ProjectAndConfigMonoid
Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ main =
151151 <*> boolFlags True
152152 " ghc-package-path"
153153 " setting the GHC_PACKAGE_PATH variable for the subprocess"
154+ idm
155+ <*> boolFlags True
156+ " stack-exe"
157+ " setting the STACK_EXE environment variable to the path for the stack executable"
154158 idm))
155159 addCommand " ghc"
156160 " Run ghc"
You can’t perform that action at this time.
0 commit comments