303beca23adec52f26b7af72293397fb289eb1ad
[hadrian.git] / src / GHC.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 module GHC (
3 array, base, binary, bytestring, cabal, compiler, containers, compareSizes,
4 deepseq, deriveConstants, directory, dllSplit, filepath, genapply,
5 genprimopcode, ghc, ghcBoot, ghcBootTh, ghcCabal, ghci, ghcPkg, ghcPrim,
6 ghcTags, ghcSplit, haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin,
7 integerGmp, integerSimple, iservBin, libffi, mkUserGuidePart, parallel,
8 pretty, primitive, process, rts, runGhc, stm, templateHaskell, terminfo,
9 time, touchy, transformers, unlit, unix, win32, xhtml,
10
11 defaultKnownPackages, programPath, contextDirectory, rtsContext
12 ) where
13
14 import Base
15 import Context
16 import Package
17 import Stage
18
19 -- | These are all GHC packages we know about. Build rules will be generated for
20 -- all of them. However, not all of these packages will be built. For example,
21 -- package /win32/ is built only on Windows.
22 -- "Packages" defines default conditions for building each package, which can
23 -- be overridden in "Settings.User".
24 defaultKnownPackages :: [Package]
25 defaultKnownPackages =
26 [ array, base, binary, bytestring, cabal, compiler, containers, compareSizes
27 , deepseq, deriveConstants, directory, dllSplit, filepath, genapply
28 , genprimopcode, ghc, ghcBoot, ghcBootTh, ghcCabal, ghci, ghcPkg, ghcPrim
29 , ghcTags, haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin, integerGmp
30 , integerSimple, iservBin, libffi, mkUserGuidePart, parallel, pretty
31 , primitive, process, rts, runGhc, stm, templateHaskell, terminfo, time
32 , touchy, transformers, unlit, unix, win32, xhtml ]
33
34 -- | Package definitions, see 'Package'.
35 array, base, binary, bytestring, cabal, compiler, containers, compareSizes,
36 deepseq, deriveConstants, directory, dllSplit, filepath, genapply,
37 genprimopcode, ghc, ghcBoot, ghcBootTh, ghcCabal, ghci, ghcPkg, ghcPrim,
38 ghcTags, haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin, integerGmp,
39 integerSimple, iservBin, libffi, mkUserGuidePart, parallel, pretty,
40 primitive, process, rts, runGhc, stm, templateHaskell, terminfo, time,
41 touchy, transformers, unlit, unix, win32, xhtml :: Package
42
43 array = library "array"
44 base = library "base"
45 binary = library "binary"
46 bytestring = library "bytestring"
47 cabal = library "Cabal" `setPath` "libraries/Cabal/Cabal"
48 compiler = topLevel "ghc" `setPath` "compiler"
49 containers = library "containers"
50 compareSizes = utility "compareSizes" `setPath` "utils/compare_sizes"
51 deepseq = library "deepseq"
52 deriveConstants = utility "deriveConstants"
53 directory = library "directory"
54 dllSplit = utility "dll-split"
55 filepath = library "filepath"
56 genapply = utility "genapply"
57 genprimopcode = utility "genprimopcode"
58 ghc = topLevel "ghc-bin" `setPath` "ghc" `setType` Program
59 ghcBoot = library "ghc-boot"
60 ghcBootTh = library "ghc-boot-th"
61 ghcCabal = utility "ghc-cabal"
62 ghci = library "ghci"
63 ghcPkg = utility "ghc-pkg"
64 ghcPrim = library "ghc-prim"
65 ghcTags = utility "ghctags"
66 haddock = utility "haddock"
67 haskeline = library "haskeline"
68 hsc2hs = utility "hsc2hs"
69 hoopl = library "hoopl"
70 hp2ps = utility "hp2ps"
71 hpc = library "hpc"
72 hpcBin = utility "hpc-bin" `setPath` "utils/hpc"
73 integerGmp = library "integer-gmp"
74 integerSimple = library "integer-simple"
75 iservBin = topLevel "iserv-bin" `setPath` "iserv" `setType` Program
76 libffi = topLevel "libffi"
77 mkUserGuidePart = utility "mkUserGuidePart"
78 parallel = library "parallel"
79 pretty = library "pretty"
80 primitive = library "primitive"
81 process = library "process"
82 rts = topLevel "rts"
83 runGhc = utility "runghc"
84 stm = library "stm"
85 templateHaskell = library "template-haskell"
86 terminfo = library "terminfo"
87 time = library "time"
88 touchy = utility "touchy"
89 transformers = library "transformers"
90 unlit = utility "unlit"
91 unix = library "unix"
92 win32 = library "Win32"
93 xhtml = library "xhtml"
94
95 -- | ghc-split is a perl script used by GHC with @-split-objs@ flag. It is
96 -- generated in "Rules.Generators.GhcSplit".
97 ghcSplit :: FilePath
98 ghcSplit = "inplace/lib/bin/ghc-split"
99
100 -- TODO: The following utils are not included into the build system because
101 -- they seem to be unused or unrelated to the build process: checkUniques,
102 -- completion, count_lines, coverity, debugNGC, describe-unexpected, genargs,
103 -- lndir, mkdirhier, testremove, vagrant
104
105 -- TODO: move to buildRootPath, see #113
106 -- TODO: simplify, add programInplaceLibPath
107 -- | The relative path to the program executable
108 programPath :: Context -> Maybe FilePath
109 programPath context@Context {..}
110 | package == ghc = Just . inplaceProgram $ "ghc-stage" ++ show (fromEnum stage + 1)
111 | package `elem` [ghcTags, haddock, mkUserGuidePart] = case stage of
112 Stage2 -> Just . inplaceProgram $ pkgNameString package
113 _ -> Nothing
114 | package `elem` [touchy, unlit] = case stage of
115 Stage0 -> Just $ "inplace/lib/bin" -/- pkgNameString package <.> exe
116 _ -> Nothing
117 | package == hpcBin = case stage of
118 Stage1 -> Just $ inplaceProgram "hpc"
119 _ -> Nothing
120 | isProgram package = case stage of
121 Stage0 -> Just . inplaceProgram $ pkgNameString package
122 _ -> Just . installProgram $ pkgNameString package
123 | otherwise = Nothing
124 where
125 inplaceProgram name = programInplacePath -/- name <.> exe
126 installProgram name = pkgPath package -/- contextDirectory context
127 -/- "build/tmp" -/- name <.> exe
128
129 rtsContext :: Context
130 rtsContext = vanillaContext Stage1 rts
131
132 -- | GHC build results will be placed into target directories with the
133 -- following typical structure:
134
135 -- * @build/@ contains compiled object code
136 -- * @doc/@ is produced by haddock
137 -- * @package-data.mk@ contains output of ghc-cabal applied to pkgCabal
138 contextDirectory :: Context -> FilePath
139 contextDirectory Context {..} = stageString stage
140