-
Notifications
You must be signed in to change notification settings - Fork 681
/
SetupHooks.hs
34 lines (29 loc) · 1.02 KB
/
SetupHooks.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
26
27
28
29
30
31
32
33
34
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecursiveDo #-}
module SetupHooks where
import Distribution.Simple.SetupHooks
import qualified Data.List.NonEmpty as NE ( NonEmpty(..) )
setupHooks :: SetupHooks
setupHooks =
noSetupHooks
{ buildHooks =
noBuildHooks
{ preBuildComponentRules = Just cyclicPreBuildRules
}
}
cyclicPreBuildRules :: Rules PreBuildComponentInputs
cyclicPreBuildRules = rules $ \ (PreBuildComponentInputs { localBuildInfo = lbi, targetInfo = tgt }) -> do
let clbi = targetCLBI tgt
autogenDir = autogenComponentModulesDir lbi clbi
actId <- registerAction "a" $ simpleAction $ \ _ _ -> error "This should not run"
return $ mdo
r1 <- registerRule "r1" $
simpleRule actId
[ RuleDependency $ RuleOutput r2 0 ]
( ( autogenDir, "G2.hs" ) NE.:| [] )
r2 <- registerRule "r2" $
simpleRule actId
[ RuleDependency $ RuleOutput r1 0 ]
( ( autogenDir, "G1.hs" ) NE.:| [] )
return ()