aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cabal-helper.cabal24
-rw-r--r--src/CabalHelper/Compiletime/Compat/Environment.hs17
-rw-r--r--src/CabalHelper/Compiletime/Data.hs6
-rw-r--r--tests/CompileTest.hs3
4 files changed, 37 insertions, 13 deletions
diff --git a/cabal-helper.cabal b/cabal-helper.cabal
index 335e3fe..7788130 100644
--- a/cabal-helper.cabal
+++ b/cabal-helper.cabal
@@ -56,13 +56,17 @@ library
Paths_cabal_helper
ghc-options: -Wall
build-depends: base < 5 && >= 4.5
- , Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14
+ if os(windows)
+ build-depends: base >= 4.7
+ build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14
, directory < 1.4 && >= 1.1.0.2
, filepath < 1.5 && >= 1.3.0.0
, transformers < 0.6 && >= 0.3.0.0
, mtl < 2.3 && >= 2.0
, process < 1.7 && >= 1.1.0.1
- , unix < 2.8 && >= 2.5.1.1
+ if !os(windows)
+ build-depends: unix < 2.8 && >= 2.5.1.1
+ build-depends: unix-compat < 0.5 && >= 0.4.3.1
, semigroupoids < 5.3 && >= 5.2.1
, ghc-prim
@@ -94,7 +98,9 @@ executable cabal-helper-wrapper
-- Remember to copy to compile-test!
build-depends: base < 5 && >= 4.5
- , Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14
+ if os(windows)
+ build-depends: base >= 4.7
+ build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14
, bytestring < 0.11 && >= 0.9.2.1
, directory < 1.4 && >= 1.1.0.2
, exceptions < 0.9 && >= 0.8.3
@@ -104,7 +110,9 @@ executable cabal-helper-wrapper
, template-haskell < 2.13 && >= 2.7.0.0
, temporary < 1.3 && >= 1.2.0.4
, transformers < 0.6 && >= 0.3.0.0
- , unix < 2.8 && >= 2.5.1.1
+ if !os(windows)
+ build-depends: unix < 2.8 && >= 2.5.1.1
+ build-depends: unix-compat < 0.5 && >= 0.4.3.1
, utf8-string < 1.1 && >= 1.0.1.1
, ghc-prim
@@ -129,7 +137,9 @@ test-suite compile-test
-- Same as cabal-helper-wrapper
build-depends: base < 5 && >= 4.5
- , Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14
+ if os(windows)
+ build-depends: base >= 4.7
+ build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14
, bytestring < 0.11 && >= 0.9.2.1
, directory < 1.4 && >= 1.1.0.2
, exceptions < 0.9 && >= 0.8.3
@@ -139,7 +149,9 @@ test-suite compile-test
, template-haskell < 2.13 && >= 2.7.0.0
, temporary < 1.3 && >= 1.2.0.4
, transformers < 0.6 && >= 0.3.0.0
- , unix < 2.8 && >= 2.5.1.1
+ if !os(windows)
+ build-depends: unix < 2.8 && >= 2.5.1.1
+ build-depends: unix-compat < 0.5 && >= 0.4.3.1
, utf8-string < 1.1 && >= 1.0.1.1
, ghc-prim
diff --git a/src/CabalHelper/Compiletime/Compat/Environment.hs b/src/CabalHelper/Compiletime/Compat/Environment.hs
index 916f782..535bcc6 100644
--- a/src/CabalHelper/Compiletime/Compat/Environment.hs
+++ b/src/CabalHelper/Compiletime/Compat/Environment.hs
@@ -1,6 +1,19 @@
+{-# LANGUAGE CPP #-}
module CabalHelper.Compiletime.Compat.Environment where
-import System.Environment
+import qualified System.Environment
+#ifndef mingw32_HOST_OS
+import qualified System.Posix.Env (setEnv)
+#endif
lookupEnv :: String -> IO (Maybe String)
-lookupEnv var = do env <- getEnvironment; return (lookup var env)
+lookupEnv var =
+ do env <- System.Environment.getEnvironment
+ return (lookup var env)
+
+setEnv :: String -> String -> IO ()
+#ifdef mingw32_HOST_OS
+setEnv = System.Environment.setEnv
+#else
+setEnv k v = System.Posix.Env.setEnv k v True
+#endif
diff --git a/src/CabalHelper/Compiletime/Data.hs b/src/CabalHelper/Compiletime/Data.hs
index dce3570..ca291e9 100644
--- a/src/CabalHelper/Compiletime/Data.hs
+++ b/src/CabalHelper/Compiletime/Data.hs
@@ -33,9 +33,9 @@ import Language.Haskell.TH
import System.Directory
import System.FilePath
import System.IO.Temp
-import System.Posix.Files
-import System.Posix.Time
-import System.Posix.Types
+import System.PosixCompat.Files
+import System.PosixCompat.Time
+import System.PosixCompat.Types
import Prelude
import CabalHelper.Compiletime.Compat.Environment
diff --git a/tests/CompileTest.hs b/tests/CompileTest.hs
index a2187d2..0cbb044 100644
--- a/tests/CompileTest.hs
+++ b/tests/CompileTest.hs
@@ -1,6 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-}
-import System.Posix.Env (setEnv)
import System.Process
import System.Exit
import System.IO
@@ -36,7 +35,7 @@ withinRange'CH v r =
main :: IO ()
main = do
- flip (setEnv "HOME") True =<< fromMaybe "/tmp" <$> lookupEnv "TMPDIR"
+ setEnv "HOME" =<< fromMaybe "/tmp" <$> lookupEnv "TMPDIR"
_ <- rawSystem "cabal" ["update"]
let parseVer' "HEAD" = Left HEAD