language: fix: move interface files to a different (#1074)

* language: fix: move interface files to a different

This fixes https://github.com/digital-asset/daml/issues/1009. We move
the created interface files and hie files to a hidden directory
".interfaces" when creating a package.

* removing the ifaceDir option and hardcode the dir
This commit is contained in:
Robin Krom 2019-05-10 18:40:15 +02:00 committed by mergify[bot]
parent 0ac72a4340
commit 160554ac95

View File

@ -62,6 +62,7 @@ import Data.Time
import Development.IDE.Types.SpanInfo
import GHC.Generics (Generic)
import System.FilePath
import System.Directory
-- | 'CoreModule' together with some additional information required for the
-- conversion to DAML-LF.
@ -274,12 +275,14 @@ mkTcModuleResult (WriteInterface writeIface) tcm = do
nc <- liftIO $ readIORef (hsc_NC session)
(iface,_) <- liftIO $ mkIfaceTc session Nothing Sf_None details tcGblEnv
liftIO $ when writeIface $ do
writeIfaceFile (hsc_dflags session) (replaceExtension (file tcm) ".hi") iface
let path = ".interfaces" </> file tcm
createDirectoryIfMissing True (takeDirectory path)
writeIfaceFile (hsc_dflags session) (replaceExtension path ".hi") iface
-- For now, we write .hie files whenever we write .hi files which roughly corresponds to
-- when we are building a package. It should be easily decoupable if that turns out to be
-- useful.
hieFile <- runHsc session $ mkHieFile (tcModSummary tcm) tcGblEnv (fromJust $ renamedSource tcm)
writeHieFile (replaceExtension (file tcm) ".hie") hieFile
writeHieFile (replaceExtension path ".hie") hieFile
let mod_info = HomeModInfo iface details Nothing
origNc = nsNames nc
case lookupModuleEnv origNc (tcmModule tcm) of