More for GHC 6.10

This commit is contained in:
alson
2009-01-31 23:29:21 +00:00
parent 9d431c68a3
commit a0391e5cd3
3 changed files with 9 additions and 35 deletions

View File

@ -52,11 +52,11 @@ module System.Plugins.Env (
import System.Plugins.LoadTypes (Module)
import System.Plugins.PackageAPI {- everything -}
import System.Plugins.Consts ( ghcLibraryPath, sysPkgConf, sysPkgSuffix )
import System.Plugins.Consts ( sysPkgConf, sysPkgSuffix )
import Data.IORef ( writeIORef, readIORef, newIORef, IORef() )
import Data.Maybe ( isJust, isNothing, fromMaybe )
import Data.List ( isPrefixOf, isInfixOf, nub )
import Data.List ( isInfixOf, nub )
import System.IO.Unsafe ( unsafePerformIO )
import System.IO ( hGetContents )
@ -311,35 +311,10 @@ grabDefaultPkgConf = do
--
readPackageConf :: FilePath -> IO [PackageConfig]
readPackageConf f = do
-- s <- readFile f
-- let p = map parseInstalledPackageInfo $ splitPkgs s
-- return $ flip map p $ \p' -> case p' of
-- ParseFailed e -> error $ show e
-- ParseOk _ c -> expand_libdir c
pc <- configureAllKnownPrograms silent defaultProgramConfiguration
pkgIndex <- getInstalledPackages silent (SpecificPackageDB f) pc
return $ allPackages pkgIndex
where
expand_libdir :: PackageConfig -> PackageConfig
expand_libdir pk =
let pk' = updImportDirs (\idirs -> map expand idirs) pk
pk'' = updLibraryDirs (\ldirs -> map expand ldirs) pk'
in pk''
expand :: FilePath -> FilePath
expand s | "$libdir" `isPrefixOf` s = ghcLibraryPath ++ drop 7 s
expand s = s
splitPkgs :: String -> [String]
splitPkgs = map unlines . splitWith ("---" ==) . lines
where
splitWith :: (a -> Bool) -> [a] -> [[a]]
splitWith p xs = ys : case zs of
[] -> []
_:ws -> splitWith p ws
where (ys,zs) = break p xs
-- -----------------------------------------------------------
-- Static package management stuff. A static package is linked with the base
-- application and we should therefore not link with any of the DLLs it requires.