From 497db229ca68243e7c8e9c03831d529a99d38882 Mon Sep 17 00:00:00 2001 From: Francesco Gazzetta Date: Sun, 21 Oct 2018 21:20:14 +0200 Subject: [PATCH] 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 #5104 --- .../Distribution/Client/ProjectPlanning.hs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 2f85dca3cdc..d0a8de07796 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -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 @@ -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