1{-# LANGUAGE TemplateHaskell #-}
2import Distribution.Simple
3import Distribution.Simple.LocalBuildInfo
4import Distribution.Simple.Setup
5import Distribution.PackageDescription
6import Distribution.Simple.Utils
7import Distribution.Simple.Program
8import Distribution.Verbosity
10import System.Directory
13import Language.Haskell.TH (appE, varE, mkName, conE)
15main = defaultMainWithHooks hk
17 hk = simpleUserHooks { buildHook = \pd lbi uh bf -> do
18 let ccProg = Program "gcc" undefined undefined undefined
19 mConf = lookupProgram ccProg (withPrograms lbi)
20 err = error "Could not determine C compiler"
21 cc = locationPath . programLocation . maybe err id $ mConf
23 let newWithPrograms1 = userSpecifyArgs "gcc" cArgs (withPrograms lbi)
24 newWithPrograms = userSpecifyArgs "ghc" cArgsHC newWithPrograms1
25 lbiNew = if b then (lbi {withPrograms = newWithPrograms }) else lbi
26 buildHook simpleUserHooks pd lbiNew uh bf
30cArgs = ["-DHAVE_RDRAND"]
33cArgsHC = map ("-optc" ++) cArgs
35canUseRDRAND :: FilePath -> IO Bool
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
42 writeFile (tmpDir ++ "/testRDRAND.c")
43 (unlines [ "#include <stdint.h>"
45 , " uint64_t therand;"
46 , " unsigned char err;"
47 , " asm volatile(\"rdrand %0 ; setc %1\""
48 , " : \"=r\" (therand), \"=qm\" (err));"
52 ec <- rawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o" ++ tmpDir ++ "/a.out"]
53 notice normal $ "Result of RDRAND Test: " ++ show (ec == ExitSuccess)
54 return (ec == ExitSuccess)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list