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