Skip to content

Commit b96c601

Browse files
authored
Merge pull request #5812 from haskell/munged-rep
Change MungedPackageName to not be opaque
2 parents 5a1ca1f + 1a6e273 commit b96c601

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+483
-424
lines changed

Cabal/Cabal.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ library
370370
Distribution.Types.LibraryName
371371
Distribution.Types.MungedPackageName
372372
Distribution.Types.PackageName
373+
Distribution.Types.PackageName.Magic
373374
Distribution.Types.PkgconfigName
374375
Distribution.Types.UnqualComponentName
375376
Distribution.Types.IncludeRenaming

Cabal/Distribution/Backpack/ComponentsGraph.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ mkComponentsGraph enabled pkg_descr =
7373
where
7474
bi = componentBuildInfo component
7575
internalPkgDeps = map (conv . libName) (allLibraries pkg_descr)
76-
conv Nothing = packageNameToUnqualComponentName $ packageName pkg_descr
77-
conv (Just s) = s
76+
77+
conv LMainLibName = packageNameToUnqualComponentName $ packageName pkg_descr
78+
conv (LSubLibName s) = s
7879

7980
-- | Given the package description and a 'PackageDescription' (used
8081
-- to determine if a package name is internal or not), sort the

Cabal/Distribution/Backpack/Configure.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import Distribution.Simple.LocalBuildInfo
4141
import Distribution.Types.AnnotatedId
4242
import Distribution.Types.ComponentRequestedSpec
4343
import Distribution.Types.ComponentInclude
44+
import Distribution.Types.MungedPackageName
4445
import Distribution.Verbosity
4546
import qualified Distribution.Compat.Graph as Graph
4647
import Distribution.Compat.Graph (Graph, IsNode(..))
@@ -277,7 +278,7 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
277278
Right instc -> [ (m, OpenModule (DefiniteUnitId uid') m')
278279
| (m, Module uid' m') <- instc_insts instc ]
279280

280-
compat_name = computeCompatPackageName (packageName rc) (libName lib)
281+
compat_name = MungedPackageName (packageName rc) (libName lib)
281282
compat_key = computeCompatPackageKey comp compat_name (packageVersion rc) this_uid
282283

283284
in LibComponentLocalBuildInfo {

Cabal/Distribution/Backpack/ConfiguredComponent.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,4 @@ fixFakePkgName pkg_descr pn =
315315
else (pn, CLibName LMainLibName )
316316
where
317317
subLibName = packageNameToUnqualComponentName pn
318-
internalLibraries = mapMaybe libName (allLibraries pkg_descr)
318+
internalLibraries = mapMaybe (libraryNameString . libName) (allLibraries pkg_descr)

Cabal/Distribution/Backpack/Id.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
module Distribution.Backpack.Id(
66
computeComponentId,
77
computeCompatPackageKey,
8-
computeCompatPackageName,
98
) where
109

1110
import Prelude ()

Cabal/Distribution/Backpack/PreExistingComponent.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ipiToPreExistingComponent :: InstalledPackageInfo -> PreExistingComponent
4646
ipiToPreExistingComponent ipi =
4747
PreExistingComponent {
4848
pc_pkgname = packageName ipi,
49-
pc_compname = libraryComponentName $ Installed.sourceLibName ipi,
49+
pc_compname = CLibName $ Installed.sourceLibName ipi,
5050
pc_munged_id = mungedId ipi,
5151
pc_uid = Installed.installedUnitId ipi,
5252
pc_cid = Installed.installedComponentId ipi,

Cabal/Distribution/Backpack/ReadyComponent.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ import Distribution.Types.Component
2525
import Distribution.Types.ComponentInclude
2626
import Distribution.Types.ComponentId
2727
import Distribution.Types.ComponentName
28-
import Distribution.Types.LibraryName
2928
import Distribution.Types.PackageId
29+
import Distribution.Types.PackageName.Magic
3030
import Distribution.Types.UnitId
3131
import Distribution.Compat.Graph (IsNode(..))
3232
import Distribution.Types.Module
3333
import Distribution.Types.MungedPackageId
3434
import Distribution.Types.MungedPackageName
3535
import Distribution.Types.Library
36+
import Distribution.Types.LibraryName
3637

3738
import Distribution.ModuleName
3839
import Distribution.Package
@@ -140,8 +141,7 @@ rc_depends rc = ordNub $
140141
computeCompatPackageId
141142
(ci_pkgid ci)
142143
(case ci_cname ci of
143-
CLibName LMainLibName -> Nothing
144-
CLibName (LSubLibName uqn) -> Just uqn
144+
CLibName name -> name
145145
_ -> error $ prettyShow (rc_cid rc) ++
146146
" depends on non-library " ++ prettyShow (ci_id ci))
147147

@@ -275,7 +275,7 @@ toReadyComponents pid_map subst0 comps
275275
fmap rc_munged_id (join (Map.lookup dep_uid s)))]
276276
where
277277
err_pid = MungedPackageId
278-
(mkMungedPackageName "nonexistent-package-this-is-a-cabal-bug")
278+
(MungedPackageName nonExistentPackageThisIsCabalBug LMainLibName)
279279
(mkVersion [0])
280280
instc = InstantiatedComponent {
281281
instc_insts = Map.toList insts,

Cabal/Distribution/InstalledPackageInfo.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import Distribution.FieldGrammar.FieldDescrs
5252
import Distribution.ModuleName
5353
import Distribution.Package hiding (installedPackageId, installedUnitId)
5454
import Distribution.Types.ComponentName
55-
import Distribution.Types.LibraryName
5655
import Distribution.Utils.Generic (toUTF8BS)
5756

5857
import qualified Data.Map as Map
@@ -97,10 +96,7 @@ installedPackageId = installedUnitId
9796
-- Munging
9897

9998
sourceComponentName :: InstalledPackageInfo -> ComponentName
100-
sourceComponentName ipi =
101-
case sourceLibName ipi of
102-
Nothing -> CLibName LMainLibName
103-
Just qn -> CLibName $ LSubLibName qn
99+
sourceComponentName = CLibName . sourceLibName
104100

105101
-- -----------------------------------------------------------------------------
106102
-- Parsing

Cabal/Distribution/PackageDescription/Check.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import Distribution.System
5454
import Distribution.Types.ComponentRequestedSpec
5555
import Distribution.Types.CondTree
5656
import Distribution.Types.ExeDependency
57+
import Distribution.Types.LibraryName
5758
import Distribution.Types.UnqualComponentName
5859
import Distribution.Utils.Generic (isAscii)
5960
import Distribution.Verbosity
@@ -195,7 +196,7 @@ checkSanity pkg =
195196
PackageBuildImpossible
196197
"No executables, libraries, tests, or benchmarks found. Nothing to do."
197198

198-
, check (any isNothing (map libName $ subLibraries pkg)) $
199+
, check (any (== LMainLibName) (map libName $ subLibraries pkg)) $
199200
PackageBuildImpossible $ "Found one or more unnamed internal libraries. "
200201
++ "Only the non-internal library can have the same name as the package."
201202

@@ -236,7 +237,7 @@ checkSanity pkg =
236237
-- The public 'library' gets special dispensation, because it
237238
-- is common practice to export a library and name the executable
238239
-- the same as the package.
239-
subLibNames = catMaybes . map libName $ subLibraries pkg
240+
subLibNames = mapMaybe (libraryNameString . libName) $ subLibraries pkg
240241
exeNames = map exeName $ executables pkg
241242
testNames = map testName $ testSuites pkg
242243
bmNames = map benchmarkName $ benchmarks pkg
@@ -254,10 +255,7 @@ checkLibrary pkg lib =
254255
-- TODO: This check is bogus if a required-signature was passed through
255256
, check (null (explicitLibModules lib) && null (reexportedModules lib)) $
256257
PackageDistSuspiciousWarn $
257-
"Library " ++ (case libName lib of
258-
Nothing -> ""
259-
Just n -> prettyShow n
260-
) ++ "does not expose any modules"
258+
showLibraryName (libName lib) ++ " does not expose any modules"
261259

262260
-- check use of signatures sections
263261
, checkVersion [1,25] (not (null (signatures lib))) $
@@ -589,7 +587,7 @@ checkFields pkg =
589587
, isNoVersion vr ]
590588

591589
internalLibraries =
592-
map (maybe (packageName pkg) (unqualComponentNameToPackageName) . libName)
590+
map (maybe (packageName pkg) (unqualComponentNameToPackageName) . libraryNameString . libName)
593591
(allLibraries pkg)
594592

595593
internalExecutables = map exeName $ executables pkg

Cabal/Distribution/PackageDescription/Configuration.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ finalizePD userflags enabled satisfyDep
455455
(mb_lib, comps) = flattenTaggedTargets targetSet
456456
mb_lib' = fmap libFillInDefaults mb_lib
457457
comps' = flip map comps $ \(n,c) -> foldComponent
458-
(\l -> CLib (libFillInDefaults l) { libName = Just n
458+
(\l -> CLib (libFillInDefaults l) { libName = LSubLibName n
459459
, libExposed = False })
460460
(\l -> CFLib (flibFillInDefaults l) { foreignLibName = n })
461461
(\e -> CExe (exeFillInDefaults e) { exeName = n })
@@ -541,14 +541,14 @@ flattenPackageDescription
541541
}
542542
where
543543
mlib = f <$> mlib0
544-
where f lib = (libFillInDefaults . fst . ignoreConditions $ lib) { libName = Nothing }
544+
where f lib = (libFillInDefaults . fst . ignoreConditions $ lib) { libName = LMainLibName }
545545
sub_libs = flattenLib <$> sub_libs0
546546
flibs = flattenFLib <$> flibs0
547547
exes = flattenExe <$> exes0
548548
tests = flattenTst <$> tests0
549549
bms = flattenBm <$> bms0
550550
flattenLib (n, t) = libFillInDefaults $ (fst $ ignoreConditions t)
551-
{ libName = Just n, libExposed = False }
551+
{ libName = LSubLibName n, libExposed = False }
552552
flattenFLib (n, t) = flibFillInDefaults $ (fst $ ignoreConditions t)
553553
{ foreignLibName = n }
554554
flattenExe (n, t) = exeFillInDefaults $ (fst $ ignoreConditions t)

0 commit comments

Comments
 (0)