-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetup.hs
More file actions
36 lines (30 loc) · 1.01 KB
/
Copy pathSetup.hs
File metadata and controls
36 lines (30 loc) · 1.01 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
32
33
34
35
36
{-| This is a small harness to check the version of the Cabal library and
build and run the real setup script, @DoSetup.hs@.
-}
import Control.Monad
import Data.Char
import Distribution.Simple.Utils(cabalVersion)
import Distribution.Version(Version(..))
import System.Environment
import System.Exit
import System.Process
-- | Pick a CPP flag based on the Cabal library version
cabalVersionCPPFlags :: [String]
cabalVersionCPPFlags = [major_flag, minor_flag]
where
major:minor:_ = versionBranch cabalVersion
major_flag = "-DCABAL_MAJOR=" ++ show major
minor_flag = "-DCABAL_MINOR=" ++ show minor
outputDir = "dist/setup"
setupPath = "dist/setup/do-setup"
buildSetup = do
let flags = ["--make", "-XCPP"] ++ cabalVersionCPPFlags ++
["DoSetup.hs", "-outputdir", outputDir, "-o", setupPath]
ec <- rawSystem "ghc" flags
unless (ec == ExitSuccess) $
fail "Error occured when building the setup script"
main = do
buildSetup
args <- getArgs
ec <- rawSystem setupPath args
exitWith ec