git.iko.soy/typeable/entropy
on main help sign in
Restore compatibility with GHC 7.0 and GHC 7.2
df3193aHerbert Valerio Riedel
Setup.hs+28−1
@@ -1,3 +1,5 @@
1+{-# LANGUAGE CPP #-}
2+import Control.Monad
1import Distribution.Simple
3import Distribution.Simple
2import Distribution.Simple.LocalBuildInfo
4import Distribution.Simple.LocalBuildInfo
3import Distribution.Simple.Setup
5import Distribution.Simple.Setup
@@ -9,6 +11,7 @@ import System.Process
9import System.Directory
11import System.Directory
10import System.FilePath
12import System.FilePath
11import System.Exit
13import System.Exit
14+import System.IO
12
15
13main = defaultMainWithHooks hk
16main = defaultMainWithHooks hk
14 where
17 where
@@ -44,6 +47,30 @@ canUseRDRAND cc = do
44 , " return (!err);"
47 , " return (!err);"
45 , "}"
48 , "}"
46 ])
49 ])
47− ec <- rawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o", tmpDir ++ "/a.o","-c"]
50+ ec <- myRawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o", tmpDir ++ "/a.o","-c"]
48 notice normal $ "Result of RDRAND Test: " ++ show (ec == ExitSuccess)
51 notice normal $ "Result of RDRAND Test: " ++ show (ec == ExitSuccess)
49 return (ec == ExitSuccess)
52 return (ec == ExitSuccess)
53+
54+myRawSystemExitCode :: Verbosity -> FilePath -> [String] -> IO ExitCode
55+#if __GLASGOW_HASKELL__ >= 704
56+-- We know for sure, that if GHC >= 7.4 implies Cabal >= 1.14
57+myRawSystemExitCode = rawSystemExitCode
58+#else
59+-- Legacy branch:
60+-- We implement our own 'rawSystemExitCode', this will even work if
61+-- the user happens to have Cabal >= 1.14 installed with GHC 7.0 or
62+-- 7.2
63+myRawSystemExitCode verbosity path args = do
64+ printRawCommandAndArgs verbosity path args
65+ hFlush stdout
66+ exitcode <- rawSystem path args
67+ unless (exitcode == ExitSuccess) $ do
68+ debug verbosity $ path ++ " returned " ++ show exitcode
69+ return exitcode
70+ where
71+ printRawCommandAndArgs :: Verbosity -> FilePath -> [String] -> IO ()
72+ printRawCommandAndArgs verbosity path args
73+ | verbosity >= deafening = print (path, args)
74+ | verbosity >= verbose = putStrLn $ unwords (path : args)
75+ | otherwise = return ()
76+#endif
entropy.cabal+1−1
@@ -42,7 +42,7 @@ library
42 other-modules: System.EntropyNix
42 other-modules: System.EntropyNix
43 }
43 }
44 other-extensions: CPP, ForeignFunctionInterface, BangPatterns, ScopedTypeVariables
44 other-extensions: CPP, ForeignFunctionInterface, BangPatterns, ScopedTypeVariables
45− build-depends: base >= 4.5 && < 5, bytestring
45+ build-depends: base >= 4.3 && < 5, bytestring
46 default-language: Haskell2010
46 default-language: Haskell2010
47 if(os(halvm))
47 if(os(halvm))
48 cpp-options: -DXEN -DHAVE_RDRAND
48 cpp-options: -DXEN -DHAVE_RDRAND