Commit be1a184c authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Extend ComponentLocalBuildInfo with backpack info

(1) add 'componentInstantiatedWith' to record how a component was
instantiated (analogous to @instantiated-with@) and
(2) fix 'componentComponentId' for the new constructors in 'Module'.
parent 1017f710
......@@ -33,6 +33,7 @@ import Distribution.Types.LocalBuildInfo
import Distribution.Types.TargetInfo
import Distribution.Package
import Distribution.Backpack
import qualified Distribution.Simple.GHC as GHC
import qualified Distribution.Simple.GHCJS as GHCJS
import qualified Distribution.Simple.JHC as JHC
......@@ -427,11 +428,13 @@ testSuiteLibV09AsLibAndExe pkg_descr
libClbi = LibComponentLocalBuildInfo
{ componentPackageDeps = componentPackageDeps clbi
, componentInternalDeps = componentInternalDeps clbi
, componentIsIndefinite_ = False
, componentExeDeps = componentExeDeps clbi
, componentLocalName = CSubLibName (testName test)
, componentIsPublic = False
, componentIncludes = componentIncludes clbi
, componentUnitId = componentUnitId clbi
, componentInstantiatedWith = []
, componentCompatPackageName = compat_name
, componentCompatPackageKey = compat_key
, componentExposedModules = [IPI.ExposedModule m Nothing]
......@@ -470,7 +473,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
componentExeDeps = [],
componentLocalName = CExeName (stubName test),
componentPackageDeps = deps,
componentIncludes = zip (map fst deps) (repeat defaultRenaming)
componentIncludes = zip (map (IndefUnitId . fst) deps) (repeat defaultRenaming)
}
testSuiteLibV09AsLibAndExe _ TestSuite{} _ _ _ _ = error "testSuiteLibV09AsLibAndExe: wrong kind"
......
......@@ -1861,6 +1861,8 @@ mkComponentsLocalBuildInfo cfg use_external_internal comp installedPackages
componentInternalDeps = dep_uids,
componentExeDeps = dep_exes,
componentUnitId = uid,
componentInstantiatedWith = [], --TODO in later patch
componentIsIndefinite_ = False, --TODO in later patch
componentLocalName = componentName component,
componentIsPublic = libName lib == Nothing,
componentCompatPackageKey = compat_key,
......@@ -1935,7 +1937,7 @@ mkComponentsLocalBuildInfo cfg use_external_internal comp installedPackages
| pkg <- externalPkgDeps ]
-- TODO: this is an intermediate stage in introducing backpack
-- so this is a bit of a hack. It will be completely replaced.
includes = map (\(i,p) -> (i,lookupRenaming p)) cpds
includes = map (\(i,p) -> (IndefUnitId i,lookupRenaming p)) cpds
lookupRenaming p = case Map.lookup (packageName p) cprns of
Nothing -> defaultRenaming
Just rns -> includeProvidesRn rns
......
......@@ -37,6 +37,7 @@ import Distribution.Compat.Prelude
import Distribution.Simple.GHC.ImplInfo
import Distribution.Package
import Distribution.Types.ComponentLocalBuildInfo
import Distribution.Backpack
import Distribution.InstalledPackageInfo
import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo
......@@ -376,8 +377,7 @@ getHaskellObjects _implInfo lib lbi clbi pref wanted_obj_ext allow_split_objs
mkGhcOptPackages :: ComponentLocalBuildInfo
-> [(IndefUnitId, ModuleRenaming)]
mkGhcOptPackages = map (\(uid, mr) -> (IndefUnitId uid, mr))
. componentIncludes
mkGhcOptPackages = componentIncludes
substTopDir :: FilePath -> InstalledPackageInfo -> InstalledPackageInfo
substTopDir topDir ipo
......
......@@ -3,12 +3,15 @@
module Distribution.Types.ComponentLocalBuildInfo (
ComponentLocalBuildInfo(..),
componentIsIndefinite,
componentComponentId,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.ModuleName
import Distribution.Backpack
import Distribution.Compat.Graph
import Distribution.Types.ComponentName
......@@ -27,8 +30,12 @@ data ComponentLocalBuildInfo
-- identify the ComponentLocalBuildInfo.
componentLocalName :: ComponentName,
-- | The computed 'UnitId' which uniquely identifies this
-- component.
-- component. Might be hashed.
componentUnitId :: UnitId,
-- | Is this an indefinite component (i.e. has unfilled holes)?
componentIsIndefinite_ :: Bool,
-- | How the component was instantiated
componentInstantiatedWith :: [(ModuleName, IndefModule)],
-- | Resolved internal and external package dependencies for this component.
-- The 'BuildInfo' specifies a set of build dependencies that must be
-- satisfied in terms of version ranges. This field fixes those dependencies
......@@ -39,7 +46,7 @@ data ComponentLocalBuildInfo
-- to hide or rename modules. This is what gets translated into
-- @-package-id@ arguments. This is a modernized version of
-- 'componentPackageDeps', which is kept around for BC purposes.
componentIncludes :: [(UnitId, ModuleRenaming)],
componentIncludes :: [(IndefUnitId, ModuleRenaming)],
componentExeDeps :: [UnitId],
-- | The internal dependencies which induce a graph on the
-- 'ComponentLocalBuildInfo' of this package. This does NOT
......@@ -62,7 +69,7 @@ data ComponentLocalBuildInfo
componentLocalName :: ComponentName,
componentUnitId :: UnitId,
componentPackageDeps :: [(UnitId, PackageId)],
componentIncludes :: [(UnitId, ModuleRenaming)],
componentIncludes :: [(IndefUnitId, ModuleRenaming)],
componentExeDeps :: [UnitId],
componentInternalDeps :: [UnitId]
}
......@@ -70,7 +77,7 @@ data ComponentLocalBuildInfo
componentLocalName :: ComponentName,
componentUnitId :: UnitId,
componentPackageDeps :: [(UnitId, PackageId)],
componentIncludes :: [(UnitId, ModuleRenaming)],
componentIncludes :: [(IndefUnitId, ModuleRenaming)],
componentExeDeps :: [UnitId],
componentInternalDeps :: [UnitId]
......@@ -79,7 +86,7 @@ data ComponentLocalBuildInfo
componentLocalName :: ComponentName,
componentUnitId :: UnitId,
componentPackageDeps :: [(UnitId, PackageId)],
componentIncludes :: [(UnitId, ModuleRenaming)],
componentIncludes :: [(IndefUnitId, ModuleRenaming)],
componentExeDeps :: [UnitId],
componentInternalDeps :: [UnitId]
}
......@@ -94,3 +101,7 @@ instance IsNode ComponentLocalBuildInfo where
componentComponentId :: ComponentLocalBuildInfo -> ComponentId
componentComponentId clbi = unitIdComponentId (componentUnitId clbi)
componentIsIndefinite :: ComponentLocalBuildInfo -> Bool
componentIsIndefinite LibComponentLocalBuildInfo{ componentIsIndefinite_ = b } = b
componentIsIndefinite _ = False
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