Skip to content

Commit

Permalink
Respect GHC_PACKAGE_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ttuegel committed Sep 1, 2016
1 parent 8cd7d24 commit 692ba50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
13 changes: 6 additions & 7 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ import Distribution.Text
import Distribution.Utils.NubList
import Language.Haskell.Extension

import Distribution.Compat.Environment ( lookupEnv )
import qualified Data.Map as Map
import Data.Version ( showVersion )
import System.Directory
( doesFileExist, getAppUserDataDirectory, createDirectoryIfMissing
, canonicalizePath, removeFile )
import System.FilePath ( (</>), (<.>), takeExtension
, takeDirectory, replaceExtension
, isRelative )
, isRelative, searchPathSeparator )
import qualified System.Info

-- -----------------------------------------------------------------------------
Expand Down Expand Up @@ -283,9 +284,11 @@ getInstalledPackages :: Verbosity -> Compiler -> PackageDBStack
-> ProgramConfiguration
-> IO InstalledPackageIndex
getInstalledPackages verbosity comp packagedbs conf = do
checkPackageDbEnvVar
checkPackageDbStack comp packagedbs
pkgss <- getInstalledPackages' verbosity packagedbs conf
envPackageDBs <- maybe []
(map SpecificPackageDB . unintersperse searchPathSeparator)
<$> lookupEnv "GHC_PACKAGE_PATH"
pkgss <- getInstalledPackages' verbosity (envPackageDBs ++ packagedbs) conf
index <- toPackageIndex verbosity pkgss conf
return $! hackRtsPackage index

Expand Down Expand Up @@ -351,10 +354,6 @@ getUserPackageDB _verbosity ghcProg (Platform arch os) = do
| otherwise = "package.conf"
Just ghcVersion = programVersion ghcProg

checkPackageDbEnvVar :: IO ()
checkPackageDbEnvVar =
Internal.checkPackageDbEnvVar "GHC" "GHC_PACKAGE_PATH"

checkPackageDbStack :: Compiler -> PackageDBStack -> IO ()
checkPackageDbStack comp = if flagPackageConf implInfo
then checkPackageDbStackPre76
Expand Down
14 changes: 7 additions & 7 deletions Cabal/Distribution/Simple/GHCJS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ import Language.Haskell.Extension
import qualified Data.Map as Map
import System.Directory ( doesFileExist )
import System.FilePath ( (</>), (<.>), takeExtension
, takeDirectory, replaceExtension )
, takeDirectory, replaceExtension
, searchPathSeparator )
import Distribution.Compat.Environment ( lookupEnv )

configure :: Verbosity -> Maybe FilePath -> Maybe FilePath
-> ProgramConfiguration
Expand Down Expand Up @@ -187,9 +189,11 @@ getPackageDBContents verbosity packagedb conf = do
getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
-> IO InstalledPackageIndex
getInstalledPackages verbosity packagedbs conf = do
checkPackageDbEnvVar
checkPackageDbStack packagedbs
pkgss <- getInstalledPackages' verbosity packagedbs conf
envPackageDBs <- maybe []
(map SpecificPackageDB . unintersperse searchPathSeparator)
<$> lookupEnv "GHCJS_PACKAGE_PATH"
pkgss <- getInstalledPackages' verbosity (envPackageDBs ++ packagedbs) conf
index <- toPackageIndex verbosity pkgss conf
return $! index

Expand All @@ -209,10 +213,6 @@ toPackageIndex verbosity pkgss conf = do
where
Just ghcjsProg = lookupProgram ghcjsProgram conf

checkPackageDbEnvVar :: IO ()
checkPackageDbEnvVar =
Internal.checkPackageDbEnvVar "GHCJS" "GHCJS_PACKAGE_PATH"

checkPackageDbStack :: PackageDBStack -> IO ()
checkPackageDbStack (GlobalPackageDB:rest)
| GlobalPackageDB `notElem` rest = return ()
Expand Down

0 comments on commit 692ba50

Please sign in to comment.