summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2016-08-30 16:59:17 -0400
committerBen Gamari <ben@smart-cactus.org>2016-08-30 17:50:51 -0400
commitef784c551ef9b64c3c0b32c73f54bbdb747a8188 (patch)
tree47b9404e0e1e24f69ba6f1c0500d6b95e5e76cb0
parenta25bf2673d0f6db5f454619ddf91f974cace4e8b (diff)
downloadhaskell-ef784c551ef9b64c3c0b32c73f54bbdb747a8188.tar.gz
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
-rw-r--r--compiler/main/DynFlags.hs4
-rw-r--r--compiler/main/Packages.hs7
2 files changed, 6 insertions, 5 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index c1ccfcd95c..4081ac4684 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 ecec982422..0c91af284d 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