on master help sign in
Allow to build katip under windows.
9cf7991Alexander Vershilov
katip/katip.cabal+6−1
@@ -68,7 +68,6 @@ library
68 , time >= 1 && < 1.7
68 , time >= 1 && < 1.7
69 , transformers >= 0.3 && < 0.6
69 , transformers >= 0.3 && < 0.6
70 , transformers-compat
70 , transformers-compat
71− , unix >= 2.5 && < 2.8
72 , unordered-containers >= 0.2 && < 0.3
71 , unordered-containers >= 0.2 && < 0.3
73 , monad-control >= 1.0 && < 1.1
72 , monad-control >= 1.0 && < 1.1
74 , mtl >= 2.0 && < 2.3
73 , mtl >= 2.0 && < 2.3
@@ -83,6 +82,12 @@ library
83 ghc-options: -Wall
82 ghc-options: -Wall
84 if flag(lib-Werror)
83 if flag(lib-Werror)
85 ghc-options: -Werror
84 ghc-options: -Werror
85+ if os(windows)
86+ build-depends: Win32 >=2.3 && <2.5
87+ other-modules: Katip.Compat
88+ else
89+ build-depends: unix >= 2.5 && <2.8
90+
86
91
87test-suite test
92test-suite test
88 type: exitcode-stdio-1.0
93 type: exitcode-stdio-1.0
katip/src/Katip/Compat.hsnew file+30
@@ -0,0 +1,30 @@
1+{-# LANGUAGE ForeignFunctionInterface #-}
2+{-# LANGUAGE CPP #-}
3+module Katip.Compat
4+ ( ProcessID
5+ , getProcessID
6+ ) where
7+
8+import System.Win32.Process
9+
10+type ProcessID = ProcessId
11+
12+#if !MIN_VERSION_Win32(2,4,0)
13+
14+#if defined(i386_HOST_ARCH)
15+# define WINDOWS_CCONV stdcall
16+#elif defined(x86_64_HOST_ARCH)
17+# define WINDOWS_CCONV ccall
18+#else
19+# error Unknown mingw32 arch
20+#endif
21+
22+foreign import WINDOWS_CCONV unsafe "windows.h GetCurrentProcessId"
23+ c_GetCurrentProcessId :: IO ProcessId
24+
25+getProcessID :: IO ProcessID
26+getProcessID = c_GetCurrentProcessId
27+#else
28+getProcessID :: IO ProcessID
29+getProcessID = getCurrentProcessId
30+#endif
katip/src/Katip/Core.hs+5
@@ -63,7 +63,12 @@ import qualified Language.Haskell.TH.Syntax as TH
63import Lens.Micro
63import Lens.Micro
64import Lens.Micro.TH
64import Lens.Micro.TH
65import Network.HostName
65import Network.HostName
66+#if mingw32_HOST_OS
67+import Katip.Compat
68+#else
66import System.Posix
69import System.Posix
70+#endif
71+
67-------------------------------------------------------------------------------
72-------------------------------------------------------------------------------
68
73
69
74