Commit 4fe78fc6 authored by ijones's avatar ijones
Browse files

cleaned up use of ~/.ghc-packages

parent 91398426
......@@ -62,6 +62,8 @@ import Distribution.Simple.Utils(pathJoin)
import qualified Distribution.Simple.Configure as D.S.C (hunitTests)
import qualified Distribution.Simple.Register as D.S.R (hunitTests)
import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig)
-- base
import Control.Monad(when)
import Directory(setCurrentDirectory, doesFileExist,
......@@ -110,17 +112,18 @@ tests = [TestLabel "testing the HUnit package" $ TestCase $
do oldDir <- getCurrentDirectory
setCurrentDirectory "test/HUnit-1.0"
-- assertCmd "make semiclean" "make semiclean"
system "ghc-pkg --config-file=$HOME/.ghc-packages -r HUnit-1.0"
pkgConf <- GHC.localPackageConfig
system $ "ghc-pkg --config-file=" ++ pkgConf ++ " -r HUnit-1.0"
assertCmd "./setup configure --prefix=\",tmp\"" "hunit configure"
assertCmd "./setup build" "hunit build"
assertCmd "./setup install --user" "hunit install"
assertCmd "ghc -package-conf $HOME/.ghc-packages -package HUnit-1.0 HUnitTester.hs -o ./hunitTest" "compile w/ hunit"
assertCmd ("ghc -package-conf " ++ pkgConf ++ " -package HUnit-1.0 HUnitTester.hs -o ./hunitTest" "compile w/ hunit"
assertCmd "./hunitTest" "hunit test"
assertCmd "ghc-pkg --config-file=$HOME/.ghc-packages -r HUnit-1.0" "package remove"
assertCmd ("ghc-pkg --config-file=" ++ pkgConf ++ " -r HUnit-1.0" "package remove"
setCurrentDirectory oldDir,
TestLabel "configure GHC, sdist" $ TestCase $
do system "ghc-pkg -r test-1.0 --config-file=$HOME/.ghc-packages"
do system $ "ghc-pkg -r test-1.0 --config-file=" ++ pkgConf
setCurrentDirectory "test/A"
dirE1 <- doesDirectoryExist ",tmp"
when dirE1 (system "rm -r ,tmp">>return())
......
......@@ -61,6 +61,7 @@ import Distribution.Simple.Utils (rawSystemExit, setupMessage,
import Control.Monad (when)
import Data.List(intersperse, nub)
import System.Environment (getEnv)
import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig)
#ifdef DEBUG
import HUnit (Test)
......@@ -95,8 +96,8 @@ buildGHC :: FilePath -> PackageDescription -> LocalBuildInfo -> IO ()
buildGHC pref pkg_descr lbi = do
-- first, build the modules
home <- getEnv "HOME"
let args = ["-package-conf", home ++ "/.ghc-packages"]
pkgConf <- GHC.localPackageConfig
let args = ["-package-conf", pkgConf]
++ constructGHCCmdLine pref pkg_descr lbi
rawSystemExit (compilerPath (compiler lbi)) args
......
......@@ -14,15 +14,22 @@ module Distribution.Simple.GHCPackageConfig (
GHCPackageConfig(..),
mkGHCPackageConfig,
defaultGHCPackageConfig,
showGHCPackageConfig
showGHCPackageConfig,
localPackageConfig
) where
import Distribution.Package (PackageDescription(..), showPackageId)
import Distribution.Simple.Configure (LocalBuildInfo(..))
import Distribution.Simple.Install (mkImportDir)
import Distribution.Simple.Utils(pathJoin)
import Text.PrettyPrint.HughesPJ
import System(getEnv)
-- |Where ghc keeps the --user files.
localPackageConfig :: IO FilePath
localPackageConfig = do u <- getEnv "HOME"
return $ pathJoin [u, ".ghc-packages"]
-- -----------------------------------------------------------------------------
-- GHC 6.2 PackageConfig type
......
......@@ -55,6 +55,7 @@ import Distribution.Setup (CompilerFlavor(..), Compiler(..))
import Distribution.Package (PackageDescription, package, showPackageId)
import Distribution.Simple.Utils (setupMessage, rawSystemExit, die)
import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageConfig)
import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig)
import System(getEnv)
......@@ -75,11 +76,11 @@ register pkg_descr lbi userInst = do
case compilerFlavor (compiler lbi) of
GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi
localConf <- GHC.localPackageConfig
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
home <- getEnv "HOME"
rawSystemExit (compilerPkgTool (compiler lbi))
(["--add-package", "--input-file="++installedPkgConfigFile]
++ (if userInst then ["--config-file=" ++ home ++ "/.ghc-packages"] else []))
++ (if userInst then ["--config-file=" ++ localConf] else []))
_ -> die ("only registering with GHC is implemented")
installedPkgConfigFile :: String
......
* misc
** make a library from the FileUtils, look at Python's os.path.
** add en.wikipedia.org/wiki/Cabal to web page
** clean up ~/.ghc-packages location...
** if the configure with --user make sure it installs with --user!
** Possibly create a (native?) zib library?
** port code to windows
** ./Setup.lhs build for nhc
......
......@@ -7,6 +7,7 @@ clean:
find . -name "*.hi" |xargs rm -f
check: all
./setup configure --user --prefix=/tmp/foo
./setup build
./setup install --install-prefix=/tmp/bar
ls /tmp/bar*
# install w/ register!
......
Supports Markdown
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