Targets.hs 4.95 KB
Newer Older
1
module Targets (
2
    targetWays, targetPackages, targetDirectory, packagePredicate,
3
    customConfigureSettings,
4
5
6
7
    array, base, binPackageDb, binary, bytestring, cabal, containers, deepseq,
    directory, filepath, ghcPrim, haskeline, hoopl, hpc, integerLibrary,
    parallel, pretty, primitive, process, stm, templateHaskell, terminfo, time,
    transformers, unix, win32, xhtml
8
    ) where
9

10
import qualified Ways
Andrey Mokhov's avatar
Andrey Mokhov committed
11
import Base hiding (arg, args, Args, TargetDir)
12
import Package
Andrey Mokhov's avatar
Andrey Mokhov committed
13
14
15
import Switches
import Expression
import Expression.Settings
16

17
-- These are the packages we build
18
19
20
21
22
23
targetPackages :: [Package]
targetPackages =
    [ array, base, binPackageDb, binary, bytestring, cabal, compiler
    , containers, deepseq, directory, filepath, ghcPrim, haskeline
    , hoopl, hpc, integerLibrary, parallel, pretty, primitive, process
    , stm, templateHaskell, terminfo, time, transformers, unix, win32, xhtml ]
24

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
-- Some packages are built conditionally
-- TODO: make this function total (it only reads stage from the environment)
packagePredicate :: Package -> Predicate
packagePredicate pkg = do
    stage   <- asks getStage
    windows <- windowsHost
    ios     <- targetOs "ios"
    haddock <- buildHaddock
    let result
            | stage == Stage0 && pkg `notElem`
                [ binPackageDb
                , binary
                , cabal
                , compiler
                , hoopl
                , hpc
                , terminfo
                , transformers ] = False
            | pkg == terminfo    = not windows && not ios
            | pkg == unix        = not windows
            | pkg == win32       = windows
            | pkg == xhtml       = haddock
            | stage == Stage0    = True
            | stage == Stage1    = True
            | otherwise          = False -- TODO: enable Stage2
    return result
51

52
-- Packages will be build these ways
53
targetWays :: Ways
Andrey Mokhov's avatar
Andrey Mokhov committed
54
55
56
57
targetWays = mconcat
    [                              return [Ways.vanilla] -- always build vanilla
    , notStage Stage0            ? return [Ways.profiling]
    , platformSupportsSharedLibs ? return [Ways.dynamic] ]
58

59
60
61
62
63
-- Build results will be placed into a target directory with the following
-- typical structure:
-- * build/           : contains compiled object code
-- * doc/             : produced by haddock
-- * package-data.mk  : contains output of ghc-cabal applied to pkgCabal
64
65
66
67
68
targetDirectory :: Stage -> Package -> FilePath
targetDirectory stage package
    | package == compiler = "stage" ++ show (1 + fromEnum stage)
    | stage   == Stage0   = "dist-boot"
    | otherwise           = "dist-install"
Andrey Mokhov's avatar
Andrey Mokhov committed
69

70
71
72
73
74
75
-- Package definitions
array, base, binPackageDb, binary, bytestring, cabal, containers, deepseq,
    directory, filepath, ghcPrim, haskeline, hoopl, hpc, integerLibrary,
    parallel, pretty, primitive, process, stm, templateHaskell, terminfo, time,
    transformers, unix, win32, xhtml :: Package

Andrey Mokhov's avatar
Andrey Mokhov committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
array           = library  "array"
base            = library  "base"
binPackageDb    = library  "bin-package-db"
binary          = library  "binary"
bytestring      = library  "bytestring"
cabal           = library  "Cabal/Cabal" `setCabal` "Cabal.cabal"
compiler        = topLevel "compiler"    `setCabal` "ghc.cabal"
containers      = library  "containers"
deepseq         = library  "deepseq"
directory       = library  "directory"
filepath        = library  "filepath"
ghcPrim         = library  "ghc-prim"
haskeline       = library  "haskeline"
hoopl           = library  "hoopl"
hpc             = library  "hpc"
integerLibrary  = library  integerLibraryName `setCabal` integerLibraryCabal
parallel        = library  "parallel"
pretty          = library  "pretty"
primitive       = library  "primitive"
process         = library  "process"
stm             = library  "stm"
templateHaskell = library  "template-haskell"
terminfo        = library  "terminfo"
time            = library  "time"
transformers    = library  "transformers"
unix            = library  "unix"
win32           = library  "Win32"
xhtml           = library  "xhtml"
104

105
106
107
108
109
110
111
112
113
integerLibraryName :: String
integerLibraryName = case integerLibraryImpl of
    IntegerGmp    -> "integer-gmp"
    IntegerGmp2   -> "integer-gmp2"
    IntegerSimple -> "integer-simple"

-- see Note [Cabal name weirdness]
integerLibraryCabal :: FilePath
integerLibraryCabal = case integerLibraryImpl of
Andrey Mokhov's avatar
Andrey Mokhov committed
114
115
116
    IntegerGmp    -> "integer-gmp.cabal"
    IntegerGmp2   -> "integer-gmp.cabal" -- Indeed, why make life easier?
    IntegerSimple -> "integer-simple.cabal"
117
118

-- Custom configure settings for packages
119
customConfigureSettings :: Settings
Andrey Mokhov's avatar
Andrey Mokhov committed
120
121
122
123
124
customConfigureSettings = mconcat
    [ package base           ? arg ("--flags=" ++ integerLibraryName)
    , package ghcPrim        ? arg "--flag=include-ghc-prim"
    , package integerLibrary ?
        windowsHost ? arg "--configure-option=--with-intree-gmp"
125
126
    ]

127
-- Note [Cabal name weirdness]
128
129
-- Find out if we can move the contents to just Cabal/
-- What is Cabal/cabal-install? Do we need it?
130
-- A related question about gmp2 -- let's rename the cabal file?