git.iko.soy/typeable/entropy
on main help sign in
Merge pull request #3 from hamishmack/master
8be62adThomas M. DuBuisson
Setup.hs+7−1
@@ -1,3 +1,4 @@
1+{-# LANGUAGE TemplateHaskell #-}
1import Distribution.Simple
2import Distribution.Simple
2import Distribution.Simple.LocalBuildInfo
3import Distribution.Simple.LocalBuildInfo
3import Distribution.Simple.Setup
4import Distribution.Simple.Setup
@@ -9,6 +10,7 @@ import System.Process
9import System.Directory
10import System.Directory
10import System.FilePath
11import System.FilePath
11import System.Exit
12import System.Exit
13+import Language.Haskell.TH (appE, varE, mkName, conE)
12
14
13main = defaultMainWithHooks hk
15main = defaultMainWithHooks hk
14 where
16 where
@@ -32,7 +34,11 @@ cArgsHC = map ("-optc" ++) cArgs
32
34
33canUseRDRAND :: FilePath -> IO Bool
35canUseRDRAND :: FilePath -> IO Bool
34canUseRDRAND cc = do
36canUseRDRAND cc = do
35− withTempDirectory normal "" "testRDRAND" $ \tmpDir -> do
37+ -- Template haskell to call withTempDirectory in a backward compatible way
38+ -- withTempDirectory normal False "" "testRDRAND" $ \tmpDir -> do
39+ $(if cabalVersion >= Version [1,17,0] []
40+ then appE (appE (varE $ mkName "withTempDirectory") (varE 'normal)) (conE (mkName "False"))
41+ else appE (varE $ mkName "withTempDirectory") (varE 'normal)) "" "testRDRAND" $ \tmpDir -> do
36 writeFile (tmpDir ++ "/testRDRAND.c")
42 writeFile (tmpDir ++ "/testRDRAND.c")
37 (unlines [ "#include <stdint.h>"
43 (unlines [ "#include <stdint.h>"
38 , "int main() {"
44 , "int main() {"