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 29, 2018
1 parent e306737 commit 830e8ee
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,8 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
compExeDependencyPaths =
[ (annotatedIdToConfiguredId aid', path)
| aid' <- cc_exe_deps cc0
, Just path <- [Map.lookup (ann_id aid') exe_map1]]
, Just paths <- [Map.lookup (ann_id aid') exe_map1]
, path <- paths ]
elab_comp = ElaboratedComponent {..}

-- 3. Construct a preliminary ElaboratedConfiguredPackage,
Expand Down Expand Up @@ -1514,10 +1515,10 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
external_exe_dep_sids ++ external_lib_dep_sids

external_exe_map = Map.fromList $
[ (getComponentId pkg, path)
[ (getComponentId pkg, paths)
| pkg <- external_exe_dep_pkgs
, Just path <- [planPackageExePath pkg] ]
exe_map1 = Map.union external_exe_map exe_map
, let paths = planPackageExePaths pkg ]
exe_map1 = Map.union external_exe_map $ fmap (\x -> [x]) exe_map

external_lib_cc_map = Map.fromListWith Map.union
$ map mkCCMapping external_lib_dep_pkgs
Expand Down Expand Up @@ -1577,24 +1578,35 @@ 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 $
binDirectoryFor
distDirLayout
elaboratedSharedConfig
elab $
case elabPkgOrComp elab of
ElabPackage _ -> ""
ElabComponent comp ->
case fmap Cabal.componentNameString
(compComponentName comp) of
Just (Just n) -> display n
_ -> ""
InstallPlan.foldPlanPackage (const []) $ \elab ->
let
executables :: [FilePath]
executables =
case elabPkgOrComp elab of
-- 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]
_ -> [""]
in
binDirectoryFor
distDirLayout
elaboratedSharedConfig
elab
<$> executables

elaborateSolverToPackage :: SolverPackage UnresolvedPkgLoc
-> ComponentsGraph
Expand Down

0 comments on commit 830e8ee

Please sign in to comment.