[commit: ghc] master: Export more Packages functions (3793d3b)
git at git.haskell.org
git at git.haskell.org
Fri Nov 21 17:32:25 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3793d3b2b0199e50f6066f948a7c94df0c9f3580/ghc
>---------------------------------------------------------------
commit 3793d3b2b0199e50f6066f948a7c94df0c9f3580
Author: Luite Stegeman <stegeman at gmail.com>
Date: Fri Nov 21 11:33:00 2014 -0600
Export more Packages functions
Summary:
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: https://phabricator.haskell.org/D514
>---------------------------------------------------------------
3793d3b2b0199e50f6066f948a7c94df0c9f3580
compiler/main/Packages.lhs | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
index 40b5e24..2151902 100644
--- a/compiler/main/Packages.lhs
+++ b/compiler/main/Packages.lhs
@@ -11,6 +11,10 @@ module Packages (
-- * Reading the package config, and processing cmdline args
PackageState(preloadPackages),
initPackages,
+ readPackageConfigs,
+ getPackageConfRefs,
+ resolvePackageConfig,
+ readPackageConfig,
-- * Querying the package config
lookupPackage,
@@ -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)
More information about the ghc-commits
mailing list