Skip to content

Commit

Permalink
Change generation of -package-id parameters to new CLBI entry.
Browse files Browse the repository at this point in the history
Instead of computing the renamings based on componentPackageRenaming
right before it gets to GHC, compute it *during configure time*.
This will make some refactorings for Backpack easier.

NB: I had to keep componentPackageDeps because removing it would
be a big BC break.

Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Mar 31, 2016
1 parent 1ade220 commit bddc053
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Cabal/Distribution/Simple/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
{ componentPackageDeps = componentPackageDeps clbi
, componentLocalName = CLibName (testName test)
, componentIsPublic = False
, componentPackageRenaming = componentPackageRenaming clbi
, componentIncludes = componentIncludes clbi
, componentUnitId = componentUnitId clbi
, componentCompatPackageName = compat_name
, componentCompatPackageKey = compat_key
Expand Down Expand Up @@ -423,17 +423,17 @@ testSuiteLibV09AsLibAndExe pkg_descr
}
-- | The stub executable needs a new 'ComponentLocalBuildInfo'
-- that exposes the relevant test suite library.
deps = (IPI.installedUnitId ipi, packageId ipi)
: (filter (\(_, x) -> let PackageName name = pkgName x
in name == "Cabal" || name == "base")
(componentPackageDeps clbi))
exeClbi = ExeComponentLocalBuildInfo {
-- TODO: this is a hack, but as long as this is unique
-- (doesn't clobber something) we won't run into trouble
componentUnitId = mkUnitId (stubName test),
componentLocalName = CExeName (stubName test),
componentPackageDeps =
(IPI.installedUnitId ipi, packageId ipi)
: (filter (\(_, x) -> let PackageName name = pkgName x
in name == "Cabal" || name == "base")
(componentPackageDeps clbi)),
componentPackageRenaming = Map.empty
componentPackageDeps = deps,
componentIncludes = zip (map fst deps) (repeat defaultRenaming)
}
testSuiteLibV09AsLibAndExe _ TestSuite{} _ _ _ _ = error "testSuiteLibV09AsLibAndExe: wrong kind"

Expand All @@ -454,7 +454,7 @@ benchmarkExeV10asExe bm@Benchmark { benchmarkInterface = BenchmarkExeV10 _ f }
componentUnitId = componentUnitId clbi,
componentLocalName = CExeName (benchmarkName bm),
componentPackageDeps = componentPackageDeps clbi,
componentPackageRenaming = componentPackageRenaming clbi
componentIncludes = componentIncludes clbi
}
benchmarkExeV10asExe Benchmark{} _ = error "benchmarkExeV10asExe: wrong kind"

Expand Down
9 changes: 5 additions & 4 deletions Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1672,29 +1672,29 @@ mkComponentsLocalBuildInfo cfg comp installedPackages pkg_descr
componentIsPublic = libName lib == display (packageName (package pkg_descr)),
componentCompatPackageKey = compat_key,
componentCompatPackageName = compat_name,
componentPackageRenaming = cprns,
componentIncludes = includes,
componentExposedModules = exports ++ reexports
}
CExe _ ->
return ExeComponentLocalBuildInfo {
componentUnitId = uid,
componentLocalName = componentName component,
componentPackageDeps = cpds,
componentPackageRenaming = cprns
componentIncludes = includes
}
CTest _ ->
return TestComponentLocalBuildInfo {
componentUnitId = uid,
componentLocalName = componentName component,
componentPackageDeps = cpds,
componentPackageRenaming = cprns
componentIncludes = includes
}
CBench _ ->
return BenchComponentLocalBuildInfo {
componentUnitId = uid,
componentLocalName = componentName component,
componentPackageDeps = cpds,
componentPackageRenaming = cprns
componentIncludes = includes
}
where

Expand Down Expand Up @@ -1729,6 +1729,7 @@ mkComponentsLocalBuildInfo cfg comp installedPackages pkg_descr
| pkgid <- selectSubset bi internalPkgDeps ]
else [ (Installed.installedUnitId pkg, packageId pkg)
| pkg <- externalPkgDeps ]
includes = map (\(i,p) -> (i,lookupRenaming p cprns)) cpds
cprns = if newPackageDepsBehaviour pkg_descr
then targetBuildRenaming bi
else Map.empty
Expand Down
5 changes: 1 addition & 4 deletions Cabal/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,9 @@ getHaskellObjects _implInfo lib lbi pref wanted_obj_ext allow_split_objs
return [ pref </> ModuleName.toFilePath x <.> wanted_obj_ext
| x <- libModules lib ]

-- TODO: rework me
mkGhcOptPackages :: ComponentLocalBuildInfo
-> [(UnitId, ModuleRenaming)]
mkGhcOptPackages clbi =
map (\(i,p) -> (i,lookupRenaming p (componentPackageRenaming clbi)))
(componentPackageDeps clbi)
mkGhcOptPackages = componentIncludes

substTopDir :: FilePath -> InstalledPackageInfo -> InstalledPackageInfo
substTopDir topDir ipo
Expand Down
8 changes: 4 additions & 4 deletions Cabal/Distribution/Simple/LocalBuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -325,25 +325,25 @@ data ComponentLocalBuildInfo
componentCompatPackageName :: PackageName,
componentExposedModules :: [Installed.ExposedModule],
componentIsPublic :: Bool,
componentPackageRenaming :: Map PackageName ModuleRenaming
componentIncludes :: [(UnitId, ModuleRenaming)]
}
| ExeComponentLocalBuildInfo {
componentLocalName :: ComponentName,
componentUnitId :: UnitId,
componentPackageDeps :: [(UnitId, PackageId)],
componentPackageRenaming :: Map PackageName ModuleRenaming
componentIncludes :: [(UnitId, ModuleRenaming)]
}
| TestComponentLocalBuildInfo {
componentLocalName :: ComponentName,
componentUnitId :: UnitId,
componentPackageDeps :: [(UnitId, PackageId)],
componentPackageRenaming :: Map PackageName ModuleRenaming
componentIncludes :: [(UnitId, ModuleRenaming)]
}
| BenchComponentLocalBuildInfo {
componentLocalName :: ComponentName,
componentUnitId :: UnitId,
componentPackageDeps :: [(UnitId, PackageId)],
componentPackageRenaming :: Map PackageName ModuleRenaming
componentIncludes :: [(UnitId, ModuleRenaming)]
}
deriving (Generic, Read, Show)

Expand Down

0 comments on commit bddc053

Please sign in to comment.