GHC.hs 3.66 KB
Newer Older
1
module GHC (
2
    array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
3
    deepseq, directory, filepath, ghc, ghcCabal, ghcPrim, haskeline, hoopl, hpc,
Andrey Mokhov's avatar
Andrey Mokhov committed
4
5
    integerGmp, integerSimple, parallel, pretty, primitive, process, stm,
    templateHaskell, terminfo, time, transformers, unix, win32, xhtml,
6

7
    defaultKnownPackages, defaultTargetDirectory, defaultProgramPath
8
    ) where
9

10
import Base
11
import Package
12
import Stage
13

14
-- These are all GHC packages we know about. Build rules will be generated for
15
16
17
-- 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,
18
-- which can be overridden in Settings/User.hs.
19
20
21
defaultKnownPackages :: [Package]
defaultKnownPackages =
    [ array, base, binPackageDb, binary, bytestring, cabal, compiler
22
23
24
25
    , containers, deepseq, directory, filepath, ghc, ghcCabal, ghcPrim
    , haskeline, hoopl, hpc, integerGmp, integerSimple, parallel, pretty
    , primitive, process, stm, templateHaskell, terminfo, time, transformers
    , unix, win32, xhtml ]
26

27
-- Package definitions
Andrey Mokhov's avatar
Andrey Mokhov committed
28
array, base, binPackageDb, binary, bytestring, cabal, compiler, containers,
29
    deepseq, directory, filepath, ghc, ghcCabal, ghcPrim, haskeline, hoopl, hpc,
Andrey Mokhov's avatar
Andrey Mokhov committed
30
31
    integerGmp, integerSimple, parallel, pretty, primitive, process, stm,
    templateHaskell, terminfo, time, transformers, unix, win32, xhtml :: Package
Andrey Mokhov's avatar
Andrey Mokhov committed
32

Andrey Mokhov's avatar
Andrey Mokhov committed
33
34
35
36
37
array           = library  "array"
base            = library  "base"
binPackageDb    = library  "bin-package-db"
binary          = library  "binary"
bytestring      = library  "bytestring"
Andrey Mokhov's avatar
Andrey Mokhov committed
38
39
cabal           = library  "Cabal"          `setPath` "libraries/Cabal/Cabal"
compiler        = topLevel "ghc"            `setPath` "compiler"
Andrey Mokhov's avatar
Andrey Mokhov committed
40
41
42
43
containers      = library  "containers"
deepseq         = library  "deepseq"
directory       = library  "directory"
filepath        = library  "filepath"
Andrey Mokhov's avatar
Andrey Mokhov committed
44
ghc             = topLevel "ghc-bin"        `setPath` "ghc"
45
ghcCabal        = utility  "ghc-cabal"
Andrey Mokhov's avatar
Andrey Mokhov committed
46
47
48
49
ghcPrim         = library  "ghc-prim"
haskeline       = library  "haskeline"
hoopl           = library  "hoopl"
hpc             = library  "hpc"
50
51
integerGmp      = library  "integer-gmp"
integerSimple   = library  "integer-simple"
Andrey Mokhov's avatar
Andrey Mokhov committed
52
53
54
55
56
57
58
59
60
61
62
63
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"
64

65

66
-- GHC build results will be placed into target directories with the following
67
-- typical structure:
68
69
70
71
-- * 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'?
72
defaultTargetDirectory :: Stage -> Package -> FilePath
73
74
75
76
77
78
79
80
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
81
82
83
    | pkg == ghc      = program $ "ghc-stage" ++ show (fromEnum stage + 1)
    | pkg == ghcCabal = program $ pkgName pkg
    | otherwise       = Nothing
84
85
86
  where
    program name = Just $ pkgPath pkg -/- defaultTargetDirectory stage pkg
                                      -/- "build/tmp" -/- name <.> exe