1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE TypeFamilies #-}
5 module Distribution
.Types
.ComponentLocalBuildInfo
6 ( ComponentLocalBuildInfo
(..)
7 , componentIsIndefinite
8 , maybeComponentInstantiatedWith
9 , maybeComponentCompatPackageKey
10 , maybeComponentExposedModules
13 import Distribution
.Compat
.Prelude
14 import Distribution
.ModuleName
17 import Distribution
.Backpack
18 import Distribution
.Compat
.Graph
19 import Distribution
.Types
.ComponentId
20 import Distribution
.Types
.ComponentName
21 import Distribution
.Types
.ModuleRenaming
22 import Distribution
.Types
.MungedPackageId
23 import Distribution
.Types
.MungedPackageName
24 import Distribution
.Types
.UnitId
26 import qualified Distribution
.InstalledPackageInfo
as Installed
28 -- | The first five fields are common across all algebraic variants.
29 data ComponentLocalBuildInfo
30 = LibComponentLocalBuildInfo
31 { componentLocalName
:: ComponentName
32 -- ^ It would be very convenient to store the literal Library here,
33 -- but if we do that, it will get serialized (via the Binary)
34 -- instance twice. So instead we just provide the ComponentName,
35 -- which can be used to find the Component in the
36 -- PackageDescription. NB: eventually, this will NOT uniquely
37 -- identify the ComponentLocalBuildInfo.
38 , componentComponentId
:: ComponentId
39 -- ^ The computed 'ComponentId' of this component.
40 , componentUnitId
:: UnitId
41 -- ^ The computed 'UnitId' which uniquely identifies this
42 -- component. Might be hashed.
43 , componentIsIndefinite_
:: Bool
44 -- ^ Is this an indefinite component (i.e. has unfilled holes)?
45 , componentInstantiatedWith
:: [(ModuleName
, OpenModule
)]
46 -- ^ How the component was instantiated
47 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
48 -- ^ Resolved internal and external package dependencies for this component.
49 -- The 'BuildInfo' specifies a set of build dependencies that must be
50 -- satisfied in terms of version ranges. This field fixes those dependencies
51 -- to the specific versions available on this machine for this compiler.
52 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
53 -- ^ The set of packages that are brought into scope during
54 -- compilation, including a 'ModuleRenaming' which may used
55 -- to hide or rename modules. This is what gets translated into
56 -- @-package-id@ arguments. This is a modernized version of
57 -- 'componentPackageDeps', which is kept around for BC purposes.
58 , componentExeDeps
:: [UnitId
]
59 , componentInternalDeps
:: [UnitId
]
60 -- ^ The internal dependencies which induce a graph on the
61 -- 'ComponentLocalBuildInfo' of this package. This does NOT
62 -- coincide with 'componentPackageDeps' because it ALSO records
63 -- 'build-tool' dependencies on executables. Maybe one day
64 -- @cabal-install@ will also handle these correctly too!
65 , componentCompatPackageKey
:: String
66 -- ^ Compatibility "package key" that we pass to older versions of GHC.
67 , componentCompatPackageName
:: MungedPackageName
68 -- ^ Compatibility "package name" that we register this component as.
69 , componentExposedModules
:: [Installed
.ExposedModule
]
70 -- ^ A list of exposed modules (either defined in this component,
71 -- or reexported from another component.)
72 , componentIsPublic
:: Bool
73 -- ^ Convenience field, specifying whether or not this is the
74 -- "public library" that has the same name as the package.
76 |
-- TODO: refactor all these duplicates
77 FLibComponentLocalBuildInfo
78 { componentLocalName
:: ComponentName
79 , componentComponentId
:: ComponentId
80 , componentUnitId
:: UnitId
81 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
82 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
83 , componentExeDeps
:: [UnitId
]
84 , componentInternalDeps
:: [UnitId
]
86 | ExeComponentLocalBuildInfo
87 { componentLocalName
:: ComponentName
88 , componentComponentId
:: ComponentId
89 , componentUnitId
:: UnitId
90 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
91 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
92 , componentExeDeps
:: [UnitId
]
93 , componentInternalDeps
:: [UnitId
]
95 | TestComponentLocalBuildInfo
96 { componentLocalName
:: ComponentName
97 , componentComponentId
:: ComponentId
98 , componentUnitId
:: UnitId
99 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
100 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
101 , componentExeDeps
:: [UnitId
]
102 , componentInternalDeps
:: [UnitId
]
104 | BenchComponentLocalBuildInfo
105 { componentLocalName
:: ComponentName
106 , componentComponentId
:: ComponentId
107 , componentUnitId
:: UnitId
108 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
109 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
110 , componentExeDeps
:: [UnitId
]
111 , componentInternalDeps
:: [UnitId
]
113 deriving (Generic
, Read, Show, Typeable
)
115 instance Binary ComponentLocalBuildInfo
116 instance Structured ComponentLocalBuildInfo
118 instance IsNode ComponentLocalBuildInfo
where
119 type Key ComponentLocalBuildInfo
= UnitId
120 nodeKey
= componentUnitId
121 nodeNeighbors
= componentInternalDeps
123 componentIsIndefinite
:: ComponentLocalBuildInfo
-> Bool
124 componentIsIndefinite LibComponentLocalBuildInfo
{componentIsIndefinite_
= b
} = b
125 componentIsIndefinite _
= False
127 maybeComponentInstantiatedWith
:: ComponentLocalBuildInfo
-> Maybe [(ModuleName
, OpenModule
)]
128 maybeComponentInstantiatedWith
129 LibComponentLocalBuildInfo
{componentInstantiatedWith
= insts
} = Just insts
130 maybeComponentInstantiatedWith _
= Nothing
132 maybeComponentCompatPackageKey
:: ComponentLocalBuildInfo
-> Maybe String
133 maybeComponentCompatPackageKey
134 LibComponentLocalBuildInfo
{componentCompatPackageKey
= key
} = Just key
135 maybeComponentCompatPackageKey _
= Nothing
137 maybeComponentExposedModules
:: ComponentLocalBuildInfo
-> Maybe [Installed
.ExposedModule
]
138 maybeComponentExposedModules
139 LibComponentLocalBuildInfo
{componentExposedModules
= exposed
} = Just exposed
140 maybeComponentExposedModules _
= Nothing