@@ -3223,9 +3223,6 @@ setRootTargets targetAction perPkgTargetsMap =
3223
3223
| isSubLibComponentTarget tgt = elab{elabHaddockInternal = True }
3224
3224
| otherwise = elab
3225
3225
3226
- minVersionReplFlagFile :: Version
3227
- minVersionReplFlagFile = mkVersion [3 , 9 ]
3228
-
3229
3226
-- | Assuming we have previously set the root build targets (i.e. the user
3230
3227
-- targets but not rev deps yet), the first pruning pass does two things:
3231
3228
--
@@ -3240,7 +3237,7 @@ pruneInstallPlanPass1
3240
3237
pruneInstallPlanPass1 pkgs
3241
3238
-- if there are repl targets, we need to do a bit more work
3242
3239
-- See Note [Pruning for Multi Repl]
3243
- | anyReplTarget = final_final_graph
3240
+ | anyMultiReplTarget = graph_with_repl_targets
3244
3241
-- otherwise we'll do less
3245
3242
| otherwise = pruned_packages
3246
3243
where
@@ -3264,10 +3261,11 @@ pruneInstallPlanPass1 pkgs
3264
3261
closed_graph :: Graph. Graph ElaboratedPlanPackage
3265
3262
closed_graph = Graph. fromDistinctList pruned_packages
3266
3263
3267
- -- whether any package has repl targets enabled.
3268
- anyReplTarget :: Bool
3269
- anyReplTarget = any is_repl_gpp pkgs'
3264
+ -- whether any package has repl targets enabled, and we need to use multi-repl .
3265
+ anyMultiReplTarget :: Bool
3266
+ anyMultiReplTarget = length repls > 1
3270
3267
where
3268
+ repls = filter is_repl_gpp pkgs'
3271
3269
is_repl_gpp (InstallPlan. Configured pkg) = is_repl_pp pkg
3272
3270
is_repl_gpp _ = False
3273
3271
@@ -3290,52 +3288,9 @@ pruneInstallPlanPass1 pkgs
3290
3288
3291
3289
-- Add the repl target information to the ElaboratedPlanPackages
3292
3290
graph_with_repl_targets
3293
- | anyReplTarget = map (mapConfiguredPackage add_repl_target) (Graph. toList closed_graph)
3291
+ | anyMultiReplTarget = map (mapConfiguredPackage add_repl_target) (Graph. toList closed_graph)
3294
3292
| otherwise = Graph. toList closed_graph
3295
3293
3296
- -- But check that all the InMemory targets have a new enough version of Cabal,
3297
- -- otherwise we will confuse Setup.hs by passing new arguments which it doesn't understand
3298
- -- later down the line. We try to remove just these edges, if it doesn't break the overall structure
3299
- -- then we just report to the user that their target will not be loaded for this reason.
3300
- --
3301
- -- 'bad' are the nodes with a too old version of Cabal
3302
- -- 'good' are the nodes with a new-enough version of Cabal
3303
- (bad, _good) = partitionEithers (map go graph_with_repl_targets)
3304
- where
3305
- go :: ElaboratedPlanPackage -> Either UnitId ElaboratedPlanPackage
3306
- go (InstallPlan. Configured cp)
3307
- | BuildInplaceOnly InMemory <- elabBuildStyle cp
3308
- , elabSetupScriptCliVersion cp < minVersionReplFlagFile =
3309
- Left (elabUnitId cp)
3310
- go (InstallPlan. Configured c) = Right (InstallPlan. Configured c)
3311
- go c = Right c
3312
-
3313
- -- Now take the upwards closure from the bad nodes, and find the other `BuildInplaceOnly InMemory` packages that clobbers,
3314
- -- disables those and issue a warning to the user. Because we aren't going to be able to load those into memory as well
3315
- -- because the thing it depends on is not going to be in memory.
3316
- disabled_repl_targets =
3317
- [ c | InstallPlan. Configured c <- fromMaybe [] $ Graph. revClosure (Graph. fromDistinctList graph_with_repl_targets) bad, BuildInplaceOnly InMemory <- [elabBuildStyle c]
3318
- ]
3319
-
3320
- remove_repl_target :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage
3321
- remove_repl_target ecp
3322
- | ecp `elem` disabled_repl_targets =
3323
- ecp
3324
- { elabReplTarget = []
3325
- , elabBuildStyle = BuildInplaceOnly OnDisk
3326
- }
3327
- | otherwise = ecp
3328
-
3329
- final_graph_with_repl_targets = map (mapConfiguredPackage remove_repl_target) graph_with_repl_targets
3330
-
3331
- -- Now find what the new roots are after we have disabled things which we can't build (and the things above that)
3332
- new_roots :: [UnitId ]
3333
- new_roots = mapMaybe find_root (map (mapConfiguredPackage prune) final_graph_with_repl_targets)
3334
-
3335
- -- Then take the final closure from these new roots to remove these things
3336
- -- TODO: Can probably just remove them directly in remove_repl_target.
3337
- final_final_graph = fromMaybe [] $ Graph. closure (Graph. fromDistinctList final_graph_with_repl_targets) new_roots
3338
-
3339
3294
is_root :: PrunedPackage -> Maybe UnitId
3340
3295
is_root (PrunedPackage elab _) =
3341
3296
if not $
@@ -3462,13 +3417,6 @@ our roots (graph closure), and then from this closed graph, we calculate
3462
3417
the reverse closure, which gives us all components that depend on
3463
3418
'roots'. Thus, the result is a list of components that we need to load
3464
3419
into the repl to uphold the closure property.
3465
-
3466
- Further to this, we then check that all the enabled components are using a new enough
3467
- version of Cabal which understands the repl option to write the arguments to a file.
3468
-
3469
- If there is a package using a custom Setup.hs which is linked against a too old version
3470
- of Cabal then we need to disable that as otherwise we will end up passing unknown
3471
- arguments to `./Setup`.
3472
3420
-}
3473
3421
3474
3422
-- | Given a set of already installed packages @availablePkgs@,
0 commit comments