diff --git a/Main.hs b/Main.hs index a4c0d04..bcd9ee6 100644 --- a/Main.hs +++ b/Main.hs @@ -109,8 +109,7 @@ main = do inh <- getGhcHandle rfd2 outh <- getGhcHandle wfd1 installSignalHandlers - lo_ref <- newIORef Nothing - let in_pipe = Pipe{pipeRead = inh, pipeWrite = outh, pipeLeftovers = lo_ref} + in_pipe <- mkPipeFromHandles inh outh when verbose $ trace ("Trying to connect to " ++ host_ip ++ ":" ++ (show port)) @@ -307,5 +306,4 @@ socketToPipe sock = do hdl <- socketToHandle sock ReadWriteMode hSetBuffering hdl NoBuffering - lo_ref <- newIORef Nothing - pure Pipe{ pipeRead = hdl, pipeWrite = hdl, pipeLeftovers = lo_ref } + mkPipeFromHandles hdl hdl diff --git a/cabal.project b/cabal.project index e6fdbad..12c8d21 100644 --- a/cabal.project +++ b/cabal.project @@ -1 +1,2 @@ packages: . +allow-newer: * diff --git a/iserv-proxy.cabal b/iserv-proxy.cabal index 39e5cc6..5aaea55 100644 --- a/iserv-proxy.cabal +++ b/iserv-proxy.cabal @@ -80,8 +80,7 @@ Library directory >= 1.3 && < 1.4, network >= 2.6, filepath >= 1.4 && < 1.5, - ghci == 9.3, - libiserv == 9.3 + ghci Executable iserv-proxy Default-Language: Haskell2010 @@ -92,8 +91,7 @@ Executable iserv-proxy directory >= 1.3 && < 1.4, network >= 2.6, filepath >= 1.4 && < 1.5, - ghci == 9.3, - libiserv == 9.3, + ghci, iserv-proxy Executable iserv-proxy-interpreter diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..3b7d9f1 --- /dev/null +++ b/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Simple script to build and start the proxy. The printed args show how to use +# it for testing a cross-compiler on the same machine. + +set -e + +GHC="${GHC:-ghc}" +port=5005 + +cabal build -w "$GHC" exe:iserv-proxy +echo ghc-args: -fexternal-interpreter -pgmi=$(cabal list-bin -w "$GHC" exe:iserv-proxy) -opti=127.0.0.1 -opti=$port +cabal run -w "$GHC" iserv-proxy-interpreter $port . diff --git a/src/IServ/Remote/Interpreter.hs b/src/IServ/Remote/Interpreter.hs index 9f8f88f..301a559 100644 --- a/src/IServ/Remote/Interpreter.hs +++ b/src/IServ/Remote/Interpreter.hs @@ -3,7 +3,8 @@ module IServ.Remote.Interpreter where import Network.Socket -import IServ (serv) +import GHCi.Server (serv) +import GHCi.Message import IServ.Remote.Message import System.IO @@ -153,7 +154,7 @@ socketToPipe sock = do hSetBuffering hdl NoBuffering lo_ref <- newIORef Nothing - pure Pipe{ pipeRead = hdl, pipeWrite = hdl, pipeLeftovers = lo_ref } + mkPipeFromHandles hdl hdl acceptSocket :: Socket -> IO Socket acceptSocket = fmap fst . accept