Fix wrapper build
[hadrian.git] / src / Base.hs
1 module Base (
2 -- * General utilities
3 module Control.Applicative,
4 module Control.Monad.Extra,
5 module Data.List.Extra,
6 module Data.Maybe,
7 module Data.Semigroup,
8 module Hadrian.Utilities,
9
10 -- * Shake
11 module Development.Shake,
12 module Development.Shake.Classes,
13 module Development.Shake.FilePath,
14 module Development.Shake.Util,
15
16 -- * Basic data types
17 module Hadrian.Package,
18 module Stage,
19 module Way,
20
21 -- * Paths
22 hadrianPath, configPath, configFile, sourcePath, configH, shakeFilesDir,
23 generatedDir, inplaceBinPath, inplaceLibBinPath, inplaceLibPath,
24 inplaceLibCopyTargets, templateHscPath, stage0PackageDbDir,
25 inplacePackageDbPath, packageDbStamp
26 ) where
27
28 import Control.Applicative
29 import Control.Monad.Extra
30 import Control.Monad.Reader
31 import Data.List.Extra
32 import Data.Maybe
33 import Data.Semigroup
34 import Development.Shake hiding (parallel, unit, (*>), Normal)
35 import Development.Shake.Classes
36 import Development.Shake.FilePath
37 import Development.Shake.Util
38 import Hadrian.Utilities
39 import Hadrian.Package
40
41 import Stage
42 import Way
43
44 -- | Hadrian lives in the 'hadrianPath' directory of the GHC tree.
45 hadrianPath :: FilePath
46 hadrianPath = "hadrian"
47
48 -- TODO: Move this to build directory?
49 -- | Path to system configuration files, such as 'configFile'.
50 configPath :: FilePath
51 configPath = hadrianPath -/- "cfg"
52
53 -- | Path to the system configuration file generated by the @configure@ script.
54 configFile :: FilePath
55 configFile = configPath -/- "system.config"
56
57 -- | Path to source files of the build system, e.g. this file is located at
58 -- @sourcePath -/- "Base.hs"@. We use this to track some of the source files.
59 sourcePath :: FilePath
60 sourcePath = hadrianPath -/- "src"
61
62 -- TODO: Change @mk/config.h@ to @shake-build/cfg/config.h@.
63 -- | Path to the generated @mk/config.h@ file.
64 configH :: FilePath
65 configH = "mk/config.h"
66
67 -- | The directory in 'buildRoot' containing the Shake database and other
68 -- auxiliary files generated by Hadrian.
69 shakeFilesDir :: FilePath
70 shakeFilesDir = "hadrian"
71
72 -- | The directory in 'buildRoot' containing generated source files that are not
73 -- package-specific, e.g. @ghcplatform.h@.
74 generatedDir :: FilePath
75 generatedDir = "generated"
76
77 -- | The directory in 'buildRoot' containing the 'Stage0' package database.
78 stage0PackageDbDir :: FilePath
79 stage0PackageDbDir = "stage0/bootstrapping.conf"
80
81 -- | Path to the inplace package database used in 'Stage1' and later.
82 inplacePackageDbPath :: FilePath
83 inplacePackageDbPath = "inplace/lib/package.conf.d"
84
85 -- | We use a stamp file to track the existence of a package database.
86 packageDbStamp :: FilePath
87 packageDbStamp = ".stamp"
88
89 -- | Directory for binaries that are built "in place".
90 inplaceBinPath :: FilePath
91 inplaceBinPath = "inplace/bin"
92
93 -- | Directory for libraries that are built "in place".
94 inplaceLibPath :: FilePath
95 inplaceLibPath = "inplace/lib"
96
97 -- | Directory for binary wrappers, and auxiliary binaries such as @touchy@.
98 inplaceLibBinPath :: FilePath
99 inplaceLibBinPath = "inplace/lib/bin"
100
101 -- ref: ghc/ghc.mk:142
102 -- ref: driver/ghc.mk
103 -- ref: utils/hsc2hs/ghc.mk:35
104 -- | Files that need to be copied over to 'inplaceLibPath'.
105 inplaceLibCopyTargets :: [FilePath]
106 inplaceLibCopyTargets = map (inplaceLibPath -/-)
107 [ "ghc-usage.txt"
108 , "ghci-usage.txt"
109 , "platformConstants"
110 , "settings"
111 , "template-hsc.h" ]
112
113 -- | Path to hsc2hs template.
114 templateHscPath :: FilePath
115 templateHscPath = "inplace/lib/template-hsc.h"