GHC.hs 6.12 KB
Newer Older
1
module GHC (
Andrey Mokhov's avatar
Andrey Mokhov committed
2
3
4
    array, base, binary, bytestring, cabal, compiler, containers, compareSizes,
    deepseq, deriveConstants, directory, dllSplit, filepath, genapply,
    genprimopcode, ghc, ghcBoot, ghcCabal, ghci, ghcPkg, ghcPrim, ghcPwd, ghcTags,
Andrey Mokhov's avatar
Andrey Mokhov committed
5
    haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin, integerGmp,
Ben Gamari's avatar
Ben Gamari committed
6
    integerSimple, iservBin, mkUserGuidePart, parallel, pretty, primitive, process,
Andrey Mokhov's avatar
Andrey Mokhov committed
7
    runghc, stm, templateHaskell, terminfo, time, transformers, unix, win32, xhtml,
8

9
    defaultKnownPackages, defaultTargetDirectory, defaultProgramPath
10
    ) where
11

12
import Base
13
import Package
14
import Stage
15

16
-- These are all GHC packages we know about. Build rules will be generated for
17
18
19
-- all of them. However, not all of these packages will be built. For example,
-- package 'win32' is built only on Windows.
-- Settings/Packages.hs defines default conditions for building each package,
20
-- which can be overridden in Settings/User.hs.
21
22
defaultKnownPackages :: [Package]
defaultKnownPackages =
Andrey Mokhov's avatar
Andrey Mokhov committed
23
24
25
    [ array, base, binary, bytestring, cabal, compiler, containers, compareSizes
    , deepseq, deriveConstants, directory, dllSplit, filepath, genapply
    , genprimopcode, ghc, ghcBoot, ghcCabal, ghci, ghcPkg, ghcPrim
Andrey Mokhov's avatar
Andrey Mokhov committed
26
    , ghcPwd, ghcTags, haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin
Ben Gamari's avatar
Ben Gamari committed
27
28
29
    , integerGmp, integerSimple, iservBin, mkUserGuidePart, parallel, pretty
    , primitive , process, runghc, stm, templateHaskell, terminfo, time
    , transformers, unix, win32, xhtml ]
30

Andrey Mokhov's avatar
Andrey Mokhov committed
31
-- Package definitions (see Package.hs)
Andrey Mokhov's avatar
Andrey Mokhov committed
32
33
34
array, base, binary, bytestring, cabal, compiler, containers, compareSizes,
    deepseq, deriveConstants, directory, dllSplit, filepath, genapply,
    genprimopcode, ghc, ghcBoot, ghcCabal, ghci, ghcPkg, ghcPrim, ghcPwd,
Andrey Mokhov's avatar
Andrey Mokhov committed
35
    ghcTags, haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin, integerGmp,
Andrey Mokhov's avatar
Andrey Mokhov committed
36
    integerSimple, iservBin, mkUserGuidePart, parallel, pretty, primitive, process,
Andrey Mokhov's avatar
Andrey Mokhov committed
37
    runghc, stm, templateHaskell, terminfo, time, transformers, unix, win32, xhtml :: Package
Andrey Mokhov's avatar
Andrey Mokhov committed
38

