Commit 03bb97e0 authored by Simon Marlow's avatar Simon Marlow

Add -package-id, improve package shadowing behaviour and error messages

A few changes bundled together here:

 - Add -package-id flag, like -package but takes an
   InstalledPackageId as an argument (mainly for Cabal)
   (docs to follow)

 - Fix the shadowing behaviour: if we end up with
   two packages with the same name/version that came from
   different package databases, then one will shadow the
   other.  This may mean we have to disable other packages
   that depended on the now-shadowed package.  Lots of
   refactoring to ensure that we can get reasonable diagnostics when
   this happens

<command line>: cannot satisfy -package shadowdep: 
    shadowdep-1-XXX is unusable due to missing or recursive dependencies:
      shadow-1-XXX
    (use -v for more information)
parent b5f2a027
......@@ -77,7 +77,6 @@ import Config
import CmdLineParser
import Constants ( mAX_CONTEXT_REDUCTION_DEPTH )
import Panic
import UniqFM ( UniqFM )
import Util
import Maybes ( orElse )
import SrcLoc
......@@ -450,7 +449,7 @@ data DynFlags = DynFlags {
-- Package state
-- NB. do not modify this field, it is calculated by
-- Packages.initPackages and Packages.updatePackages.
pkgDatabase :: Maybe (UniqFM PackageConfig),
pkgDatabase :: Maybe [PackageConfig],
pkgState :: PackageState,
-- Temporary files
......@@ -546,6 +545,7 @@ doingTickyProfiling dflags = WayTicky `elem` wayNames dflags
data PackageFlag
= ExposePackage String
| ExposePackageId String
| HidePackage String
| IgnorePackage String
deriving Eq
......@@ -1622,6 +1622,7 @@ package_flags = [
, Flag "no-user-package-conf" (NoArg (unSetDynFlag Opt_ReadUserPackageConf))
Supported
, Flag "package-name" (HasArg (upd . setPackageName)) Supported
, Flag "package-id" (HasArg exposePackageId) Supported
, Flag "package" (HasArg exposePackage) Supported
, Flag "hide-package" (HasArg hidePackage) Supported
, Flag "hide-all-packages" (NoArg (setDynFlag Opt_HideAllPackages))
......@@ -2049,9 +2050,11 @@ addCmdlineHCInclude a = upd (\s -> s{cmdlineHcIncludes = a : cmdlineHcIncludes
extraPkgConf_ :: FilePath -> DynP ()
extraPkgConf_ p = upd (\s -> s{ extraPkgConfs = p : extraPkgConfs s })
exposePackage, hidePackage, ignorePackage :: String -> DynP ()
exposePackage, exposePackageId, hidePackage, ignorePackage :: String -> DynP ()
exposePackage p =
upd (\s -> s{ packageFlags = ExposePackage p : packageFlags s })
exposePackageId p =
upd (\s -> s{ packageFlags = ExposePackageId p : packageFlags s })
hidePackage p =
upd (\s -> s{ packageFlags = HidePackage p : packageFlags s })
ignorePackage p =
......
This diff is collapsed.
......@@ -1592,6 +1592,7 @@ showPackages = do
where showFlag (ExposePackage p) = text $ " -package " ++ p
showFlag (HidePackage p) = text $ " -hide-package " ++ p
showFlag (IgnorePackage p) = text $ " -ignore-package " ++ p
showFlag (ExposePackageId p) = text $ " -package-id " ++ p
showLanguages :: GHCi ()
showLanguages = do
......
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