Targets.hs 4.25 KB
Newer Older
1
2
3
4
5
6
{-# LANGUAGE NoImplicitPrelude #-}
module Targets (
    targetPackages, targetPackagesInStage,
    IntegerLibrary (..), integerLibrary,
    buildHaddock
    ) where
7

8
import Package.Base
9

10
11
12
13
14
15
16
17
18
19
20
data IntegerLibrary = IntegerGmp | IntegerGmp2 | IntegerSimple

instance Show IntegerLibrary where
    show library = case library of
         IntegerGmp    -> "integer-gmp"
         IntegerGmp2   -> "integer-gmp2"
         IntegerSimple -> "integer-simple"

integerLibrary :: IntegerLibrary
integerLibrary = IntegerGmp2

21
22
23
integerLibraryName :: String
integerLibraryName = show integerLibrary

24
25
26
buildHaddock :: Bool
buildHaddock = True

27
28
29
-- These are the packages we build:
-- TODO: this should eventually be removed and replaced by the top-level
-- target, i.e. GHC (and perhaps, something else)
30
targetPackages :: [Package]
31
targetPackages =
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    [   standardLibrary "array"            [        Stage1]
    ,     customLibrary "base"             [        Stage1] baseConfArgs
    ,   standardLibrary "bin-package-db"   [Stage0, Stage1]
    ,   standardLibrary "binary"           [Stage0, Stage1]
    ,   standardLibrary "bytestring"       [        Stage1]
    , customNameLibrary "Cabal/Cabal"      [Stage0, Stage1] cabalTraits
    ,   standardLibrary "containers"       [        Stage1]
    ,   standardLibrary "deepseq"          [        Stage1]
    ,   standardLibrary "directory"        [        Stage1]
    ,   standardLibrary "filepath"         [        Stage1]
    ,     customLibrary "ghc-prim"         [        Stage1] ghcPrimConfArgs
    ,   standardLibrary "haskeline"        [        Stage1]
    ,   standardLibrary "hoopl"            [Stage0, Stage1]
    ,   standardLibrary "hpc"              [Stage0, Stage1]
    , customNameLibrary integerLibraryName [        Stage1] integerLibTraits
    ,   standardLibrary "parallel"         [        Stage1]
    ,   standardLibrary "pretty"           [        Stage1]
    ,   standardLibrary "primitive"        [        Stage1]
    ,   standardLibrary "process"          [        Stage1]
    ,   standardLibrary "stm"              [        Stage1]
    ,   standardLibrary "template-haskell" [        Stage1]
    ,     customLibrary "terminfo"         [Stage0, Stage1] whenTerminfo
    ,   standardLibrary "time"             [        Stage1]
    ,   standardLibrary "transformers"     [Stage0, Stage1]
    ,     customLibrary "unix"             [        Stage1] whenUnix
    ,     customLibrary "Win32"            [        Stage1] whenWin32
    ,     customLibrary "xhtml"            [        Stage1] whenXhtml
59
60
61
62
63
64
    ]

baseConfArgs :: Settings -> Settings
baseConfArgs settings =
    settings { customConfArgs = arg $ "--flags=" ++ show integerLibrary }

65
-- see Note [Cabal package weirdness]
66
cabalTraits :: (String, Settings -> Settings)
67
cabalTraits = ("Cabal", id) -- change cabalName, keep other settings intact
68
69
70
71
72
73
74
75
76
77
78
79
80
81

ghcPrimConfArgs :: Settings -> Settings
ghcPrimConfArgs settings =
    settings { customConfArgs = arg "--flag=include-ghc-prim" }

integerLibTraits :: (String, Settings -> Settings)
integerLibTraits = (cabalName, traits)
  where
    cabalName = case integerLibrary of
        IntegerGmp    -> "integer-gmp"
        IntegerGmp2   -> "integer-gmp" -- Indeed, why make life easier?
        IntegerSimple -> "integer-simple"
    traits settings = settings
        {
82
83
84
            customConfArgs = when windowsHost $
                             arg "--configure-option=--with-intree-gmp",
            customCcArgs   = arg "-Ilibraries/integer-gmp2/gmp"
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
        }

whenTerminfo :: Settings -> Settings
whenTerminfo settings = settings
    {
        buildWhen = do
            os <- showArg TargetOs
            not windowsHost && (os /= "ios")
    }

whenUnix :: Settings -> Settings
whenUnix settings = settings { buildWhen = not windowsHost }

whenWin32 :: Settings -> Settings
whenWin32 settings = settings { buildWhen = windowsHost }

whenXhtml :: Settings -> Settings
whenXhtml settings = settings { buildWhen = return buildHaddock }
Andrey Mokhov's avatar
Andrey Mokhov committed
103

104
105
106
targetPackagesInStage :: Stage -> [Package]
targetPackagesInStage stage = filter inStage targetPackages
  where
107
    inStage (Package _ _ _ todoItems) = any matchStage todoItems
108
    matchStage (todoStage, _, _)    = todoStage == stage
109

110
111
112
-- Note [Cabal package weirdness]
-- Find out if we can move the contents to just Cabal/
-- What is Cabal/cabal-install? Do we need it?