Skip to content

Commit c81bc98

Browse files
committed
Fix monolithic inplace build tool PATH
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
1 parent 9c6b142 commit c81bc98

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

cabal-install/Distribution/Client/ProjectPlanning.hs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,8 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
14351435
compExeDependencyPaths =
14361436
[ (annotatedIdToConfiguredId aid', path)
14371437
| aid' <- cc_exe_deps cc0
1438-
, Just path <- [Map.lookup (ann_id aid') exe_map1]]
1438+
, Just paths <- [Map.lookup (ann_id aid') exe_map1]
1439+
, path <- paths ]
14391440
elab_comp = ElaboratedComponent {..}
14401441

14411442
-- 3. Construct a preliminary ElaboratedConfiguredPackage,
@@ -1520,10 +1521,10 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
15201521
external_exe_dep_sids ++ external_lib_dep_sids
15211522

15221523
external_exe_map = Map.fromList $
1523-
[ (getComponentId pkg, path)
1524+
[ (getComponentId pkg, paths)
15241525
| pkg <- external_exe_dep_pkgs
1525-
, Just path <- [planPackageExePath pkg] ]
1526-
exe_map1 = Map.union external_exe_map exe_map
1526+
, let paths = planPackageExePaths pkg ]
1527+
exe_map1 = Map.union external_exe_map $ fmap (\x -> [x]) exe_map
15271528

15281529
external_lib_cc_map = Map.fromListWith Map.union
15291530
$ map mkCCMapping external_lib_dep_pkgs
@@ -1583,24 +1584,35 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
15831584
-> SolverId -> [ElaboratedPlanPackage]
15841585
elaborateLibSolverId mapDep = filter (matchPlanPkg (== CLibName)) . mapDep
15851586

1586-
-- | Given an 'ElaboratedPlanPackage', return the path to where the
1587-
-- executable that this package represents would be installed.
1588-
planPackageExePath :: ElaboratedPlanPackage -> Maybe FilePath
1589-
planPackageExePath =
1587+
-- | Given an 'ElaboratedPlanPackage', return the paths to where the
1588+
-- executables that this package represents would be installed.
1589+
-- The only case where multiple paths can be returned is the inplace
1590+
-- monolithic package one, since there can be multiple exes and each one
1591+
-- has its own directory.
1592+
planPackageExePaths :: ElaboratedPlanPackage -> [FilePath]
1593+
planPackageExePaths =
15901594
-- Pre-existing executables are assumed to be in PATH
15911595
-- already. In fact, this should be impossible.
1592-
InstallPlan.foldPlanPackage (const Nothing) $ \elab -> Just $
1593-
binDirectoryFor
1594-
distDirLayout
1595-
elaboratedSharedConfig
1596-
elab $
1597-
case elabPkgOrComp elab of
1598-
ElabPackage _ -> ""
1599-
ElabComponent comp ->
1600-
case fmap Cabal.componentNameString
1601-
(compComponentName comp) of
1602-
Just (Just n) -> display n
1603-
_ -> ""
1596+
InstallPlan.foldPlanPackage (const []) $ \elab ->
1597+
let
1598+
executables :: [FilePath]
1599+
executables =
1600+
case elabPkgOrComp elab of
1601+
-- Monolithic mode: all exes of the package
1602+
ElabPackage _ -> unUnqualComponentName . PD.exeName
1603+
<$> PD.executables (elabPkgDescription elab)
1604+
-- Per-component mode: just the selected exe
1605+
ElabComponent comp ->
1606+
case fmap Cabal.componentNameString
1607+
(compComponentName comp) of
1608+
Just (Just n) -> [display n]
1609+
_ -> [""]
1610+
in
1611+
binDirectoryFor
1612+
distDirLayout
1613+
elaboratedSharedConfig
1614+
elab
1615+
<$> executables
16041616

16051617
elaborateSolverToPackage :: SolverPackage UnresolvedPkgLoc
16061618
-> ComponentsGraph

0 commit comments

Comments
 (0)