Refactor package-specific settings (#622)
[hadrian.git] / src / Context / Path.hs
1 module Context.Path where
2
3 import Base
4 import Context.Type
5 import Hadrian.Expression
6
7 -- | The build directory of the current 'Stage'.
8 stageDir :: Context -> FilePath
9 stageDir Context {..} = stageString stage
10
11 -- | The build path of the current 'Stage'.
12 stagePath :: Context -> Action FilePath
13 stagePath context = buildRoot <&> (-/- stageDir context)
14
15 -- | The expression that evaluates to the build path of the current 'Stage'.
16 getStagePath :: Expr Context b FilePath
17 getStagePath = expr . stagePath =<< getContext
18
19 -- | The directory in 'buildRoot' containing build artifacts of a given 'Context'.
20 contextDir :: Context -> FilePath
21 contextDir Context {..} = stageString stage -/- pkgPath package
22
23 -- | The path to the directory in 'buildRoot' containing build artifacts of a
24 -- given 'Context'.
25 contextPath :: Context -> Action FilePath
26 contextPath context = buildRoot <&> (-/- contextDir context)
27
28 -- | The expression that evaluates to the path to the directory in 'buildRoot'
29 -- containing build artifacts of a given 'Context'.
30 getContextPath :: Expr Context b FilePath
31 getContextPath = expr . contextPath =<< getContext
32
33 -- | The directory in 'buildRoot' containing the object artifacts.
34 buildDir :: Context -> FilePath
35 buildDir context = contextDir context -/- "build"
36
37 -- | Path to the directory containing build artifacts of a given 'Context'.
38 buildPath :: Context -> Action FilePath
39 buildPath context = buildRoot <&> (-/- buildDir context)
40
41 -- | The expression that evaluates to the build path of the current 'Context'.
42 getBuildPath :: Expr Context b FilePath
43 getBuildPath = expr . buildPath =<< getContext