Drop redundant brackets.
[hadrian.git] / src / Settings / Paths.hs
1 module Settings.Paths (
2 contextDirectory, contextPath, pkgDataFile, pkgHaddockFile, pkgLibraryFile,
3 pkgLibraryFile0, pkgGhciLibraryFile, gmpBuildPath, gmpBuildInfoPath,
4 packageDbDirectory, pkgConfFile
5 ) where
6
7 import Base
8 import Context
9 import Expression
10 import GHC
11 import Oracles.PackageData
12 import Settings.User
13
14 -- Path to the target directory from GHC source root
15 contextPath :: Context -> FilePath
16 contextPath context @ Context {..} =
17 buildRootPath -/- contextDirectory context -/- pkgPath package
18
19 pkgDataFile :: Context -> FilePath
20 pkgDataFile context = contextPath context -/- "package-data.mk"
21
22 -- Relative path to a package haddock file, e.g.:
23 -- "libraries/array/dist-install/doc/html/array/array.haddock"
24 pkgHaddockFile :: Context -> FilePath
25 pkgHaddockFile context @ Context {..} =
26 contextPath context -/- "doc/html" -/- name -/- name <.> "haddock"
27 where name = pkgNameString package
28
29 -- Relative path to a package library file, e.g.:
30 -- "libraries/array/stage2/build/libHSarray-0.5.1.0.a"
31 pkgLibraryFile :: Context -> Action FilePath
32 pkgLibraryFile context @ Context {..} = do
33 extension <- libsuf way
34 pkgFile context "build/libHS" extension
35
36 pkgLibraryFile0 :: Context -> Action FilePath
37 pkgLibraryFile0 context @ Context {..} = do
38 extension <- libsuf way
39 pkgFile context "build/libHS" ("-0" ++ extension)
40
41 -- Relative path to a package ghci library file, e.g.:
42 -- "libraries/array/dist-install/build/HSarray-0.5.1.0.o"
43 pkgGhciLibraryFile :: Context -> Action FilePath
44 pkgGhciLibraryFile context = pkgFile context "build/HS" ".o"
45
46 pkgFile :: Context -> String -> String -> Action FilePath
47 pkgFile context prefix suffix = do
48 let path = contextPath context
49 componentId <- pkgData $ ComponentId path
50 return $ path -/- prefix ++ componentId ++ suffix
51
52 -- This is the build directory for in-tree GMP library
53 gmpBuildPath :: FilePath
54 gmpBuildPath = buildRootPath -/- "stage1/gmp"
55
56 -- We extract system gmp library name from this file
57 gmpBuildInfoPath :: FilePath
58 gmpBuildInfoPath = pkgPath integerGmp -/- "integer-gmp.buildinfo"
59
60 -- TODO: move to buildRootPath, see #113
61 -- StageN, N > 0, share the same packageDbDirectory
62 packageDbDirectory :: Stage -> FilePath
63 packageDbDirectory Stage0 = buildRootPath -/- "stage0/bootstrapping.conf"
64 packageDbDirectory _ = "inplace/lib/package.conf.d"
65
66 pkgConfFile :: Context -> Action FilePath
67 pkgConfFile context @ Context {..} = do
68 componentId <- pkgData . ComponentId $ contextPath context
69 return $ packageDbDirectory stage -/- componentId <.> "conf"