Commit 8d39bb1b authored by ijones's avatar ijones
Browse files

check for ~/.ghc-packages wherever we use it.

parent 4019ab6b
......@@ -65,7 +65,7 @@ import qualified Distribution.Simple.Register as D.S.R (hunitTests, installedPkg
import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig)
-- base
import Control.Monad(when)
import Control.Monad(when, unless)
import Directory(setCurrentDirectory, doesFileExist,
doesDirectoryExist, getCurrentDirectory)
import System.Cmd(system)
......@@ -111,7 +111,8 @@ tests :: [Test]
tests = [TestLabel "testing the HUnit package" $ TestCase $
do oldDir <- getCurrentDirectory
setCurrentDirectory "test/HUnit-1.0"
pkgConf <- GHC.localPackageConfig
(pkgConf, pkgConfExists) <- GHC.localPackageConfig
unless pkgConfExists $ writeFile pkgConf "[]\n"
system $ "ghc-pkg --config-file=" ++ pkgConf ++ " -r HUnit"
system "make clean"
system "make"
......@@ -141,7 +142,8 @@ tests = [TestLabel "testing the HUnit package" $ TestCase $
setCurrentDirectory oldDir,
TestLabel "package A: configure GHC, sdist" $ TestCase $
do pkgConf <- GHC.localPackageConfig
do (pkgConf, pkgConfExists) <- GHC.localPackageConfig
unless pkgConfExists $ writeFile pkgConf "[]\n"
system $ "ghc-pkg -r test --config-file=" ++ pkgConf
setCurrentDirectory "test/A"
system "make clean"
......
......@@ -60,7 +60,6 @@ import Distribution.Simple.Utils (rawSystemExit, setupMessage,
import Control.Monad (when, unless)
import Data.List(intersperse)
import System.Directory (doesFileExist)
import System.Environment (getEnv)
import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig)
......@@ -102,8 +101,7 @@ buildGHC :: FilePath -> PackageDescription -> LocalBuildInfo -> IO ()
buildGHC pref pkg_descr lbi = do
-- first, build the modules
pkgConf <- GHC.localPackageConfig
pkgConfExists <- doesFileExist pkgConf
(pkgConf, pkgConfExists) <- GHC.localPackageConfig
unless pkgConfExists $ writeFile pkgConf "[]\n"
let args = ["-package-conf", pkgConf]
++ constructGHCCmdLine pref pkg_descr lbi
......
......@@ -25,11 +25,15 @@ import Distribution.Simple.Utils(pathJoin)
import Text.PrettyPrint.HughesPJ
import System(getEnv)
import System.Directory (doesFileExist)
-- |Where ghc keeps the --user files.
localPackageConfig :: IO FilePath
-- |Where ghc keeps the --user files, the bool is for whether it exists
localPackageConfig :: IO (FilePath, Bool)
localPackageConfig = do u <- getEnv "HOME"
return $ pathJoin [u, ".ghc-packages"]
let f = pathJoin [u, ".ghc-packages"]
b <- doesFileExist f
return (f, b)
-- -----------------------------------------------------------------------------
-- GHC 6.2 PackageConfig type
......
......@@ -60,7 +60,7 @@ import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig
import System(getEnv)
import Control.Monad (when)
import Control.Monad (when, unless)
#ifdef DEBUG
import HUnit (Test)
......@@ -77,7 +77,8 @@ register pkg_descr lbi userInst = do
case compilerFlavor (compiler lbi) of
GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi
localConf <- GHC.localPackageConfig
(localConf, pkgConfExists) <- GHC.localPackageConfig
unless pkgConfExists $ writeFile localConf "[]\n"
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
rawSystemExit (compilerPkgTool (compiler lbi))
(["--auto-ghci-libs", "--add-package",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment