-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.hs
31 lines (25 loc) · 1.2 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
26
27
28
29
30
31
import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.Simple.Program ( requireProgram, runProgram, simpleProgram, defaultProgramDb
, ProgArg, Program, ProgramDb, ConfiguredProgram )
import Distribution.Types.HookedBuildInfo
import Distribution.Verbosity (Verbosity, normal)
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks { preBuild = preBuildHook
, preClean = preCleanHook }
makeProgram :: Program
makeProgram = simpleProgram "make"
configuredMake :: Verbosity -> IO (ConfiguredProgram, ProgramDb)
configuredMake verb = requireProgram verb makeProgram defaultProgramDb
runMake :: Verbosity -> [ProgArg] -> IO ()
runMake verb args = do
(make', progDb) <- configuredMake verb
runProgram verb make' args
preBuildHook :: Args -> BuildFlags -> IO HookedBuildInfo
preBuildHook _ bflags = do
runMake (fromFlagOrDefault normal (buildVerbosity bflags)) ["-C", "runtime", "compile"]
pure emptyHookedBuildInfo
preCleanHook :: Args -> CleanFlags -> IO HookedBuildInfo
preCleanHook _ cflags = do
runMake (fromFlagOrDefault normal (cleanVerbosity cflags)) ["-C", "runtime", "clean"]
pure emptyHookedBuildInfo