a0d31ce0af7dc5864e7aa1290739d35988e3233d
[hadrian.git] / src / Targets.hs
1 {-# LANGUAGE NoImplicitPrelude #-}
2 module Targets (
3 buildHaddock,
4 targetWays, targetPackages, targetPackagesInStage,
5 IntegerLibraryImpl (..), integerLibraryImpl, integerLibraryName,
6 array, base, binPackageDb, binary, bytestring, cabal, containers, deepseq,
7 directory, filepath, ghcPrim, haskeline, hoopl, hpc, integerLibrary,
8 parallel, pretty, primitive, process, stm, templateHaskell, terminfo, time,
9 transformers, unix, win32, xhtml
10 ) where
11
12 import Ways
13 import Base
14 import Package
15 import Expression.Base
16
17 buildHaddock :: BuildPredicate
18 buildHaddock = true
19
20 -- These are the packages we build
21 targetPackages :: Packages
22 targetPackages =
23 [ stage Stage0 ? packagesStage0
24 , stage Stage1 ? packagesStage1 ]
25
26 packagesStage0 :: Packages
27 packagesStage0 = mconcat
28 [ fromList [ binPackageDb, binary, cabal, hoopl, hpc, transformers ]
29 , windowsHost && not (targetOs "ios") ? terminfo ]
30
31 packagesStage1 :: Packages
32 packagesStage1 = msum
33 [ packagesStage0
34 , fromList [ array, base, bytestring, containers, deepseq, directory
35 , filepath, ghcPrim, haskeline, integerLibrary, parallel
36 , pretty, primitive, process, stm, templateHaskell, time ]
37 , not windowsHost ? unix
38 , windowsHost ? win32
39 , buildHaddock ? xhtml ]
40
41 -- Packages will be build these ways
42 targetWays :: Ways
43 targetWays = msum
44 [ return vanilla -- always build vanilla
45 , notStage Stage0 ? return profiling
46 , platformSupportsSharedLibs ? return dynamic ]
47
48 -- Build results will be placed into a target directory with the following
49 -- typical structure:
50 -- * build/ : contains compiled object code
51 -- * doc/ : produced by haddock
52 -- * package-data.mk : contains output of ghc-cabal applied to pkgCabal
53 targetDirectories :: FilePaths
54 targetDirectories =
55 stage Stage0 ?? (return "dist-boot", return "dist-install")
56
57 -- Support for multiple integer library implementations
58 data IntegerLibraryImpl = IntegerGmp | IntegerGmp2 | IntegerSimple
59
60 integerLibraryImpl :: IntegerLibraryImpl
61 integerLibraryImpl = IntegerGmp2
62
63 integerLibraryName :: String
64 integerLibraryName = case integerLibraryImpl of
65 IntegerGmp -> "integer-gmp"
66 IntegerGmp2 -> "integer-gmp2"
67 IntegerSimple -> "integer-simple"
68
69 -- see Note [Cabal name weirdness]
70 integerLibraryCabal :: FilePath
71 integerLibraryCabal = case integerLibraryImpl of
72 IntegerGmp -> "integer-gmp.cabal"
73 IntegerGmp2 -> "integer-gmp.cabal" -- Indeed, why make life easier?
74 IntegerSimple -> "integer-simple.cabal"
75
76 -- Package definitions
77 array, base, binPackageDb, binary, bytestring, cabal, containers, deepseq,
78 directory, filepath, ghcPrim, haskeline, hoopl, hpc, integerLibrary,
79 parallel, pretty, primitive, process, stm, templateHaskell, terminfo, time,
80 transformers, unix, win32, xhtml :: Package
81
82 array = library "array"
83 base = library "base"
84 binPackageDb = library "bin-package-db"
85 binary = library "binary"
86 bytestring = library "bytestring"
87 cabal = library "Cabal/Cabal" `setCabal` "Cabal.cabal"
88 containers = library "containers"
89 deepseq = library "deepseq"
90 directory = library "directory"
91 filepath = library "filepath"
92 ghcPrim = library "ghc-prim"
93 haskeline = library "haskeline"
94 hoopl = library "hoopl"
95 hpc = library "hpc"
96 integerLibrary = library integerLibraryName `setCabal` integerLibraryCabal
97 parallel = library "parallel"
98 pretty = library "pretty"
99 primitive = library "primitive"
100 process = library "process"
101 stm = library "stm"
102 templateHaskell = library "template-haskell"
103 terminfo = library "terminfo"
104 time = library "time"
105 transformers = library "transformers"
106 unix = library "unix"
107 win32 = library "Win32"
108 xhtml = library "xhtml"
109
110 -- TODISCUSS
111 -- Note [Cabal name weirdness]
112 -- Find out if we can move the contents to just Cabal/
113 -- What is Cabal/cabal-install? Do we need it?
114 -- A related question about gmp2 -- let's rename the cabal file?