on master help sign in
Merge pull request #247 from blaenk/static-windows-check

Minor refactor of PR #233

commit43c2aeae54253157725c6a58318fff9f2776f108 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateMon 28 Apr 2014, 10:42 (12 years ago) parent889b9f9ca44e64
1 file changed+11−8
src/Hakyll/Core/UnixFilter.hs+11−8
src/Hakyll/Core/UnixFilter.hs+11−8
@@ -1,3 +1,5 @@
1+{-# LANGUAGE CPP #-}
2+
13--------------------------------------------------------------------------------
24-- | A Compiler that supports unix filters.
35module Hakyll.Core.UnixFilter
@@ -19,7 +21,6 @@ import System.Exit (ExitCode (..))
1921import System.IO (Handle, hClose, hFlush, hGetContents,
2022 hPutStr, hSetEncoding, localeEncoding)
2123import System.Process
22−import qualified System.Info as System
2324
2425--------------------------------------------------------------------------------
2526import Hakyll.Core.Compiler
@@ -105,17 +106,19 @@ unixFilterIO :: Monoid o
105106 -> i
106107 -> IO (o, String, ExitCode)
107108unixFilterIO writer reader programName args input = do
108− -- The problem on Windows is that `proc` is that it is unable to execute
109+ -- The problem on Windows is that `proc` is unable to execute
109110 -- batch stubs (eg. anything created using 'gem install ...') even if its in
110111 -- `$PATH`. A solution to this issue is to execute the batch file explicitly
111112 -- using `cmd /c batchfile` but there is no rational way to know where said
112113 -- batchfile is on the system. Hence, we detect windows using the
113− -- `System.Info` module and then instead of using `proc` to create the
114− -- process, use `shell` instead which will be able to execute everything
115− -- `proc` can, and this can deal with batch files as well.
116− let pr = if System.os == "mingw32"
117− then shell $ unwords (programName : args)
118− else proc programName args
114+ -- CPP and instead of using `proc` to create the process, use `shell`
115+ -- which will be able to execute everything `proc` can
116+ -- as well as batch files.
117+#ifdef mingw32_HOST_OS
118+ let pr = shell $ unwords (programName : args)
119+#else
120+ let pr = proc programName args
121+#endif
119122
120123 (Just inh, Just outh, Just errh, pid) <-
121124 createProcess pr