Skip to content

Commit d53b4fb

Browse files
committed
Don't use 'lookupEnv' in 'addLibraryPaths'
1 parent dd0eaeb commit d53b4fb

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

Cabal/Distribution/Simple/Test/ExeV10.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ runTest pkg_descr lbi flags suite = do
8787
clbi = LBI.getComponentLocalBuildInfo lbi
8888
(LBI.CTestName (PD.testName suite))
8989
paths <- LBI.depLibraryPaths True False lbi clbi
90-
addLibraryPath os paths shellEnv
90+
return (addLibraryPath os paths shellEnv)
9191
else return shellEnv
9292

9393
exit <- rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')

Cabal/Distribution/Simple/Test/LibV09.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ runTest pkg_descr lbi flags suite = do
9898
(PD.testName suite))
9999
paths <- LBI.depLibraryPaths
100100
True False lbi clbi
101-
addLibraryPath os paths shellEnv
101+
return (addLibraryPath os paths shellEnv)
102102
else return shellEnv
103103
rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
104104
-- these handles are closed automatically

Cabal/Distribution/Simple/Utils.hs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ module Distribution.Simple.Utils (
128128
wrapLine,
129129
) where
130130

131-
import Data.Functor
132-
( (<$>) )
133131
import Control.Monad
134132
( join, when, unless, filterM )
135133
import Control.Concurrent.MVar
@@ -149,7 +147,7 @@ import System.Directory
149147
, doesDirectoryExist, doesFileExist, removeFile, findExecutable
150148
, getModificationTime )
151149
import System.Environment
152-
( getProgName, lookupEnv )
150+
( getProgName )
153151
import System.Exit
154152
( exitWith, ExitCode(..) )
155153
import System.FilePath
@@ -703,16 +701,21 @@ isInSearchPath path = fmap (elem path) getSearchPath
703701
addLibraryPath :: OS
704702
-> [FilePath]
705703
-> [(String,String)]
706-
-> IO [(String,String)]
707-
addLibraryPath os paths env = do
708-
let libPaths = intercalate [searchPathSeparator] paths
709-
ldPath = case os of
710-
OSX -> "DYLD_LIBRARY_PATH"
711-
_ -> "LD_LIBRARY_PATH"
712-
ldEnv <- maybe libPaths (++ (searchPathSeparator:libPaths)) <$>
713-
lookupEnv ldPath
714-
715-
return (env ++ [(ldPath,ldEnv)])
704+
-> [(String,String)]
705+
addLibraryPath os paths = addEnv
706+
where
707+
pathsString = intercalate [searchPathSeparator] paths
708+
ldPath = case os of
709+
OSX -> "DYLD_LIBRARY_PATH"
710+
_ -> "LD_LIBRARY_PATH"
711+
712+
addEnv [] = [(ldPath,pathsString)]
713+
addEnv ((key,value):xs)
714+
| key == ldPath =
715+
if null value
716+
then (key,pathsString):xs
717+
else (key,value ++ (searchPathSeparator:pathsString)):xs
718+
| otherwise = (key,value):addEnv xs
716719

717720
----------------
718721
-- File globbing

cabal-install/Distribution/Client/Run.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ run verbosity lbi exe exeArgs = do
7272
clbi = getComponentLocalBuildInfo lbi
7373
(CExeName (exeName exe))
7474
paths <- depLibraryPaths True False lbi clbi
75-
addLibraryPath os paths env
75+
return (addLibraryPath os paths env)
7676
else return env
7777
notice verbosity $ "Running " ++ exeName exe ++ "..."
7878
rawSystemExitWithEnv verbosity path exeArgs env'

0 commit comments

Comments
 (0)