Targets.hs 4.15 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
21
22
23
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

buildHaddock :: Bool
buildHaddock = True

24
25
26
-- 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)
27
targetPackages :: [Package]
28
29
30
31
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
targetPackages =
    [   standardLibrary "array"               [        Stage1]
    --,     customLibrary "base"                [        Stage1] baseConfArgs
    ,   standardLibrary "bin-package-db"      [Stage0, Stage1]
    ,   standardLibrary "binary"              [Stage0, Stage1]
    ,   standardLibrary "bytestring"          [        Stage1]
    -- see Note [Cabal package weirdness]
    , 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 (show integerLibrary) [        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
    ]

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

cabalTraits :: (String, Settings -> Settings)
cabalTraits = ("Cabal", id) -- change cabalName, keep the other settings intact

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
        {
            customCcArgs = arg "-Ilibraries/integer-gmp2/gmp"
        }

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
98

99
100
101
targetPackagesInStage :: Stage -> [Package]
targetPackagesInStage stage = filter inStage targetPackages
  where
102
    inStage (Package _ _ _ todoItems) = any matchStage todoItems
103
    matchStage (todoStage, _, _)    = todoStage == stage
104

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