Commit b1b9d3b1 authored by Edward Z. Yang's avatar Edward Z. Yang

Revert "Merge pull request #4382 from Ericson2314/munge"

This reverts commit 332d809c, reversing
changes made to 0c72bc88.
parent 8b1ff6db
......@@ -219,7 +219,6 @@ library
Distribution.Types.PkgconfigDependency
Distribution.Types.DependencyMap
Distribution.Types.ComponentId
Distribution.Types.MungedPackageId
Distribution.Types.PackageId
Distribution.Types.UnitId
Distribution.Types.Executable
......@@ -231,7 +230,6 @@ library
Distribution.Types.ModuleReexport
Distribution.Types.ModuleRenaming
Distribution.Types.ComponentName
Distribution.Types.MungedPackageName
Distribution.Types.PackageName
Distribution.Types.PkgconfigName
Distribution.Types.UnqualComponentName
......
......@@ -39,7 +39,6 @@ import Distribution.Simple.Setup as Setup
import Distribution.Simple.LocalBuildInfo
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ComponentInclude
import Distribution.Types.MungedPackageId
import Distribution.Verbosity
import qualified Distribution.Compat.Graph as Graph
import Distribution.Compat.Graph (Graph, IsNode(..))
......@@ -82,7 +81,7 @@ configureComponentLocalBuildInfos
(dispComponentsGraph graph0)
let conf_pkg_map = Map.fromListWith Map.union
[(pc_pkgname pkg, Map.singleton (pc_compname pkg) (pc_cid pkg, packageId pkg))
[(pc_pkgname pkg, Map.singleton (pc_compname pkg) (pc_cid pkg, pc_pkgid pkg))
| pkg <- prePkgDeps]
graph1 <- toConfiguredComponents use_external_internal_deps
flagAssignment
......@@ -108,9 +107,9 @@ configureComponentLocalBuildInfos
(vcat (map dispLinkedComponent graph2))
let pid_map = Map.fromList $
[ (pc_uid pkg, pc_munged_id pkg)
[ (pc_uid pkg, pc_pkgid pkg)
| pkg <- prePkgDeps] ++
[ (Installed.installedUnitId pkg, Installed.sourceMungedPackageId pkg)
[ (Installed.installedUnitId pkg, Installed.sourcePackageId pkg)
| (_, Module uid _) <- instantiate_with
, Just pkg <- [PackageIndex.lookupUnitId
installedPackageSet (unDefUnitId uid)] ]
......@@ -205,12 +204,12 @@ toComponentLocalBuildInfos
-- TODO: This is probably wrong for Backpack
let pseudoTopPkg :: InstalledPackageInfo
pseudoTopPkg = emptyInstalledPackageInfo {
Installed.installedUnitId = mkLegacyUnitId munged_id,
Installed.sourceMungedPackageId = munged_id,
Installed.depends = map pc_uid externalPkgDeps
Installed.installedUnitId =
mkLegacyUnitId (packageId pkg_descr),
Installed.sourcePackageId = packageId pkg_descr,
Installed.depends =
map pc_uid externalPkgDeps
}
where munged_id = computeCompatPackageId (packageId pkg_descr)
CLibName
case PackageIndex.dependencyInconsistencies
. PackageIndex.insert pseudoTopPkg
$ packageDependsIndex of
......
......@@ -99,7 +99,7 @@ mkConfiguredComponent pkg_decr this_cid lib_deps exe_deps component = do
-- Resolve each @mixins@ into the actual dependency
-- from @lib_deps@.
explicit_includes <- forM (mixins bi) $ \(Mixin name rns) -> do
let keys@(_, cname) = fixFakePkgName pkg_decr name
let keys = fixFakePkgName pkg_decr name
(cid, pid) <-
case Map.lookup keys deps_map of
Nothing ->
......@@ -110,8 +110,10 @@ mkConfiguredComponent pkg_decr this_cid lib_deps exe_deps component = do
Just r -> return r
return ComponentInclude {
ci_id = cid,
ci_pkgid = pid,
ci_compname = cname,
-- TODO: We set pkgName = name here to make error messages
-- look better. But it would be better to properly
-- record component name here.
ci_pkgid = pid { pkgName = name },
ci_renaming = rns,
ci_implicit = False
}
......@@ -120,10 +122,10 @@ mkConfiguredComponent pkg_decr this_cid lib_deps exe_deps component = do
-- @backpack-include@ is converted into an "implicit" include.
let used_explicitly = Set.fromList (map ci_id explicit_includes)
implicit_includes
= map (\((_, cn), (cid, pid)) -> ComponentInclude {
= map (\((pn, _), (cid, pid)) -> ComponentInclude {
ci_id = cid,
ci_pkgid = pid,
ci_compname = cn,
-- See above ci_pkgid
ci_pkgid = pid { pkgName = pn },
ci_renaming = defaultIncludeRenaming,
ci_implicit = True
})
......
......@@ -20,7 +20,7 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Types.ComponentId
import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Types.MungedPackageName
import Distribution.Types.PackageName
import Distribution.Utils.Base62
import Distribution.Version
......@@ -71,6 +71,55 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
Nothing -> ""
Just s -> "-" ++ unUnqualComponentName s)
-- | Computes the package name for a library. If this is the public
-- library, it will just be the original package name; otherwise,
-- it will be a munged package name recording the original package
-- name as well as the name of the internal library.
--
-- A lot of tooling in the Haskell ecosystem assumes that if something
-- is installed to the package database with the package name 'foo',
-- then it actually is an entry for the (only public) library in package
-- 'foo'. With internal packages, this is not necessarily true:
-- a public library as well as arbitrarily many internal libraries may
-- come from the same package. To prevent tools from getting confused
-- in this case, the package name of these internal libraries is munged
-- so that they do not conflict the public library proper. A particular
-- case where this matters is ghc-pkg: if we don't munge the package
-- name, the inplace registration will OVERRIDE a different internal
-- library.
--
-- We munge into a reserved namespace, "z-", and encode both the
-- component name and the package name of an internal library using the
-- following format:
--
-- compat-pkg-name ::= "z-" package-name "-z-" library-name
--
-- where package-name and library-name have "-" ( "z" + ) "-"
-- segments encoded by adding an extra "z".
--
-- When we have the public library, the compat-pkg-name is just the
-- package-name, no surprises there!
--
computeCompatPackageName :: PackageName -> ComponentName -> PackageName
-- First handle the cases where we can just use the original 'PackageName'.
-- This is for the PRIMARY library, and it is non-Backpack, or the
-- indefinite package for us.
computeCompatPackageName pkg_name CLibName = pkg_name
computeCompatPackageName pkg_name cname
= mkPackageName $ "z-" ++ zdashcode (display pkg_name)
++ (case componentNameString cname of
Just cname_u -> "-z-" ++ zdashcode cname_str
where cname_str = unUnqualComponentName cname_u
Nothing -> "")
zdashcode :: String -> String
zdashcode s = go s (Nothing :: Maybe Int) []
where go [] _ r = reverse r
go ('-':z) (Just n) r | n > 0 = go z (Just 0) ('-':'z':r)
go ('-':z) _ r = go z (Just 0) ('-':r)
go ('z':z) (Just n) r = go z (Just (n+1)) ('z':r)
go (c:z) _ r = go z Nothing (c:r)
-- | In GHC 8.0, the string we pass to GHC to use for symbol
-- names for a package can be an arbitrary, IPID-compatible string.
-- However, prior to GHC 8.0 there are some restrictions on what
......@@ -120,7 +169,7 @@ computeComponentId deterministic mb_ipid mb_cid pid cname mb_details =
--
computeCompatPackageKey
:: Compiler
-> MungedPackageName
-> PackageName
-> Version
-> UnitId
-> String
......
......@@ -29,7 +29,6 @@ import Distribution.Types.ModuleRenaming
import Distribution.Types.IncludeRenaming
import Distribution.Types.ComponentInclude
import Distribution.Types.ComponentId
import Distribution.Types.MungedPackageId
import Distribution.Types.PackageId
import Distribution.Package
import Distribution.PackageDescription as PD hiding (Flag)
......@@ -106,10 +105,6 @@ dispLinkedComponent lc =
instance Package LinkedComponent where
packageId = lc_pkgid
instance HasMungedPackageId LinkedComponent where
mungedId LinkedComponent { lc_pkgid = pkgid, lc_component = component }
= computeCompatPackageId pkgid (componentName component)
toLinkedComponent
:: Verbosity
-> FullDb
......@@ -142,8 +137,8 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
-- *unlinked* unit identity. We will use unification (relying
-- on the ModuleShape) to resolve these into linked identities.
unlinked_includes :: [ComponentInclude (OpenUnitId, ModuleShape) IncludeRenaming]
unlinked_includes = [ ComponentInclude (lookupUid cid) pid cn rns i
| ComponentInclude cid pid cn rns i <- cid_includes ]
unlinked_includes = [ ComponentInclude (lookupUid cid) pid rns i
| ComponentInclude cid pid rns i <- cid_includes ]
lookupUid :: ComponentId -> (OpenUnitId, ModuleShape)
lookupUid cid = fromMaybe (error "linkComponent: lookupUid")
......@@ -183,12 +178,11 @@ toLinkedComponent verbosity db this_pid pkg_map ConfiguredComponent {
-- src_reqs_u <- mapM convertReq src_reqs
-- Read out all the final results by converting back
-- into a pure representation.
let convertIncludeU (ComponentInclude uid_u pid cn rns i) = do
let convertIncludeU (ComponentInclude uid_u pid rns i) = do
uid <- convertUnitIdU uid_u
return (ComponentInclude {
ci_id = uid,
ci_pkgid = pid,
ci_compname = cn,
ci_renaming = rns,
ci_implicit = i
})
......
......@@ -10,7 +10,6 @@ import Distribution.Compat.Prelude
import Distribution.Backpack.ModuleShape
import Distribution.Backpack
import Distribution.Types.ComponentId
import Distribution.Types.MungedPackageId
import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Types.ComponentName
......@@ -32,7 +31,7 @@ data PreExistingComponent
pc_pkgname :: PackageName,
-- | The actual name of the component.
pc_compname :: ComponentName,
pc_munged_id :: MungedPackageId,
pc_pkgid :: PackageId,
pc_uid :: UnitId,
pc_cid :: ComponentId,
pc_open_uid :: OpenUnitId,
......@@ -45,9 +44,11 @@ data PreExistingComponent
ipiToPreExistingComponent :: InstalledPackageInfo -> PreExistingComponent
ipiToPreExistingComponent ipi =
PreExistingComponent {
pc_pkgname = Installed.sourcePackageName' ipi,
pc_pkgname = case Installed.sourcePackageName ipi of
Just n -> n
Nothing -> pkgName $ Installed.sourcePackageId ipi,
pc_compname = libraryComponentName $ Installed.sourceLibName ipi,
pc_munged_id = Installed.sourceMungedPackageId ipi,
pc_pkgid = Installed.sourcePackageId ipi,
pc_uid = Installed.installedUnitId ipi,
pc_cid = Installed.installedComponentId ipi,
pc_open_uid =
......@@ -56,12 +57,8 @@ ipiToPreExistingComponent ipi =
pc_shape = shapeInstalledPackage ipi
}
instance HasMungedPackageId PreExistingComponent where
mungedId = pc_munged_id
instance Package PreExistingComponent where
packageId pec = PackageIdentifier (pc_pkgname pec) v
where MungedPackageId _ v = pc_munged_id pec
packageId = pc_pkgid
instance HasUnitId PreExistingComponent where
installedUnitId = pc_uid
......@@ -28,8 +28,7 @@ import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Compat.Graph (IsNode(..))
import Distribution.Types.Module
import Distribution.Types.MungedPackageId
import Distribution.Types.MungedPackageName
import Distribution.Types.PackageName
import Distribution.ModuleName
import Distribution.Package
......@@ -92,7 +91,7 @@ data InstantiatedComponent
-- | Dependencies induced by 'instc_insts'. These are recorded
-- here because there isn't a convenient way otherwise to get
-- the 'PackageId' we need to fill 'componentPackageDeps' as needed.
instc_insts_deps :: [(UnitId, MungedPackageId)],
instc_insts_deps :: [(UnitId, PackageId)],
-- | The modules exported/reexported by this library.
instc_provides :: Map ModuleName Module,
-- | The dependencies which need to be passed to the compiler
......@@ -117,27 +116,20 @@ data IndefiniteComponent
-- | Compute the dependencies of a 'ReadyComponent' that should
-- be recorded in the @depends@ field of 'InstalledPackageInfo'.
rc_depends :: ReadyComponent -> [(UnitId, MungedPackageId)]
rc_depends :: ReadyComponent -> [(UnitId, PackageId)]
rc_depends rc = ordNub $
case rc_i rc of
Left indefc ->
map (\ci -> (abstractUnitId $ ci_id ci, toMungedPackageId ci))
map (\ci -> (abstractUnitId (ci_id ci), ci_pkgid ci))
(indefc_includes indefc)
Right instc ->
map (\ci -> (unDefUnitId $ ci_id ci, toMungedPackageId ci))
map (\ci -> (unDefUnitId (ci_id ci), ci_pkgid ci))
(instc_includes instc)
++ instc_insts_deps instc
where
toMungedPackageId :: ComponentInclude x y -> MungedPackageId
toMungedPackageId ci = computeCompatPackageId (ci_pkgid ci) (ci_compname ci)
instance Package ReadyComponent where
packageId = rc_pkgid
instance HasMungedPackageId ReadyComponent where
mungedId ReadyComponent { rc_pkgid = pkgid, rc_component = component }
= computeCompatPackageId pkgid (componentName component)
instance HasUnitId ReadyComponent where
installedUnitId = rc_uid
......@@ -154,8 +146,8 @@ instance IsNode ReadyComponent where
ordNub (map fst (rc_depends rc)) ++
map fst (rc_exe_deps rc)
rc_compat_name :: ReadyComponent -> MungedPackageName
rc_compat_name ReadyComponent {
rc_compat_name :: ReadyComponent -> PackageName
rc_compat_name ReadyComponent{
rc_pkgid = PackageIdentifier pkg_name _,
rc_component = component
}
......@@ -221,7 +213,7 @@ instance Monad InstM where
-- instantiated components are given 'HashedUnitId'.
--
toReadyComponents
:: Map UnitId MungedPackageId
:: Map UnitId PackageId
-> Map ModuleName Module -- subst for the public component
-> [LinkedComponent]
-> [ReadyComponent]
......@@ -265,10 +257,11 @@ toReadyComponents pid_map subst0 comps
= [(dep_uid,
fromMaybe err_pid $
Map.lookup dep_uid pid_map A.<|>
fmap mungedId (join (Map.lookup dep_uid s)))]
fmap rc_pkgid (join (Map.lookup dep_uid s)))]
where
err_pid = MungedPackageId
(mkMungedPackageName "nonexistent-package-this-is-a-cabal-bug")
err_pid =
PackageIdentifier
(mkPackageName "nonexistent-package-this-is-a-cabal-bug")
(mkVersion [0])
instc = InstantiatedComponent {
instc_insts = Map.toList insts,
......
......@@ -450,7 +450,6 @@ convertInclude
convertInclude ci@(ComponentInclude {
ci_id = (uid, ModuleShape provs reqs),
ci_pkgid = pid,
ci_compname = compname,
ci_renaming = incl@(IncludeRenaming prov_rns req_rns),
ci_implicit = implicit
}) = addErrContext (text "In" <+> ci_msg ci) $ do
......@@ -588,7 +587,6 @@ convertInclude ci@(ComponentInclude {
else Left) (ComponentInclude {
ci_id = uid_u,
ci_pkgid = pid,
ci_compname = compname,
ci_renaming = prov_rns',
ci_implicit = ci_implicit ci
}))
......
......@@ -32,10 +32,8 @@ module Distribution.InstalledPackageInfo (
InstalledPackageInfo(..),
installedPackageId,
installedComponentId,
installedOpenUnitId,
requiredSignatures,
sourcePackageId,
sourcePackageName',
installedOpenUnitId,
ExposedModule(..),
AbiDependency(..),
ParseResult(..), PError(..), PWarning,
......@@ -60,8 +58,6 @@ import Distribution.Version
import Distribution.Text
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.Graph
import Distribution.Types.MungedPackageId
import Distribution.Types.MungedPackageName
import Distribution.Types.UnqualComponentName
import Text.PrettyPrint as Disp
......@@ -77,19 +73,17 @@ import Data.Set (Set)
data InstalledPackageInfo
= InstalledPackageInfo {
-- these parts are exactly the same as PackageDescription
-- | Traditionally, 'sourceMungedPackageId' was called 'sourcePackageId' and
-- recorded the 'PackageId' of the package associated with this library,
-- and most tooling assumed that this field uniquely identified any
-- package that a user might interact with in a single GHC session.
--
-- However, with convenience libraries, it's possible for there to be
-- multiple libraries associated with a package ID; to keep backwards
-- compatibility with old versions of GHC, 'sourceMungedPackageId' actually
-- stores a *munged* version of the package identifier that also
-- incorporates the component name. The /real/ package name is stored
-- in 'sourcePackageName'. The field was renamed for clarity in Cabal,
-- but the underlying field names in the package db stay the same.
sourceMungedPackageId :: MungedPackageId,
-- | Traditionally, 'sourcePackageId' records the 'PackageId'
-- of the package associated with this library, and most tooling
-- assumes that this field uniquely identifies any package
-- that a user might interact with in a single GHC session.
-- However, with convenience libraries, it's possible for there
-- to be multiple libraries associated with a package ID; to
-- keep backwards compatibility with old versions of GHC,
-- 'sourcePackageId' actually stores a *munged* version of the
-- package identifier that also incorporates the component name.
-- The /real/ package name is stored in 'sourcePackageName'.
sourcePackageId :: PackageId,
installedUnitId :: UnitId,
installedComponentId_ :: ComponentId,
-- INVARIANT: if this package is definite, OpenModule's
......@@ -100,7 +94,7 @@ data InstalledPackageInfo
-- | The source package name records package name of the
-- package that actually defined this component. For
-- regular libraries, this will equal what is recorded
-- in 'sourceMungedPackageId'. It's 'Nothing' when 'sourceMungedPackageId'
-- in 'sourcePackageId'. It's 'Nothing' when 'sourcePackageId'
-- is accurate.
sourcePackageName :: Maybe PackageName,
sourceLibName :: Maybe UnqualComponentName,
......@@ -167,40 +161,18 @@ installedOpenUnitId ipi
requiredSignatures :: InstalledPackageInfo -> Set ModuleName
requiredSignatures ipi = openModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi))
-- | Recover the package id using extra metadata in the munged case.
sourcePackageName' :: InstalledPackageInfo -> PackageName
sourcePackageName' ipi = case sourcePackageName ipi of
Just n -> n
Nothing -> mkPackageName $ unMungedPackageName
$ mungedName $ sourceMungedPackageId ipi
{-# DEPRECATED installedPackageId "Use installedUnitId instead" #-}
-- | Backwards compatibility with Cabal pre-1.24.
--
-- This type synonym is slightly awful because in cabal-install
-- we define an 'InstalledPackageId' but it's a ComponentId,
-- not a UnitId!
installedPackageId :: InstalledPackageInfo -> UnitId
installedPackageId = installedUnitId
{-# DEPRECATED sourcePackageId "Use sourceMungedPackageId instead" #-}
-- | Backwards compatibility with Cabal pre-2.00.
--
-- This is exactly the same as accessing the 'sourceMungedPackageId' field, but
-- uses a misleading name for backwards compat. Please don't use this: if you
-- want the munged id, just use 'sourceMungedPackageId', if you want the actual
-- package id, use 'packageId' (In the 'Package' class).
sourcePackageId :: InstalledPackageInfo -> MungedPackageId
sourcePackageId = sourceMungedPackageId
instance Binary InstalledPackageInfo
instance Package.HasMungedPackageId InstalledPackageInfo where
mungedId = sourceMungedPackageId
instance Package.Package InstalledPackageInfo where
packageId ipi = PackageIdentifier (sourcePackageName' ipi) ver
where MungedPackageId _ ver = sourceMungedPackageId ipi
packageId = sourcePackageId
instance Package.HasUnitId InstalledPackageInfo where
installedUnitId = installedUnitId
......@@ -216,7 +188,7 @@ instance IsNode InstalledPackageInfo where
emptyInstalledPackageInfo :: InstalledPackageInfo
emptyInstalledPackageInfo
= InstalledPackageInfo {
sourceMungedPackageId = MungedPackageId (mkMungedPackageName "") nullVersion,
sourcePackageId = PackageIdentifier (mkPackageName "") nullVersion,
installedUnitId = mkUnitId "",
installedComponentId_ = mkComponentId "",
instantiatedWith = [],
......@@ -376,10 +348,10 @@ basicFieldDescrs :: [FieldDescr InstalledPackageInfo]
basicFieldDescrs =
[ simpleField "name"
disp (parseMaybeQuoted parse)
mungedName' (\name pkg -> pkg{sourceMungedPackageId=(sourceMungedPackageId pkg){mungedName=name}})
packageName (\name pkg -> pkg{sourcePackageId=(sourcePackageId pkg){pkgName=name}})
, simpleField "version"
disp parseOptVersion
mungedVersion' (\ver pkg -> pkg{sourceMungedPackageId=(sourceMungedPackageId pkg){mungedVersion=ver}})
packageVersion (\ver pkg -> pkg{sourcePackageId=(sourcePackageId pkg){pkgVersion=ver}})
, simpleField "id"
disp parse
installedUnitId (\pk pkg -> pkg{installedUnitId=pk})
......
......@@ -25,7 +25,6 @@ module Distribution.Package
, module Distribution.Types.PackageName
, module Distribution.Types.PkgconfigName
, Package(..), packageName, packageVersion
, HasMungedPackageId(..), mungedName', mungedVersion'
, HasUnitId(..)
, installedPackageId
, PackageInstalled(..)
......@@ -39,11 +38,9 @@ import Distribution.Version
import Distribution.Types.AbiHash
import Distribution.Types.ComponentId
import Distribution.Types.MungedPackageId
import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Types.Module
import Distribution.Types.MungedPackageName
import Distribution.Types.PackageName
import Distribution.Types.PkgconfigName
......@@ -58,19 +55,7 @@ import Distribution.Types.PkgconfigName
-- many installed instances of the same source package.
--
class Package pkg where
packageId :: pkg -> PackageIdentifier
mungedName' :: HasMungedPackageId pkg => pkg -> MungedPackageName
mungedName' = mungedName . mungedId
mungedVersion' :: HasMungedPackageId munged => munged -> Version
mungedVersion' = mungedVersion . mungedId
class HasMungedPackageId pkg where
mungedId :: pkg -> MungedPackageId
instance Package PackageIdentifier where
packageId = id
packageId :: pkg -> PackageIdentifier
packageName :: Package pkg => pkg -> PackageName
packageName = pkgName . packageId
......@@ -78,8 +63,8 @@ packageName = pkgName . packageId
packageVersion :: Package pkg => pkg -> Version
packageVersion = pkgVersion . packageId
instance HasMungedPackageId MungedPackageId where
mungedId = id
instance Package PackageIdentifier where
packageId = id
-- | Packages that have an installed unit ID
class Package pkg => HasUnitId pkg where
......
......@@ -35,8 +35,6 @@ import Distribution.Types.LocalBuildInfo
import Distribution.Types.TargetInfo
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ForeignLib
import Distribution.Types.MungedPackageId
import Distribution.Types.MungedPackageName
import Distribution.Types.UnqualComponentName
import Distribution.Types.ComponentLocalBuildInfo
......@@ -460,7 +458,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
, componentExposedModules = [IPI.ExposedModule m Nothing]
}
pkg = pkg_descr {
package = (package pkg_descr) { pkgName = mkPackageName $ unMungedPackageName compat_name }
package = (package pkg_descr) { pkgName = compat_name }
, buildDepends = targetBuildDepends $ testBuildInfo test
, executables = []
, testSuites = []
......@@ -481,8 +479,8 @@ testSuiteLibV09AsLibAndExe pkg_descr
}
-- | The stub executable needs a new 'ComponentLocalBuildInfo'
-- that exposes the relevant test suite library.
deps = (IPI.installedUnitId ipi, mungedId ipi)
: (filter (\(_, x) -> let name = unMungedPackageName $ mungedName x
deps = (IPI.installedUnitId ipi, packageId ipi)
: (filter (\(_, x) -> let name = unPackageName $ pkgName x
in name == "Cabal" || name == "base")
(componentPackageDeps clbi))
exeClbi = ExeComponentLocalBuildInfo {
......
......@@ -17,8 +17,6 @@
-- /package/ in use is @>= A.B.C@, using the normal ordering on version
-- numbers.
--
-- TODO Figure out what to do about backpack and internal libraries. It is very
-- suspecious that this stuff works with munged package identifiers
module Distribution.Simple.Build.Macros (
generate,
generatePackageVersionMacros,
......@@ -32,8 +30,7 @@ import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Program.Db
import Distribution.Simple.Program.Types
import Distribution.Types.MungedPackageId
import Distribution.Types.PackageId (pkgVersion)
import Distribution.Types.PackageId
import Distribution.Text
-- ------------------------------------------------------------
......@@ -76,8 +73,7 @@ generate :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> S
generate pkg_descr lbi clbi =
"/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" ++
generatePackageVersionMacros
(computeCompatPackageId (package pkg_descr) CLibName
: map snd (componentPackageDeps clbi)) ++
(package pkg_descr : map snd (componentPackageDeps clbi)) ++
generateToolVersionMacros (configuredPrograms . withPrograms $ lbi) ++
generateComponentIdMacro lbi clbi ++
generateCurrentPackageVersion pkg_descr
......@@ -86,11 +82,11 @@ generate pkg_descr lbi clbi =
-- macros for a list of package ids (usually used with the specific deps of
-- a configured package).
--
generatePackageVersionMacros :: [MungedPackageId] -> String
generatePackageVersionMacros :: [PackageIdentifier] -> String
generatePackageVersionMacros pkgids = concat
[ line ("/* package " ++ display pkgid ++ " */")
++ generateMacros "" pkgname version
| pkgid@(MungedPackageId name version) <- pkgids
| pkgid@(PackageIdentifier name version) <- pkgids
, let pkgname = map fixchar (display name)
]
......
......@@ -84,7 +84,6 @@ import Distribution.Types.Dependency
import Distribution.Types.ExeDependency
import Distribution.Types.LegacyExeDependency
import Distribution.Types.PkgconfigDependency
import Distribution.Types.MungedPackageName
import Distribution.Types.LocalBuildInfo
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ForeignLib
......@@ -875,9 +874,6 @@ dependencySatisfiable
--
-- TODO: mention '--exact-configuration' in the error message
-- when this fails?
--
-- TODO: Do not use 'Dependency' for this, such abuses of
-- 'PackageName' are almost gone.
depSatisfiable =
if exact_config
-- NB: required deps map is indexed by *compat* package name.
......@@ -889,7 +885,7 @@ dependencySatisfiable
d = Dependency depName vr
depName
| isInternalDep && pn /= depName0
= mkPackageName $ unMungedPackageName $ computeCompatPackageName pn