diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-12-18 18:29:52 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-12-22 14:23:16 -0800 |
commit | 1faf1fcaebb2871f8085b01d0c6d19eec11dc808 (patch) | |
tree | ff61505ef4e115f5b13933b5e05a574d507629f5 /ghc | |
parent | 998739df630cbee7d006329a76786239e3e2c0be (diff) | |
download | haskell-1faf1fcaebb2871f8085b01d0c6d19eec11dc808.tar.gz |
Implement -hide-all-plugin-packages and -plugin-package(-id), fixing #11244
Summary:
The basic idea is that we have a new set of "exposed modules"
which are /only/ used for plugins, i.e. -fplugin Foo and
--frontend Foo. You can interact with this namespace
using the flags -plugin-package-id and -plugin-package.
By default, this namespace contains all modules in the
user namespace (as before), but you can toggle that using
-hide-all-plugin-packages.
There is one nasty hack: GhcMake respects -fplugin in
GHC_OPTIONS to make local plugins work correctly. It also
bails out of you have an import of a module which doesn't
exist locally or in the package database. The upshot is
that we need to be sure to check in the plugin modules
too, so we don't give a spurious failure when a plugin
is in the plugin namespace but not the main namespace.
A better way to fix this would be to distinguish between
plugin and normal dependencies in ModSummary.
I cheated a little and tweaked a few existing plugins
tests to exercise the new code paths.
TODO: Documentation
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: bgamari, austin, simonpj, duncan
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1661
GHC Trac Issues: #11244
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 986c119783..4fcbe6d7fe 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -2377,6 +2377,13 @@ setOptions wds = -- then, dynamic flags newDynFlags False minus_opts +packageFlagsChanged :: DynFlags -> DynFlags -> Bool +packageFlagsChanged idflags1 idflags0 = + packageFlags idflags1 /= packageFlags idflags0 || + ignorePackageFlags idflags1 /= ignorePackageFlags idflags0 || + pluginPackageFlags idflags1 /= pluginPackageFlags idflags0 || + trustFlags idflags1 /= trustFlags idflags0 + newDynFlags :: Bool -> [String] -> GHCi () newDynFlags interactive_only minus_opts = do let lopts = map noLoc minus_opts @@ -2390,8 +2397,7 @@ newDynFlags interactive_only minus_opts = do $ "Some flags have not been recognized: " ++ (concat . intersperse ", " $ map unLoc leftovers)) - when (interactive_only && - packageFlags idflags1 /= packageFlags idflags0) $ do + when (interactive_only && packageFlagsChanged idflags1 idflags0) $ do liftIO $ hPutStrLn stderr "cannot set package flags with :seti; use :set" GHC.setInteractiveDynFlags idflags1 installInteractivePrint (interactivePrint idflags1) False @@ -2405,7 +2411,7 @@ newDynFlags interactive_only minus_opts = do -- the new packages. hsc_env <- GHC.getSession let dflags2 = hsc_dflags hsc_env - when (packageFlags dflags2 /= packageFlags dflags0) $ do + when (packageFlagsChanged dflags2 dflags0) $ do when (verbosity dflags2 > 0) $ liftIO . putStrLn $ "package flags have changed, resetting and loading new packages..." |