@@ -54,7 +54,7 @@ module Distribution.Client.ProjectPlanning (
54
54
import Prelude ()
55
55
import Distribution.Client.Compat.Prelude
56
56
57
- import Distribution.Client.ProjectPlanning.Types
57
+ import Distribution.Client.ProjectPlanning.Types as Ty
58
58
import Distribution.Client.PackageHash
59
59
import Distribution.Client.RebuildMonad
60
60
import Distribution.Client.ProjectConfig
@@ -95,12 +95,14 @@ import Distribution.ModuleName
95
95
import Distribution.Package hiding
96
96
(InstalledPackageId , installedPackageId )
97
97
import Distribution.Types.Dependency
98
+ import Distribution.Types.ExeDependency
98
99
import Distribution.Types.PkgconfigDependency
99
100
import Distribution.Types.UnqualComponentName
100
101
import Distribution.System
101
102
import qualified Distribution.PackageDescription as Cabal
102
103
import qualified Distribution.PackageDescription as PD
103
104
import qualified Distribution.PackageDescription.Configuration as PD
105
+ import Distribution.Simple.BuildToolDepends
104
106
import Distribution.Simple.PackageIndex (InstalledPackageIndex )
105
107
import Distribution.Simple.Compiler hiding (Flag )
106
108
import qualified Distribution.Simple.GHC as GHC -- TODO: [code cleanup] eliminate
@@ -1011,7 +1013,7 @@ planPackages comp platform solver SolverSettings{..}
1011
1013
-- former we just apply all these flags to all local targets which
1012
1014
-- is silly. We should check if the flags are appropriate.
1013
1015
[ LabeledPackageConstraint
1014
- (PackageConstraint (scopeToplevel pkgname)
1016
+ (PackageConstraint (scopeToplevel pkgname)
1015
1017
(PackagePropertyFlags flags))
1016
1018
ConstraintSourceConfigFlagOrTarget
1017
1019
| let flags = solverSettingFlagAssignment
@@ -1270,12 +1272,42 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
1270
1272
compLibDependencies =
1271
1273
-- concatMap (elaborateLibSolverId mapDep) external_lib_dep_sids
1272
1274
ordNub (map (\ ci -> ConfiguredId (ci_pkgid ci) (ci_id ci)) (cc_includes cc))
1275
+
1276
+ filterExeMapDep :: SolverId -> [ElaboratedPlanPackage ]
1277
+ filterExeMapDep = filter go . mapDep
1278
+ where
1279
+ toolDeps = getAllToolDependencies pd $ Cabal. componentBuildInfo comp
1280
+ exeKV :: [(PackageName , Maybe (Set UnqualComponentName ))]
1281
+ exeKV = map go' toolDeps where
1282
+ go' (ExeDependency p n _) = (p, Set. singleton <$> n)
1283
+
1284
+ -- Nothing means wildcard, the complete subset
1285
+ exeMap :: Map PackageName (Maybe (Set UnqualComponentName ))
1286
+ exeMap = Map. fromListWith mappend exeKV
1287
+
1288
+ go (InstallPlan. Installed _) = error " unexpected state"
1289
+ go (InstallPlan. PreExisting _) = True
1290
+ go (InstallPlan. Configured (ElaboratedConfiguredPackage {
1291
+ elabPkgSourceId = PackageIdentifier { pkgName, .. },
1292
+ elabPkgOrComp,
1293
+ ..
1294
+ })) = case elabPkgOrComp of
1295
+ ElabPackage _ -> True
1296
+ ElabComponent comp' ->
1297
+ case Ty. compSolverName comp' of
1298
+ CD. ComponentExe n
1299
+ | Just maybeSet <- Map. lookup pkgName exeMap
1300
+ -> case maybeSet of
1301
+ Nothing -> True -- Wildcard, accept anything
1302
+ Just set -> Set. member n set
1303
+ _ -> error " unexpected state"
1304
+
1273
1305
compExeDependencies =
1274
1306
map confInstId
1275
- (concatMap (elaborateExeSolverId mapDep ) external_exe_dep_sids) ++
1307
+ (concatMap (elaborateExeSolverId filterExeMapDep ) external_exe_dep_sids) ++
1276
1308
cc_internal_build_tools cc
1277
1309
compExeDependencyPaths =
1278
- concatMap (elaborateExePath mapDep ) external_exe_dep_sids ++
1310
+ concatMap (elaborateExePath filterExeMapDep ) external_exe_dep_sids ++
1279
1311
[ path
1280
1312
| cid' <- cc_internal_build_tools cc
1281
1313
, Just path <- [Map. lookup cid' exe_map]]
@@ -2963,4 +2995,3 @@ improveInstallPlanWithInstalledPackages installedPkgIdSet =
2963
2995
2964
2996
-- TODO: decide what to do if we encounter broken installed packages,
2965
2997
-- since overwriting is never safe.
2966
-
0 commit comments