Merge pull request #10662 from haskell/ulysses4ever-prerelease-cleanup-fixup
[cabal.git] / cabal-testsuite / PackageTests / SetupHooks / SetupHooksCyclicRules / SetupHooks.hs
blob64920431b45eed54ae4f5a0f69421685de0d768b
1 {-# LANGUAGE DuplicateRecordFields #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE RecursiveDo #-}
4 {-# LANGUAGE StaticPointers #-}
6 module SetupHooks where
8 import Distribution.Simple.LocalBuildInfo (interpretSymbolicPathLBI)
9 import Distribution.Simple.SetupHooks
10 import Distribution.Utils.Path (makeRelativePathEx)
12 import qualified Data.List.NonEmpty as NE ( NonEmpty(..) )
14 setupHooks :: SetupHooks
15 setupHooks =
16 noSetupHooks
17 { buildHooks =
18 noBuildHooks
19 { preBuildComponentRules = Just $ rules (static ()) cyclicPreBuildRules
23 cyclicPreBuildRules :: PreBuildComponentInputs -> RulesM ()
24 cyclicPreBuildRules (PreBuildComponentInputs { localBuildInfo = lbi, targetInfo = tgt }) = mdo
25 let clbi = targetCLBI tgt
26 autogenDir = autogenComponentModulesDir lbi clbi
27 action = mkCommand (static Dict) (static (\ () -> error "This should not run")) ()
28 r1 <- registerRule "r1" $
29 staticRule action
30 [ RuleDependency $ RuleOutput r2 0 ]
31 ( Location autogenDir (makeRelativePathEx "G1.hs") NE.:| [] )
32 r2 <- registerRule "r2" $
33 staticRule action
34 [ RuleDependency $ RuleOutput r1 0 ]
35 ( Location autogenDir (makeRelativePathEx "G2.hs") NE.:| [] )
36 r3 <- registerRule "r3" $
37 staticRule action
38 [ RuleDependency $ RuleOutput r3 0 ]
39 ( Location autogenDir (makeRelativePathEx "G3.hs") NE.:| [] )
40 return ()