on master help sign in
Combine all artifacts output by damlc in .daml (#1959)

Fixes #1241

commitc1efd35bd0a711b8e617d1c1ca66a9c617060d41 authorMoritz Kiefer <moritz.kiefer@purelyfunctional.org> dateMon 1 Jul 2019, 17:07 (7 years ago) parent66d5bf1
2 files changed+12−10
src/Development/IDE/Core/Compile.hs+6−8 src/Development/IDE/Types/Options.hs+6−2
src/Development/IDE/Core/Compile.hs+6−8
@@ -46,7 +46,7 @@ import TidyPgm
4646import qualified GHC.LanguageExtensions as LangExt
4747
4848import Control.DeepSeq
49−import Control.Monad
49+import Control.Monad.Extra
5050import Control.Monad.Trans.Except
5151import qualified Data.Text as T
5252import Data.IORef
@@ -127,7 +127,7 @@ typecheckModule opt packageState deps pm =
127127 setupEnv deps
128128 (warnings, tcm) <- withWarnings $ \tweak ->
129129 GHC.typecheckModule pm{pm_mod_summary = tweak $ pm_mod_summary pm}
130− tcm2 <- mkTcModuleResult (WriteInterface $ optWriteIface opt) tcm
130+ tcm2 <- mkTcModuleResult (optIfaceDir opt) tcm
131131 return (warnings, tcm2)
132132
133133-- | Compile a single type-checked module to a 'CoreModule' value, or
@@ -197,18 +197,16 @@ moduleImportPaths pm
197197 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
198198
199199
200−newtype WriteInterface = WriteInterface Bool
201−
202200mkTcModuleResult
203201 :: GhcMonad m
204− => WriteInterface
202+ => InterfaceDirectory
205203 -> TypecheckedModule
206204 -> m TcModuleResult
207−mkTcModuleResult (WriteInterface writeIface) tcm = do
205+mkTcModuleResult (InterfaceDirectory mbIfaceDir) tcm = do
208206 session <- getSession
209207 (iface,_) <- liftIO $ mkIfaceTc session Nothing Sf_None details tcGblEnv
210− liftIO $ when writeIface $ do
211− let path = ".interfaces" </> file tcm
208+ liftIO $ whenJust mbIfaceDir $ \ifaceDir -> do
209+ let path = ifaceDir </> file tcm
212210 createDirectoryIfMissing True (takeDirectory path)
213211 writeIfaceFile (hsc_dflags session) (replaceExtension path ".hi") iface
214212 -- 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 @@
77module Development.IDE.Types.Options
88 ( IdeOptions(..)
99 , IdePkgLocationOptions(..)
10+ , InterfaceDirectory(..)
1011 , defaultIdeOptions
1112 ) where
1213
@@ -15,13 +16,16 @@ import GHC hiding (parseModule, typecheckModule)
1516import GhcPlugins as GHC hiding (fst3, (<>))
1617
1718
19+-- | If `Nothing` we do not write .hi files.
20+newtype InterfaceDirectory = InterfaceDirectory (Maybe FilePath)
21+
1822data IdeOptions = IdeOptions
1923 { optPreprocessor :: GHC.ParsedSource -> ([(GHC.SrcSpan, String)], GHC.ParsedSource)
2024 , optGhcSession :: Action HscEnv
2125 -- ^ Setup a GHC session using a given package state. If a `ParsedModule` is supplied,
2226 -- the import path should be setup for that module.
2327 , optPkgLocationOpts :: IdePkgLocationOptions
24− , optWriteIface :: Bool
28+ , optIfaceDir :: InterfaceDirectory
2529 , optExtensions :: [String]
2630
2731 , optThreads :: Int
@@ -33,7 +37,7 @@ data IdeOptions = IdeOptions
3337defaultIdeOptions :: Action HscEnv -> IdeOptions
3438defaultIdeOptions session = IdeOptions
3539 {optPreprocessor = (,) []
36− ,optWriteIface = False
40+ ,optIfaceDir = InterfaceDirectory Nothing
3741 ,optGhcSession = session
3842 ,optExtensions = ["hs"]
3943 ,optPkgLocationOpts = defaultIdePkgLocationOptions