Skip to content

Commit

Permalink
Make the Cabal wrapper use a .bat file on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell authored and mpickering committed Jun 16, 2019
1 parent 8529b27 commit 7ef1a9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions hie-bios.cabal
Expand Up @@ -14,6 +14,7 @@ Build-Type: Simple
Extra-Source-Files: ChangeLog
wrappers/bazel
wrappers/cabal
wrappers/cabal.bat

Library
Default-Language: Haskell2010
Expand All @@ -37,6 +38,7 @@ Library
, directory
, filepath
, ghc
, extra
, process
, transformers
, file-embed
Expand Down
7 changes: 6 additions & 1 deletion src/HIE/Bios/Cradle.hs
Expand Up @@ -15,6 +15,7 @@ import Control.Monad.Trans.Maybe
import System.FilePath
import Control.Monad
import Control.Monad.IO.Class
import System.Info.Extra
import Control.Applicative ((<|>))
import Data.FileEmbed
import System.IO.Temp
Expand Down Expand Up @@ -126,9 +127,13 @@ cabalCradle wdir mc = do
cabalWrapper :: String
cabalWrapper = $(embedStringFile "wrappers/cabal")

cabalWrapperBat :: String
cabalWrapperBat = $(embedStringFile "wrappers/cabal.bat")

cabalAction :: FilePath -> Maybe String -> FilePath -> IO (ExitCode, String, [String])
cabalAction work_dir mc _fp = do
wrapper_fp <- writeSystemTempFile "wrapper" cabalWrapper
wrapper_fp <- writeSystemTempFile "wrapper.bat" $
if isWindows then cabalWrapperBat else cabalWrapper
-- TODO: This isn't portable for windows
setFileMode wrapper_fp accessModes
check <- readFile wrapper_fp
Expand Down
7 changes: 7 additions & 0 deletions wrappers/cabal.bat
@@ -0,0 +1,7 @@
@ECHO OFF
IF "%i" == "--interactive" (
ECHO %CD%
ECHO %*
) ELSE (
ghc %*
)

0 comments on commit 7ef1a9e

Please sign in to comment.