[commit: ghc] master: Fix handling of package-db entries in .ghc.environment files, etc. (ef784c5)
git at git.haskell.org
git at git.haskell.org
Wed Aug 31 17:19:15 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ef784c551ef9b64c3c0b32c73f54bbdb747a8188/ghc
>---------------------------------------------------------------
commit ef784c551ef9b64c3c0b32c73f54bbdb747a8188
Author: Duncan Coutts <duncan at well-typed.com>
Date: Tue Aug 30 16:59:17 2016 -0400
Fix handling of package-db entries in .ghc.environment files, etc.
Previously interpreting the content of the .ghc.env files was done
after the step that loaded the available package dbs. This meant that
setting the package db flags was ineffective. This patch moves
interpreting the env files before loading of the package dbs.
Also, the package-db entries refer to files. Allow spaces in these file
names. Also treat as comments lines beginning with "--".
These are pretty minor fixes in a feature that up 'til now has been
essentially unused (witness no bug report about it), so there's very
low risk here. If we can get this into 8.0.2 then cabal can start
generating the .ghc.environment files, otherwise it cannot as it needs
the working package-db entries, to be able to refer to local package
dbs in the build tree (or cabal nix store).
Test Plan:
Manually create example .ghc.env files
run ghci; :show packages
Done this. It works.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2476
>---------------------------------------------------------------
ef784c551ef9b64c3c0b32c73f54bbdb747a8188
compiler/main/DynFlags.hs | 4 +++-
compiler/main/Packages.hs | 7 +++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index c1ccfcd..4081ac4 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -4410,13 +4410,15 @@ interpretPackageEnv dflags = do
parseEnvFile envfile = mapM_ parseEntry . lines
where
parseEntry str = case words str of
- ["package-db", db] -> addPkgConfRef (PkgConfFile (envdir </> db))
+ ("package-db": _) -> addPkgConfRef (PkgConfFile (envdir </> db))
-- relative package dbs are interpreted relative to the env file
where envdir = takeDirectory envfile
+ db = drop 11 str
["clear-package-db"] -> clearPkgConf
["global-package-db"] -> addPkgConfRef GlobalPkgConf
["user-package-db"] -> addPkgConfRef UserPkgConf
["package-id", pkgid] -> exposePackageId pkgid
+ (('-':'-':_):_) -> return () -- comments
-- and the original syntax introduced in 7.10:
[pkgid] -> exposePackageId pkgid
[] -> return ()
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index ecec982..0c91af2 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -339,7 +339,8 @@ listPackageConfigMap dflags = eltsUDFM (pkgIdMap (pkgState dflags))
-- 'pkgState' in 'DynFlags' and return a list of packages to
-- link in.
initPackages :: DynFlags -> IO (DynFlags, [UnitId])
-initPackages dflags = do
+initPackages dflags0 = do
+ dflags <- interpretPackageEnv dflags0
pkg_db <-
case pkgDatabase dflags of
Nothing -> readPackageConfigs dflags
@@ -879,9 +880,7 @@ mkPackageState
UnitId) -- this package, might be modified if the current
-- package is a wired-in package.
-mkPackageState dflags0 dbs preload0 = do
- dflags <- interpretPackageEnv dflags0
-
+mkPackageState dflags dbs preload0 = do
-- Compute the unit id
let this_package = thisPackage dflags
More information about the ghc-commits
mailing list