@@ -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,14 @@ 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
+ filterExeMapDepApp = filterExeMapDep mapDep pd [Cabal. componentBuildInfo comp]
1276
+
1273
1277
compExeDependencies =
1274
1278
map confInstId
1275
- (concatMap (elaborateExeSolverId mapDep ) external_exe_dep_sids) ++
1279
+ (concatMap (elaborateExeSolverId filterExeMapDepApp ) external_exe_dep_sids) ++
1276
1280
cc_internal_build_tools cc
1277
1281
compExeDependencyPaths =
1278
- concatMap (elaborateExePath mapDep ) external_exe_dep_sids ++
1282
+ concatMap (elaborateExePath filterExeMapDepApp ) external_exe_dep_sids ++
1279
1283
[ path
1280
1284
| cid' <- cc_internal_build_tools cc
1281
1285
, Just path <- [Map. lookup cid' exe_map]]
@@ -1347,6 +1351,36 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
1347
1351
(Map. fromList [ (req, OpenModuleVar req)
1348
1352
| req <- Set. toList (modShapeRequires shape)])
1349
1353
1354
+ filterExeMapDep :: (SolverId -> [ElaboratedPlanPackage ])
1355
+ -> PD. PackageDescription -> [PD. BuildInfo ]
1356
+ -> SolverId -> [ElaboratedPlanPackage ]
1357
+ filterExeMapDep mapDep pd bis = filter go . mapDep
1358
+ where
1359
+ toolDeps = getAllToolDependencies pd =<< bis
1360
+ exeKV :: [(PackageName , Set UnqualComponentName )]
1361
+ exeKV = map go' toolDeps where
1362
+ go' (ExeDependency p n _) = (p, Set. singleton n)
1363
+
1364
+ -- Nothing means wildcard, the complete subset
1365
+ exeMap :: Map PackageName (Set UnqualComponentName )
1366
+ exeMap = Map. fromListWith mappend exeKV
1367
+
1368
+ go (InstallPlan. Installed _) = error " unexpected state"
1369
+ go (InstallPlan. PreExisting _) = True
1370
+ go (InstallPlan. Configured (ElaboratedConfiguredPackage {
1371
+ elabPkgSourceId = PackageIdentifier { pkgName, .. },
1372
+ elabPkgOrComp,
1373
+ ..
1374
+ })) = case elabPkgOrComp of
1375
+ ElabPackage _ -> True
1376
+ ElabComponent comp' ->
1377
+ case Ty. compSolverName comp' of
1378
+ CD. ComponentExe n
1379
+ | Just set <- Map. lookup pkgName exeMap
1380
+ -> Set. member n set
1381
+ _ -> error " unexpected state"
1382
+
1383
+
1350
1384
elaborateLibSolverId' :: (SolverId -> [ElaboratedPlanPackage ])
1351
1385
-> SolverId -> [ElaboratedPlanPackage ]
1352
1386
elaborateLibSolverId' mapDep = filter is_lib . mapDep
@@ -1458,16 +1492,18 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
1458
1492
= error $ " elaborateInstallPlan: non-inplace package "
1459
1493
++ " is missing a source hash: " ++ display pkgid
1460
1494
1495
+ buildInfos = PD. allBuildInfo elabPkgDescription
1496
+ filterExeMapDepApp = filterExeMapDep mapDep elabPkgDescription buildInfos
1497
+
1461
1498
pkgLibDependencies = deps
1462
- pkgExeDependencies = fmap (concatMap (elaborateExeSolverId mapDep )) exe_deps0
1463
- pkgExeDependencyPaths = fmap (concatMap (elaborateExePath mapDep )) exe_deps0
1499
+ pkgExeDependencies = fmap (concatMap (elaborateExeSolverId filterExeMapDepApp )) exe_deps0
1500
+ pkgExeDependencyPaths = fmap (concatMap (elaborateExePath filterExeMapDepApp )) exe_deps0
1464
1501
pkgPkgConfigDependencies =
1465
1502
ordNub
1466
1503
$ [ (pn, fromMaybe (error $ " pkgPkgConfigDependencies: impossible! "
1467
1504
++ display pn ++ " from " ++ display pkgid)
1468
1505
(pkgConfigDbPkgVersion pkgConfigDB pn))
1469
- | PkgconfigDependency pn _ <- concatMap PD. pkgconfigDepends
1470
- (PD. allBuildInfo elabPkgDescription)
1506
+ | PkgconfigDependency pn _ <- concatMap PD. pkgconfigDepends buildInfos
1471
1507
]
1472
1508
1473
1509
-- Filled in later
@@ -2985,4 +3021,3 @@ improveInstallPlanWithInstalledPackages installedPkgIdSet =
2985
3021
2986
3022
-- TODO: decide what to do if we encounter broken installed packages,
2987
3023
-- since overwriting is never safe.
2988
-
0 commit comments