Andrey Mokhov's avatar
Andrey Mokhov committed
39
40
41
42
array           = library  "array"
base            = library  "base"
binary          = library  "binary"
bytestring      = library  "bytestring"
Andrey Mokhov's avatar
Andrey Mokhov committed
43
44
cabal           = library  "Cabal"          `setPath` "libraries/Cabal/Cabal"
compiler        = topLevel "ghc"            `setPath` "compiler"
Andrey Mokhov's avatar
Andrey Mokhov committed
45
containers      = library  "containers"
46
compareSizes    = utility  "compareSizes"   `setPath` "utils/compare_sizes"
Andrey Mokhov's avatar
Andrey Mokhov committed
47
deepseq         = library  "deepseq"
Andrey Mokhov's avatar
Andrey Mokhov committed
48
deriveConstants = utility  "deriveConstants"
Andrey Mokhov's avatar
Andrey Mokhov committed
49
directory       = library  "directory"
50
dllSplit        = utility  "dll-split"
Andrey Mokhov's avatar
Andrey Mokhov committed
51
filepath        = library  "filepath"
Andrey Mokhov's avatar
Andrey Mokhov committed
52
genapply        = utility  "genapply"
Andrey Mokhov's avatar
Andrey Mokhov committed
53
genprimopcode   = utility  "genprimopcode"
Ben Gamari's avatar
Ben Gamari committed
54
ghc             = topLevel "ghc-bin"        `setPath` "ghc" `setPkgType` Program
Andrey Mokhov's avatar
Andrey Mokhov committed
55
ghcBoot         = library  "ghc-boot"
56
ghcCabal        = utility  "ghc-cabal"
Andrey Mokhov's avatar
Andrey Mokhov committed
57
ghci            = library  "ghci"
58
ghcPkg          = utility  "ghc-pkg"
Andrey Mokhov's avatar
Andrey Mokhov committed
59
ghcPrim         = library  "ghc-prim"
Andrey Mokhov's avatar
Andrey Mokhov committed
60
ghcPwd          = utility  "ghc-pwd"
61
ghcTags         = utility  "ghctags"
Andrey Mokhov's avatar
Andrey Mokhov committed
62
haddock         = utility  "haddock"
Andrey Mokhov's avatar
Andrey Mokhov committed
63
haskeline       = library  "haskeline"
64
hsc2hs          = utility  "hsc2hs"
Andrey Mokhov's avatar
Andrey Mokhov committed
65
hoopl           = library  "hoopl"
Andrey Mokhov's avatar
Andrey Mokhov committed
66
hp2ps           = utility  "hp2ps"
Andrey Mokhov's avatar
Andrey Mokhov committed
67
hpc             = library  "hpc"
68
hpcBin          = utility  "hpc-bin"        `setPath` "utils/hpc"
69
70
integerGmp      = library  "integer-gmp"
integerSimple   = library  "integer-simple"
Ben Gamari's avatar
Ben Gamari committed
71
iservBin        = topLevel "iserv-bin"      `setPath` "iserv" `setPkgType` Program
72
mkUserGuidePart = utility  "mkUserGuidePart"
Andrey Mokhov's avatar
Andrey Mokhov committed
73
74
75
76
parallel        = library  "parallel"
pretty          = library  "pretty"
primitive       = library  "primitive"
process         = library  "process"
77
runghc          = utility  "runghc"
Andrey Mokhov's avatar
Andrey Mokhov committed
78
79
80
81
82
83
84
85
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"
86

Andrey Mokhov's avatar
Andrey Mokhov committed
87
88
89
90
91
-- TODO: The following utils are not included into the build system because
-- they seem to be unused or unrelated to the build process: chechUniques,
-- completion, count_lines, coverity, debugNGC, describe-unexpected, genargs,
-- lndir, mkdirhier, testremove, touchy, unlit, vagrant

92
-- GHC build results will be placed into target directories with the following
93
-- typical structure:
94
95
96
97
-- * build/          : contains compiled object code
-- * doc/            : produced by haddock
-- * package-data.mk : contains output of ghc-cabal applied to pkgCabal
-- TODO: simplify to just 'show stage'?
98
-- TODO: we divert from the previous convention for ghc-cabal and ghc-pkg,
99
100
-- which used to store stage 0 build results in 'dist' folder
-- On top of that, mkUserGuidePart used dist for stage 1 for some reason.
101
defaultTargetDirectory :: Stage -> Package -> FilePath
102
103
104
105
106
107
108
109
defaultTargetDirectory stage pkg
    | pkg   == compiler = "stage" ++ show (fromEnum stage + 1)
    | pkg   == ghc      = "stage" ++ show (fromEnum stage + 1)
    | stage == Stage0   = "dist-boot"
    | otherwise         = "dist-install"

defaultProgramPath :: Stage -> Package -> Maybe FilePath
defaultProgramPath stage pkg
110
    | pkg == compareSizes    = program $ pkgName pkg
Andrey Mokhov's avatar
Andrey Mokhov committed
111
    | pkg == deriveConstants = program $ pkgName pkg
112
    | pkg == dllSplit        = program $ pkgName pkg
Andrey Mokhov's avatar
Andrey Mokhov committed
113
    | pkg == genapply        = program $ pkgName pkg
Andrey Mokhov's avatar
Andrey Mokhov committed
114
    | pkg == genprimopcode   = program $ pkgName pkg
115
116
117
118
119
    | pkg == ghc             = program $ "ghc-stage" ++ show (fromEnum stage + 1)
    | pkg == ghcCabal        = program $ pkgName pkg
    | pkg == ghcPkg          = program $ pkgName pkg
    | pkg == ghcPwd          = program $ pkgName pkg
    | pkg == ghcTags         = program $ pkgName pkg
Andrey Mokhov's avatar
Andrey Mokhov committed
120
    | pkg == haddock         = program $ pkgName pkg
121
    | pkg == hsc2hs          = program $ pkgName pkg
Andrey Mokhov's avatar
Andrey Mokhov committed
122
    | pkg == hp2ps           = program $ pkgName pkg
123
124
125
126
    | pkg == hpcBin          = program $ pkgName pkg
    | pkg == mkUserGuidePart = program $ pkgName pkg
    | pkg == runghc          = program $ pkgName pkg
    | otherwise              = Nothing
127
128
129
  where
    program name = Just $ pkgPath pkg -/- defaultTargetDirectory stage pkg
                                      -/- "build/tmp" -/- name <.> exe