-
Notifications
You must be signed in to change notification settings - Fork 9
/
Setup.hs
25 lines (22 loc) · 1.02 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Distribution.Simple
import Distribution.Simple.Setup (BuildFlags)
import Distribution.PackageDescription (HookedBuildInfo, emptyHookedBuildInfo)
import System.Cmd (system)
import System.Directory (doesFileExist, createDirectoryIfMissing)
import Control.Monad (when)
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks { preBuild = preBuild' }
where
preBuild' :: Args -> BuildFlags -> IO HookedBuildInfo
preBuild' _ _ = do
maybeRunC2HS
return emptyHookedBuildInfo
-- Because of a problem with Cabal dependency resolution of .chs
-- files, we need to execute C2HS manually on these two files
maybeRunC2HS = do
existsA <- doesFileExist "dist/build/Foreign/OpenCL/Bindings/Internal/Types.chi"
when (not existsA) $ do
let c2hs_args="--output-dir=dist/build --include=dist/build --cppopts=-Iinclude --cppopts=-U__BLOCKS__"
createDirectoryIfMissing True "dist/build/Foreign/OpenCL/Bindings/Internal"
_ <- system $ "c2hs " ++ c2hs_args ++ " Foreign/OpenCL/Bindings/Internal/Types.chs"
return ()