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