Commit 0b922909 authored by Edward Z. Yang's avatar Edward Z. Yang Committed by Ben Gamari

Print out sub-libraries of packages more nicely.

Previously, we would print out the munged package name
which looked like z-bkpcabal01-z-p-0.1.0.0.  Now
it looks like: bkpcabal01-0.1.0.0:p.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: simonpj, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3235
parent a6874e54
......@@ -308,6 +308,8 @@ buildUnit session cid insts lunit = do
packageName = compat_pn,
packageVersion = makeVersion [0],
unitId = toInstalledUnitId (thisPackage dflags),
mungedPackageName = Nothing,
libName = Nothing,
componentId = cid,
instantiatedWith = insts,
-- Slight inefficiency here haha
......
......@@ -97,6 +97,7 @@ import qualified Data.Semigroup as Semigroup
import qualified Data.Map as Map
import qualified Data.Map.Strict as MapStrict
import qualified Data.Set as Set
import Data.Version
-- ---------------------------------------------------------------------------
-- The Package state
......@@ -1857,9 +1858,15 @@ missingDependencyMsg (Just parent)
-- -----------------------------------------------------------------------------
componentIdString :: DynFlags -> ComponentId -> Maybe String
componentIdString dflags cid =
fmap sourcePackageIdString (lookupInstalledPackage dflags
(componentIdToInstalledUnitId cid))
componentIdString dflags cid = do
conf <- lookupInstalledPackage dflags (componentIdToInstalledUnitId cid)
return $
case libName conf of
Nothing -> sourcePackageIdString conf
Just (PackageName libname) ->
packageNameString conf
++ "-" ++ showVersion (packageVersion conf)
++ ":" ++ unpackFS libname
displayInstalledUnitId :: DynFlags -> InstalledUnitId -> Maybe String
displayInstalledUnitId dflags uid =
......
......@@ -98,6 +98,8 @@ data InstalledPackageInfo compid srcpkgid srcpkgname instunitid unitid modulenam
sourcePackageId :: srcpkgid,
packageName :: srcpkgname,
packageVersion :: Version,
mungedPackageName :: Maybe srcpkgname,
libName :: Maybe srcpkgname,
abiHash :: String,
depends :: [instunitid],
-- | Like 'depends', but each dependency is annotated with the
......@@ -182,6 +184,8 @@ emptyInstalledPackageInfo =
sourcePackageId = fromStringRep BS.empty,
packageName = fromStringRep BS.empty,
packageVersion = Version [] [],
mungedPackageName = Nothing,
libName = Nothing,
abiHash = "",
depends = [],
abiDepends = [],
......@@ -440,6 +444,7 @@ instance (RepInstalledPackageInfo a b c d e f g) =>
put (InstalledPackageInfo
unitId componentId instantiatedWith sourcePackageId
packageName packageVersion
mungedPackageName libName
abiHash depends abiDepends importDirs
hsLibraries extraLibraries extraGHCiLibraries
libraryDirs libraryDynDirs
......@@ -452,6 +457,8 @@ instance (RepInstalledPackageInfo a b c d e f g) =>
put (toStringRep sourcePackageId)
put (toStringRep packageName)
put packageVersion
put (fmap toStringRep mungedPackageName)
put (fmap toStringRep libName)
put (toStringRep unitId)
put (toStringRep componentId)
put (map (\(mod_name, mod) -> (toStringRep mod_name, toDbModule mod))
......@@ -484,6 +491,8 @@ instance (RepInstalledPackageInfo a b c d e f g) =>
sourcePackageId <- get
packageName <- get
packageVersion <- get
mungedPackageName <- get
libName <- get
unitId <- get
componentId <- get
instantiatedWith <- get
......@@ -516,6 +525,8 @@ instance (RepInstalledPackageInfo a b c d e f g) =>
instantiatedWith)
(fromStringRep sourcePackageId)
(fromStringRep packageName) packageVersion
(fmap fromStringRep mungedPackageName)
(fmap fromStringRep libName)
abiHash
(map fromStringRep depends)
(map (\(k,v) -> (fromStringRep k, v)) abiDepends)
......
......@@ -6,5 +6,5 @@ q/H.hsig:2:1: error:
Hsig file: x :: Bool
The two types are different
• while merging the signatures from:
z-bkpcabal01-z-p-0.1.0.0[H=<H>]:H
bkpcabal01-0.1.0.0:p[H=<H>]:H
• ...and the local signature for H
......@@ -41,6 +41,7 @@ import Distribution.Package hiding (installedUnitId)
import Distribution.Text
import Distribution.Version
import Distribution.Backpack
import Distribution.Types.UnqualComponentName
import Distribution.Simple.Utils (fromUTF8, toUTF8, writeUTF8File, readUTF8File)
import qualified Data.Version as Version
import System.FilePath as FilePath
......@@ -1243,8 +1244,17 @@ convertPackageInfoToCacheFormat pkg =
GhcPkg.componentId = installedComponentId pkg,
GhcPkg.instantiatedWith = instantiatedWith pkg,
GhcPkg.sourcePackageId = sourcePackageId pkg,
GhcPkg.packageName = packageName pkg,
GhcPkg.packageName =
case sourcePackageName pkg of
Nothing -> packageName pkg
Just pn -> pn,
GhcPkg.packageVersion = Version.Version (versionNumbers (packageVersion pkg)) [],
GhcPkg.mungedPackageName =
case sourcePackageName pkg of
Nothing -> Nothing
Just _ -> Just (packageName pkg),
GhcPkg.libName =
fmap (mkPackageName . unUnqualComponentName) (sourceLibName pkg),
GhcPkg.depends = depends pkg,
GhcPkg.abiDepends = map (\(AbiDependency k v) -> (k,unAbiHash v)) (abiDepends pkg),
GhcPkg.abiHash = unAbiHash (abiHash pkg),
......@@ -1268,7 +1278,8 @@ convertPackageInfoToCacheFormat pkg =
GhcPkg.exposed = exposed pkg,
GhcPkg.trusted = trusted pkg
}
where convertExposed (ExposedModule n reexport) = (n, reexport)
where
convertExposed (ExposedModule n reexport) = (n, reexport)
instance GhcPkg.BinaryStringRep ComponentId where
fromStringRep = mkComponentId . fromStringRep
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment