Drop redundant brackets.
[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, ghcCabal, ghci, ghcPkg, ghcPrim, ghcTags,
6 ghcSplit, haddock, haskeline, hsc2hs, hoopl, hp2ps, hpc, hpcBin, integerGmp,
7 integerSimple, iservBin, libffi, mkUserGuidePart, parallel, pretty,
8 primitive, process, rts, runGhc, stm, templateHaskell, terminfo, time,
9 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, 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, ghcCabal, ghci, ghcPkg, ghcPrim, ghcTags,
38 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 ghcCabal = utility "ghc-cabal"
61 ghci = library "ghci"
62 ghcPkg = utility "ghc-pkg"
63 ghcPrim = library "ghc-prim"
64 ghcTags = utility "ghctags"
65 haddock = utility "haddock"
66 haskeline = library "haskeline"
67 hsc2hs = utility "hsc2hs"
68 hoopl = library "hoopl"
69 hp2ps = utility "hp2ps"
70 hpc = library "hpc"
71 hpcBin = utility "hpc-bin" `setPath` "utils/hpc"
72 integerGmp = library "integer-gmp"
73 integerSimple = library "integer-simple"
74 iservBin = topLevel "iserv-bin" `setPath` "iserv" `setType` Program
75 libffi = topLevel "libffi"
76 mkUserGuidePart = utility "mkUserGuidePart"
77 parallel = library "parallel"
78 pretty = library "pretty"
79 primitive = library "primitive"
80 process = library "process"
81 rts = topLevel "rts"
82 runGhc = utility "runghc"
83 stm = library "stm"
84 templateHaskell = library "template-haskell"
85 terminfo = library "terminfo"
86 time = library "time"
87 touchy = utility "touchy"
88 transformers = library "transformers"
89 unlit = utility "unlit"
90 unix = library "unix"
91 win32 = library "Win32"
92 xhtml = library "xhtml"
93
94 -- | ghc-split is a perl script used by GHC with @-split-objs@ flag. It is
95 -- generated in "Rules.Generators.GhcSplit".
96 ghcSplit :: FilePath
97 ghcSplit = "inplace/lib/bin/ghc-split"
98
99 -- TODO: The following utils are not included into the build system because
100 -- they seem to be unused or unrelated to the build process: checkUniques,
101 -- completion, count_lines, coverity, debugNGC, describe-unexpected, genargs,
102 -- lndir, mkdirhier, testremove, vagrant
103
104 -- TODO: move to buildRootPath, see #113
105 -- TODO: simplify, add programInplaceLibPath
106 -- | The relative path to the program executable
107 programPath :: Context -> Maybe FilePath
108 programPath context @ Context {..}
109 | package == ghc = Just . inplaceProgram $ "ghc-stage" ++ show (fromEnum stage + 1)
110 | package `elem` [ghcTags, haddock, mkUserGuidePart] = case stage of
111 Stage2 -> Just . inplaceProgram $ pkgNameString package
112 _ -> Nothing
113 | package `elem` [touchy, unlit] = case stage of
114 Stage0 -> Just $ "inplace/lib/bin" -/- pkgNameString package <.> exe
115 _ -> Nothing
116 | package == hpcBin = case stage of
117 Stage1 -> Just $ inplaceProgram "hpc"
118 _ -> Nothing
119 | isProgram package = case stage of
120 Stage0 -> Just . inplaceProgram $ pkgNameString package
121 _ -> Just . installProgram $ pkgNameString package
122 | otherwise = Nothing
123 where
124 inplaceProgram name = programInplacePath -/- name <.> exe
125 installProgram name = pkgPath package -/- contextDirectory context
126 -/- "build/tmp" -/- name <.> exe
127
128 rtsContext :: Context
129 rtsContext = vanillaContext Stage1 rts
130
131 -- | GHC build results will be placed into target directories with the
132 -- following typical structure:
133
134 -- * @build/@ contains compiled object code
135 -- * @doc/@ is produced by haddock
136 -- * @package-data.mk@ contains output of ghc-cabal applied to pkgCabal
137 contextDirectory :: Context -> FilePath
138 contextDirectory Context {..} = stageString stage
139