on master help sign in
Combine all artifacts output by damlc in .daml (#1959)
c1efd35Moritz Kiefer
src/Development/IDE/Core/Compile.hs+6−8
@@ -46,7 +46,7 @@ import TidyPgm
46import qualified GHC.LanguageExtensions as LangExt
46import qualified GHC.LanguageExtensions as LangExt
47
47
48import Control.DeepSeq
48import Control.DeepSeq
49−import Control.Monad
49+import Control.Monad.Extra
50import Control.Monad.Trans.Except
50import Control.Monad.Trans.Except
51import qualified Data.Text as T
51import qualified Data.Text as T
52import Data.IORef
52import Data.IORef
@@ -127,7 +127,7 @@ typecheckModule opt packageState deps pm =
127 setupEnv deps
127 setupEnv deps
128 (warnings, tcm) <- withWarnings $ \tweak ->
128 (warnings, tcm) <- withWarnings $ \tweak ->
129 GHC.typecheckModule pm{pm_mod_summary = tweak $ pm_mod_summary pm}
129 GHC.typecheckModule pm{pm_mod_summary = tweak $ pm_mod_summary pm}
130− tcm2 <- mkTcModuleResult (WriteInterface $ optWriteIface opt) tcm
130+ tcm2 <- mkTcModuleResult (optIfaceDir opt) tcm
131 return (warnings, tcm2)
131 return (warnings, tcm2)
132
132
133-- | Compile a single type-checked module to a 'CoreModule' value, or
133-- | Compile a single type-checked module to a 'CoreModule' value, or
@@ -197,18 +197,16 @@ moduleImportPaths pm
197 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
197 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
198
198
199
199
200−newtype WriteInterface = WriteInterface Bool
201−
202mkTcModuleResult
200mkTcModuleResult
203 :: GhcMonad m
201 :: GhcMonad m
204− => WriteInterface
202+ => InterfaceDirectory
205 -> TypecheckedModule
203 -> TypecheckedModule
206 -> m TcModuleResult
204 -> m TcModuleResult
207−mkTcModuleResult (WriteInterface writeIface) tcm = do
205+mkTcModuleResult (InterfaceDirectory mbIfaceDir) tcm = do
208 session <- getSession
206 session <- getSession
209 (iface,_) <- liftIO $ mkIfaceTc session Nothing Sf_None details tcGblEnv
207 (iface,_) <- liftIO $ mkIfaceTc session Nothing Sf_None details tcGblEnv
210− liftIO $ when writeIface $ do
208+ liftIO $ whenJust mbIfaceDir $ \ifaceDir -> do
211− let path = ".interfaces" </> file tcm
209+ let path = ifaceDir </> file tcm
212 createDirectoryIfMissing True (takeDirectory path)
210 createDirectoryIfMissing True (takeDirectory path)
213 writeIfaceFile (hsc_dflags session) (replaceExtension path ".hi") iface
211 writeIfaceFile (hsc_dflags session) (replaceExtension path ".hi") iface
214 -- For now, we write .hie files whenever we write .hi files which roughly corresponds to
212 -- For now, we write .hie files whenever we write .hi files which roughly corresponds to
src/Development/IDE/Types/Options.hs+6−2
@@ -7,6 +7,7 @@
7module Development.IDE.Types.Options
7module Development.IDE.Types.Options
8 ( IdeOptions(..)
8 ( IdeOptions(..)
9 , IdePkgLocationOptions(..)
9 , IdePkgLocationOptions(..)
10+ , InterfaceDirectory(..)
10 , defaultIdeOptions
11 , defaultIdeOptions
11 ) where
12 ) where
12
13
@@ -15,13 +16,16 @@ import GHC hiding (parseModule, typecheckModule)
15import GhcPlugins as GHC hiding (fst3, (<>))
16import GhcPlugins as GHC hiding (fst3, (<>))
16
17
17
18
19+-- | If `Nothing` we do not write .hi files.
20+newtype InterfaceDirectory = InterfaceDirectory (Maybe FilePath)
21+
18data IdeOptions = IdeOptions
22data IdeOptions = IdeOptions
19 { optPreprocessor :: GHC.ParsedSource -> ([(GHC.SrcSpan, String)], GHC.ParsedSource)
23 { optPreprocessor :: GHC.ParsedSource -> ([(GHC.SrcSpan, String)], GHC.ParsedSource)
20 , optGhcSession :: Action HscEnv
24 , optGhcSession :: Action HscEnv
21 -- ^ Setup a GHC session using a given package state. If a `ParsedModule` is supplied,
25 -- ^ Setup a GHC session using a given package state. If a `ParsedModule` is supplied,
22 -- the import path should be setup for that module.
26 -- the import path should be setup for that module.
23 , optPkgLocationOpts :: IdePkgLocationOptions
27 , optPkgLocationOpts :: IdePkgLocationOptions
24− , optWriteIface :: Bool
28+ , optIfaceDir :: InterfaceDirectory
25 , optExtensions :: [String]
29 , optExtensions :: [String]
26
30
27 , optThreads :: Int
31 , optThreads :: Int
@@ -33,7 +37,7 @@ data IdeOptions = IdeOptions
33defaultIdeOptions :: Action HscEnv -> IdeOptions
37defaultIdeOptions :: Action HscEnv -> IdeOptions
34defaultIdeOptions session = IdeOptions
38defaultIdeOptions session = IdeOptions
35 {optPreprocessor = (,) []
39 {optPreprocessor = (,) []
36− ,optWriteIface = False
40+ ,optIfaceDir = InterfaceDirectory Nothing
37 ,optGhcSession = session
41 ,optGhcSession = session
38 ,optExtensions = ["hs"]
42 ,optExtensions = ["hs"]
39 ,optPkgLocationOpts = defaultIdePkgLocationOptions
43 ,optPkgLocationOpts = defaultIdePkgLocationOptions