Commit 3793d3b2 authored by Luite Stegeman's avatar Luite Stegeman Committed by Austin Seipp
Browse files

Export more Packages functions

This patch exports functions for finding the active package
databases and their locations from the Packages module. This
allows GHC API clients to use other tools, like Cabal, to gather
package information that's not directly available from the
binary package db.

Reviewers: duncan, austin

Reviewed By: austin

Subscribers: thomie, carter

Differential Revision:
parent 3e4f49b0
......@@ -11,6 +11,10 @@ module Packages (
-- * Reading the package config, and processing cmdline args
-- * Querying the package config
......@@ -328,6 +332,12 @@ initPackages dflags = do
readPackageConfigs :: DynFlags -> IO [PackageConfig]
readPackageConfigs dflags = do
conf_refs <- getPackageConfRefs dflags
confs <- liftM catMaybes $ mapM (resolvePackageConfig dflags) conf_refs
liftM concat $ mapM (readPackageConfig dflags) confs
getPackageConfRefs :: DynFlags -> IO [PkgConfRef]
getPackageConfRefs dflags = do
let system_conf_refs = [UserPkgConf, GlobalPkgConf]
e_pkg_path <- tryIO (getEnv "GHC_PACKAGE_PATH")
......@@ -339,13 +349,10 @@ readPackageConfigs dflags = do
| otherwise
-> map PkgConfFile (splitSearchPath path)
let conf_refs = reverse (extraPkgConfs dflags base_conf_refs)
return $ reverse (extraPkgConfs dflags base_conf_refs)
-- later packages shadow earlier ones. extraPkgConfs
-- is in the opposite order to the flags on the
-- command line.
confs <- liftM catMaybes $ mapM (resolvePackageConfig dflags) conf_refs
liftM concat $ mapM (readPackageConfig dflags) confs
resolvePackageConfig :: DynFlags -> PkgConfRef -> IO (Maybe FilePath)
resolvePackageConfig dflags GlobalPkgConf = return $ Just (systemPackageConfig dflags)
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