Make PackageName into a proper newtype
[hadrian.git] / src / Settings / TargetDirectory.hs
1 module Settings.TargetDirectory (
2 targetDirectory, targetPath, pkgDataFile, pkgHaddockFile, pkgLibraryFile,
3 pkgGhciLibraryFile
4 ) where
5
6 import Expression
7 import Settings.User
8
9 -- TODO: move to Settings.hs?
10
11 -- User can override the default target directory settings given below
12 targetDirectory :: Stage -> Package -> FilePath
13 targetDirectory = userTargetDirectory
14
15 -- Path to the target directory from GHC source root
16 targetPath :: Stage -> Package -> FilePath
17 targetPath stage pkg = pkgPath pkg -/- targetDirectory stage pkg
18
19 pkgDataFile :: Stage -> Package -> FilePath
20 pkgDataFile stage pkg = targetPath stage pkg -/- "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 :: Package -> FilePath
25 pkgHaddockFile pkg =
26 targetPath Stage1 pkg -/- "doc/html" -/- name -/- name <.> "haddock"
27 where name = pkgNameString pkg
28
29 -- Relative path to a package library file, e.g.:
30 -- "libraries/array/dist-install/build/libHSarray-0.5.1.0.a"
31 -- TODO: remove code duplication for computing buildPath
32 pkgLibraryFile :: Stage -> Package -> String -> Way -> Action FilePath
33 pkgLibraryFile stage pkg componentId way = do
34 extension <- libsuf way
35 let buildPath = targetPath stage pkg -/- "build"
36 return $ buildPath -/- "libHS" ++ componentId <.> extension
37
38 -- Relative path to a package ghci library file, e.g.:
39 -- "libraries/array/dist-install/build/HSarray-0.5.1.0.o"
40 pkgGhciLibraryFile :: Stage -> Package -> String -> FilePath
41 pkgGhciLibraryFile stage pkg componentId =
42 targetPath stage pkg -/- "build" -/- "HS" ++ componentId <.> "o"