diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2018-12-11 13:24:12 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-12-11 14:23:22 -0500 |
commit | da05d79d03e5e03e391b381f23c46fc02957abf7 (patch) | |
tree | 4506d0f46dc5df4293ae1933d87b1367be0de831 /compiler/iface | |
parent | 9e763afa9f1f75eacce24291f298f32527591b14 (diff) | |
download | haskell-da05d79d03e5e03e391b381f23c46fc02957abf7.tar.gz |
Support registering Plugins through the GHC API
This allows tooling using the GHC API to use plugins internally.
Hopefully this will make it possible to decouple the development of
useful plugins from (currently) kitchen-sink type tooling projects
such as ghc-mod or HIE -- at least to some extent.
Test Plan: validate
Reviewers: bgamari, mpickering
Subscribers: mpickering, alanz, rwbarton, carter
GHC Trac Issues: #15826
Differential Revision: https://phabricator.haskell.org/D5278
Diffstat (limited to 'compiler/iface')
-rw-r--r-- | compiler/iface/MkIface.hs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index aba14baa2d..7b66472d7a 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -119,7 +119,8 @@ import Data.Ord import Data.IORef import System.Directory import System.FilePath -import Plugins ( PluginRecompile(..), Plugin(..), LoadedPlugin(..)) +import Plugins ( PluginRecompile(..), PluginWithArgs(..), LoadedPlugin(..), + pluginRecompile', plugins ) --Qualified import so we can define a Semigroup instance -- but it doesn't clash with Outputable.<> @@ -189,7 +190,7 @@ mkIfaceTc hsc_env maybe_old_fingerprint safe_mode mod_details = do let used_names = mkUsedNames tc_result let pluginModules = - map lpModule (plugins (hsc_dflags hsc_env)) + map lpModule (cachedPlugins (hsc_dflags hsc_env)) deps <- mkDependencies (thisInstalledUnitId (hsc_dflags hsc_env)) (map mi_module pluginModules) tc_result @@ -1324,17 +1325,16 @@ checkPlugins :: HscEnv -> ModIface -> IfG RecompileRequired checkPlugins hsc iface = liftIO $ do -- [(ModuleName, Plugin, [Opts])] let old_fingerprint = mi_plugin_hash iface - loaded_plugins = plugins (hsc_dflags hsc) - res <- mconcat <$> mapM checkPlugin loaded_plugins + res <- mconcat <$> mapM pluginRecompile' (plugins (hsc_dflags hsc)) return (pluginRecompileToRecompileRequired old_fingerprint res) fingerprintPlugins :: HscEnv -> IO Fingerprint fingerprintPlugins hsc_env = do - fingerprintPlugins' (plugins (hsc_dflags hsc_env)) + fingerprintPlugins' $ plugins(hsc_dflags hsc_env) -fingerprintPlugins' :: [LoadedPlugin] -> IO Fingerprint +fingerprintPlugins' :: [PluginWithArgs] -> IO Fingerprint fingerprintPlugins' plugins = do - res <- mconcat <$> mapM checkPlugin plugins + res <- mconcat <$> mapM pluginRecompile' plugins return $ case res of NoForceRecompile -> fingerprintString "NoForceRecompile" ForceRecompile -> fingerprintString "ForceRecompile" @@ -1344,10 +1344,6 @@ fingerprintPlugins' plugins = do (MaybeRecompile fp) -> fp - -checkPlugin :: LoadedPlugin -> IO PluginRecompile -checkPlugin (LoadedPlugin plugin _ opts) = pluginRecompile plugin opts - pluginRecompileToRecompileRequired :: Fingerprint -> PluginRecompile -> RecompileRequired pluginRecompileToRecompileRequired old_fp pr = case pr of |