Skip to content

Commit

Permalink
MERGED: Get the correct value of $topdir on Windows with GHC 6.12.1
Browse files Browse the repository at this point in the history
Ian Lynagh <igloo@earth.li>**20091230204613

This doesn't full merge the patch, as partly it changed an interface in
order to refactor.
  • Loading branch information
igfoo committed Feb 4, 2010
1 parent e7c1b7f commit 88b08b3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ import Distribution.Text
import Language.Haskell.Extension (Extension(..))

import Control.Monad ( unless, when )
import Data.Char ( isSpace )
import Data.List
import Data.Maybe ( catMaybes )
import Data.Monoid ( Monoid(..) )
Expand Down Expand Up @@ -353,6 +354,7 @@ getInstalledPackages :: Verbosity -> PackageDBStack -> ProgramConfiguration
getInstalledPackages verbosity packagedbs conf = do
checkPackageDbStack packagedbs
pkgss <- getInstalledPackages' verbosity packagedbs conf
topDir <- ghcLibDir' verbosity ghcProg
let indexes = [ PackageIndex.fromList (map (substTopDir topDir) pkgs)
| (_, pkgs) <- pkgss ]
return $! hackRtsPackage (mconcat indexes)
Expand All @@ -362,8 +364,6 @@ getInstalledPackages verbosity packagedbs conf = do
-- paths. We need to substitute the right value in so that when
-- we, for example, call gcc, we have proper paths to give it
Just ghcProg = lookupProgram ghcProgram conf
compilerDir = takeDirectory (programPath ghcProg)
topDir = takeDirectory compilerDir

hackRtsPackage index =
case PackageIndex.lookupPackageName index (PackageName "rts") of
Expand All @@ -372,6 +372,11 @@ getInstalledPackages verbosity packagedbs conf = do
_ -> index -- No (or multiple) ghc rts package is registered!!
-- Feh, whatever, the ghc testsuite does some crazy stuff.

ghcLibDir' :: Verbosity -> ConfiguredProgram -> IO FilePath
ghcLibDir' verbosity ghcProg =
(reverse . dropWhile isSpace . reverse) `fmap`
rawSystemProgramStdout verbosity ghcProg ["--print-libdir"]

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

0 comments on commit 88b08b3

Please sign in to comment.