Skip to content

Commit

Permalink
Fix monolithic inplace build tool PATH
Browse files Browse the repository at this point in the history
Monolithic inplace packages have a directory for each exe, so we allow
multiple paths and return all the exe paths of the package.

Fixes haskell#5104
  • Loading branch information
fgaz committed Oct 21, 2018
1 parent 9c6b142 commit 497db22
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
external_exe_map = Map.fromList $
[ (getComponentId pkg, path)
| pkg <- external_exe_dep_pkgs
, Just path <- [planPackageExePath pkg] ]
, path <- planPackageExePaths pkg ]
exe_map1 = Map.union external_exe_map exe_map

external_lib_cc_map = Map.fromListWith Map.union
Expand Down Expand Up @@ -1583,24 +1583,30 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
-> SolverId -> [ElaboratedPlanPackage]
elaborateLibSolverId mapDep = filter (matchPlanPkg (== CLibName)) . mapDep

-- | Given an 'ElaboratedPlanPackage', return the path to where the
-- executable that this package represents would be installed.
planPackageExePath :: ElaboratedPlanPackage -> Maybe FilePath
planPackageExePath =
-- | Given an 'ElaboratedPlanPackage', return the paths to where the
-- executables that this package represents would be installed.
-- The only case where multiple paths can be returned is the inplace
-- monolithic package one, since there can be multiple exes and each one
-- has its own directory.
planPackageExePaths :: ElaboratedPlanPackage -> [FilePath]
planPackageExePaths =
-- Pre-existing executables are assumed to be in PATH
-- already. In fact, this should be impossible.
InstallPlan.foldPlanPackage (const Nothing) $ \elab -> Just $
InstallPlan.foldPlanPackage (const []) $ \elab ->
binDirectoryFor
distDirLayout
elaboratedSharedConfig
elab $
elab <$>
case elabPkgOrComp elab of
ElabPackage _ -> ""
-- Monolithic mode: all exes of the package
ElabPackage _ -> unUnqualComponentName . PD.exeName
<$> PD.executables (elabPkgDescription elab)
-- Per-component mode: just the selected exe
ElabComponent comp ->
case fmap Cabal.componentNameString
(compComponentName comp) of
Just (Just n) -> display n
_ -> ""
Just (Just n) -> [display n]
_ -> [""]

elaborateSolverToPackage :: SolverPackage UnresolvedPkgLoc
-> ComponentsGraph
Expand Down

0 comments on commit 497db22

Please sign in to comment.