Commit ef784c55 authored by Duncan Coutts's avatar Duncan Coutts Committed by Ben Gamari
Browse files

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:
parent a25bf267
......@@ -4410,13 +4410,15 @@ interpretPackageEnv dflags = do
parseEnvFile envfile = mapM_ parseEntry . lines
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 ()
......@@ -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
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