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