diff options
author | Francesco Mazzoli <f@mazzo.li> | 2017-03-07 23:39:51 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-08 19:15:54 -0500 |
commit | 0fac488cca04a07224926e35be9c45ee2d0e1631 (patch) | |
tree | 48c5317fa66d9e09ff9bd829daf26539a971abc8 /libraries/ghci | |
parent | de62f587463f6377df1e69e11504578833dfe653 (diff) | |
download | haskell-0fac488cca04a07224926e35be9c45ee2d0e1631.tar.gz |
Allow compilation of C/C++/ObjC/ObjC++ files with module from TH
The main goal is to easily allow the inline-c project (and
similar projects such as inline-java) to emit C/C++ files to
be compiled and linked with the current module.
Moreover, `addCStub` is removed, since it's quite fragile. Most
notably, the C stubs end up in the file generated by
`CodeOutput.outputForeignStubs`, which is tuned towards
generating a file for stubs coming from `capi` and Haskell-to-C
exports.
Reviewers: simonmar, austin, goldfire, facundominguez, dfeuer, bgamari
Reviewed By: dfeuer, bgamari
Subscribers: snowleopard, rwbarton, dfeuer, thomie, duncan, mboes
Differential Revision: https://phabricator.haskell.org/D3280
Diffstat (limited to 'libraries/ghci')
-rw-r--r-- | libraries/ghci/GHCi/Message.hs | 7 | ||||
-rw-r--r-- | libraries/ghci/GHCi/TH.hs | 2 | ||||
-rw-r--r-- | libraries/ghci/ghci.cabal.in | 1 |
3 files changed, 6 insertions, 4 deletions
diff --git a/libraries/ghci/GHCi/Message.hs b/libraries/ghci/GHCi/Message.hs index 37db0627e1..81de2fbd21 100644 --- a/libraries/ghci/GHCi/Message.hs +++ b/libraries/ghci/GHCi/Message.hs @@ -30,6 +30,7 @@ import GHCi.TH.Binary () import GHCi.BreakArray import GHC.LanguageExtensions +import GHC.ForeignSrcLang import GHC.Fingerprint import Control.Concurrent import Control.Exception @@ -244,7 +245,7 @@ data THMessage a where AddDependentFile :: FilePath -> THMessage (THResult ()) AddModFinalizer :: RemoteRef (TH.Q ()) -> THMessage (THResult ()) AddTopDecls :: [TH.Dec] -> THMessage (THResult ()) - AddCStub :: String -> THMessage (THResult ()) + AddForeignFile :: ForeignSrcLang -> String -> THMessage (THResult ()) IsExtEnabled :: Extension -> THMessage (THResult Bool) ExtsEnabled :: THMessage (THResult [Extension]) @@ -281,7 +282,7 @@ getTHMessage = do 15 -> THMsg <$> EndRecover <$> get 16 -> return (THMsg RunTHDone) 17 -> THMsg <$> AddModFinalizer <$> get - _ -> THMsg <$> AddCStub <$> get + _ -> THMsg <$> (AddForeignFile <$> get <*> get) putTHMessage :: THMessage a -> Put putTHMessage m = case m of @@ -303,7 +304,7 @@ putTHMessage m = case m of EndRecover a -> putWord8 15 >> put a RunTHDone -> putWord8 16 AddModFinalizer a -> putWord8 17 >> put a - AddCStub a -> putWord8 18 >> put a + AddForeignFile lang a -> putWord8 18 >> put lang >> put a data EvalOpts = EvalOpts diff --git a/libraries/ghci/GHCi/TH.hs b/libraries/ghci/GHCi/TH.hs index 8cb9accc5e..1b08501580 100644 --- a/libraries/ghci/GHCi/TH.hs +++ b/libraries/ghci/GHCi/TH.hs @@ -193,7 +193,7 @@ instance TH.Quasi GHCiQ where qRunIO m = GHCiQ $ \s -> fmap (,s) m qAddDependentFile file = ghcCmd (AddDependentFile file) qAddTopDecls decls = ghcCmd (AddTopDecls decls) - qAddCStub str = ghcCmd (AddCStub str) + qAddForeignFile str lang = ghcCmd (AddForeignFile str lang) qAddModFinalizer fin = GHCiQ (\s -> mkRemoteRef fin >>= return . (, s)) >>= ghcCmd . AddModFinalizer qGetQ = GHCiQ $ \s -> diff --git a/libraries/ghci/ghci.cabal.in b/libraries/ghci/ghci.cabal.in index 631eed7190..d15da5a0f5 100644 --- a/libraries/ghci/ghci.cabal.in +++ b/libraries/ghci/ghci.cabal.in @@ -75,6 +75,7 @@ library deepseq == 1.4.*, filepath == 1.4.*, ghc-boot == @ProjectVersionMunged@, + ghc-boot-th == @ProjectVersionMunged@, template-haskell == 2.12.*, transformers == 0.5.* |