forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackSetupShim.hs
More file actions
31 lines (29 loc) · 1.31 KB
/
StackSetupShim.hs
File metadata and controls
31 lines (29 loc) · 1.31 KB
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
module StackSetupShim where
import Main
import Distribution.PackageDescription (PackageDescription, emptyHookedBuildInfo)
import Distribution.Simple
import Distribution.Simple.Build
import Distribution.Simple.Setup (ReplFlags, fromFlag, replDistPref, replVerbosity)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo)
import System.Environment (getArgs)
mainOverride :: IO ()
mainOverride = do
args <- getArgs
if "repl" `elem` args && "stack-initial-build-steps" `elem` args
then do
defaultMainWithHooks simpleUserHooks
{ preRepl = \_ _ -> return emptyHookedBuildInfo
, replHook = stackReplHook
, postRepl = \_ _ _ _ -> return ()
}
else main
stackReplHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> ReplFlags -> [String] -> IO ()
stackReplHook pkg_descr lbi hooks flags args = do
let distPref = fromFlag (replDistPref flags)
verbosity = fromFlag (replVerbosity flags)
case args of
("stack-initial-build-steps":rest)
| null rest -> initialBuildSteps distPref pkg_descr lbi verbosity
| otherwise ->
fail "Misuse of running Setup.hs with stack-initial-build-steps, expected no arguments"
_ -> replHook simpleUserHooks pkg_descr lbi hooks flags args