@@ -32,7 +32,6 @@ import Distribution.Types.PackageName
32
32
import Distribution.Types.Mixin
33
33
import Distribution.Types.ComponentName
34
34
import Distribution.Types.LibraryName
35
- import Distribution.Types.UnqualComponentName
36
35
import Distribution.Types.ComponentInclude
37
36
import Distribution.Package
38
37
import Distribution.PackageDescription
@@ -48,7 +47,8 @@ import qualified Data.Set as Set
48
47
import qualified Distribution.Compat.NonEmptySet as NonEmptySet
49
48
import qualified Data.Map as Map
50
49
import Distribution.Pretty
51
- import Text.PrettyPrint
50
+ import Text.PrettyPrint (Doc , hang , text , vcat , hsep , quotes , ($$) )
51
+ import qualified Text.PrettyPrint as PP
52
52
53
53
-- | A configured component, we know exactly what its 'ComponentId' is,
54
54
-- and the 'ComponentId's of the things it depends on.
@@ -112,13 +112,12 @@ mkConfiguredComponent
112
112
mkConfiguredComponent pkg_descr this_cid lib_deps exe_deps component = do
113
113
-- Resolve each @mixins@ into the actual dependency
114
114
-- from @lib_deps@.
115
- explicit_includes <- forM (mixins bi) $ \ (Mixin name rns) -> do
116
- let keys = fixFakePkgName pkg_descr name
117
- aid <- case Map. lookup keys deps_map of
115
+ explicit_includes <- forM (mixins bi) $ \ (Mixin pn ln rns) -> do
116
+ aid <- case Map. lookup (pn, CLibName ln) deps_map of
118
117
Nothing ->
119
118
dieProgress $
120
- text " Mix-in refers to non-existent package " <+>
121
- quotes (pretty name ) $$
119
+ text " Mix-in refers to non-existent library " <+>
120
+ quotes (pretty pn <<>> prettyLN ln ) $$
122
121
text " (did you forget to add the package to build-depends?)"
123
122
Just r -> return r
124
123
return ComponentInclude {
@@ -150,9 +149,17 @@ mkConfiguredComponent pkg_descr this_cid lib_deps exe_deps component = do
150
149
cc_includes = explicit_includes ++ implicit_includes
151
150
}
152
151
where
152
+ bi :: BuildInfo
153
153
bi = componentBuildInfo component
154
+
155
+ prettyLN :: LibraryName -> Doc
156
+ prettyLN LMainLibName = PP. empty
157
+ prettyLN (LSubLibName n) = PP. colon <<>> pretty n
158
+
159
+ deps_map :: Map (PackageName , ComponentName ) (AnnotatedId ComponentId )
154
160
deps_map = Map. fromList [ ((packageName dep, ann_cname dep), dep)
155
161
| dep <- lib_deps ]
162
+
156
163
is_public = componentName component == CLibName LMainLibName
157
164
158
165
type ConfiguredComponentMap =
@@ -179,10 +186,7 @@ toConfiguredComponent pkg_descr this_cid lib_dep_map exe_dep_map component = do
179
186
-- Return all library components
180
187
forM (NonEmptySet. toList sublibs) $ \ lib ->
181
188
let comp = CLibName lib in
182
- case Map. lookup (CLibName $ LSubLibName $
183
- packageNameToUnqualComponentName name) pkg
184
- <|> Map. lookup comp pkg
185
- of
189
+ case Map. lookup comp pkg of
186
190
Nothing ->
187
191
dieProgress $
188
192
text " Dependency on unbuildable" <+>
@@ -302,19 +306,3 @@ newPackageDepsBehaviourMinVersion = CabalSpecV1_8
302
306
newPackageDepsBehaviour :: PackageDescription -> Bool
303
307
newPackageDepsBehaviour pkg =
304
308
specVersion pkg >= newPackageDepsBehaviourMinVersion
305
-
306
- -- | 'build-depends:' stanzas are currently ambiguous as the external packages
307
- -- and internal libraries are specified the same. For now, we assume internal
308
- -- libraries shadow, and this function disambiguates accordingly, but soon the
309
- -- underlying ambiguity will be addressed.
310
- -- Multiple public libraries (cabal 3.0) added an unambiguous way of specifying
311
- -- sublibraries, but we still have to support the old syntax for bc reasons.
312
- fixFakePkgName :: PackageDescription -> PackageName -> (PackageName , ComponentName )
313
- fixFakePkgName pkg_descr pn =
314
- if subLibName `elem` internalLibraries
315
- then (packageName pkg_descr, CLibName (LSubLibName subLibName))
316
- else (pn, CLibName LMainLibName )
317
- where
318
- subLibName = packageNameToUnqualComponentName pn
319
- internalLibraries = mapMaybe (libraryNameString . libName)
320
- (allLibraries pkg_descr)
0 commit comments