@@ -287,7 +287,7 @@ multiReplDecision ctx compiler flags =
287
287
-- For more details on how this works, see the module
288
288
-- "Distribution.Client.ProjectOrchestration"
289
289
replAction :: NixStyleFlags ReplFlags -> [String ] -> GlobalFlags -> IO ()
290
- replAction flags@ NixStyleFlags {extraFlags = r @ ReplFlags {.. }, .. } targetStrings' globalFlags = do
290
+ replAction flags@ NixStyleFlags {extraFlags = replFlags @ ReplFlags {.. }, configFlags } targetStrings' globalFlags = do
291
291
-- NOTE: The REPL will work with no targets in the context of a project if a
292
292
-- single package is in the same directory as the project file. To have the
293
293
-- same behaviour when the package is somewhere else we adjust the targets.
@@ -394,7 +394,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings'
394
394
-- especially in the no-project case.
395
395
withInstallPlan (lessVerbose verbosity) baseCtx' $ \ elaboratedPlan sharedConfig -> do
396
396
-- targets should be non-empty map, but there's no NonEmptyMap yet.
397
- targets <- validatedTargets (projectConfigShared (projectConfig ctx)) (pkgConfigCompiler sharedConfig) elaboratedPlan targetSelectors
397
+ targets <- validatedTargets' (projectConfigShared (projectConfig ctx)) (pkgConfigCompiler sharedConfig) elaboratedPlan targetSelectors
398
398
399
399
let
400
400
(unitId, _) = fromMaybe (error " panic: targets should be non-empty" ) $ safeHead $ Map. toList targets
@@ -418,7 +418,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings'
418
418
let ProjectBaseContext {.. } = baseCtx''
419
419
420
420
-- Recalculate with updated project.
421
- targets <- validatedTargets (projectConfigShared projectConfig) (pkgConfigCompiler elaboratedShared') elaboratedPlan targetSelectors
421
+ targets <- validatedTargets' (projectConfigShared projectConfig) (pkgConfigCompiler elaboratedShared') elaboratedPlan targetSelectors
422
422
423
423
let
424
424
elaboratedPlan' =
@@ -562,28 +562,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings'
562
562
verbosity = cfgVerbosity normal flags
563
563
tempFileOptions = commonSetupTempFileOptions $ configCommonFlags configFlags
564
564
565
- validatedTargets ctx compiler elaboratedPlan targetSelectors = do
566
- let multi_repl_enabled = multiReplDecision ctx compiler r
567
- -- Interpret the targets on the command line as repl targets
568
- -- (as opposed to say build or haddock targets).
569
- targets <-
570
- either (reportTargetProblems verbosity) return $
571
- resolveTargetsFromSolver
572
- (selectPackageTargets multi_repl_enabled)
573
- selectComponentTarget
574
- elaboratedPlan
575
- Nothing
576
- targetSelectors
577
-
578
- -- Reject multiple targets, or at least targets in different
579
- -- components. It is ok to have two module/file targets in the
580
- -- same component, but not two that live in different components.
581
- when (Set. size (distinctTargetComponents targets) > 1 && not (useMultiRepl multi_repl_enabled)) $
582
- reportTargetProblems
583
- verbosity
584
- [multipleTargetsProblem multi_repl_enabled targets]
585
-
586
- return targets
565
+ validatedTargets' = validatedTargets verbosity replFlags
587
566
588
567
-- This is the constraint setup.Cabal>=3.11. 3.11 is when Cabal options
589
568
-- used for multi-repl were introduced.
@@ -597,6 +576,37 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings'
597
576
, ConstraintSourceMultiRepl
598
577
)
599
578
579
+ validatedTargets
580
+ :: Verbosity
581
+ -> ReplFlags
582
+ -> ProjectConfigShared
583
+ -> Compiler
584
+ -> ElaboratedInstallPlan
585
+ -> [TargetSelector ]
586
+ -> IO TargetsMap
587
+ validatedTargets verbosity replFlags ctx compiler elaboratedPlan targetSelectors = do
588
+ let multi_repl_enabled = multiReplDecision ctx compiler replFlags
589
+ -- Interpret the targets on the command line as repl targets (as opposed to
590
+ -- say build or haddock targets).
591
+ targets <-
592
+ either (reportTargetProblems verbosity) return $
593
+ resolveTargetsFromSolver
594
+ (selectPackageTargets multi_repl_enabled)
595
+ selectComponentTarget
596
+ elaboratedPlan
597
+ Nothing
598
+ targetSelectors
599
+
600
+ -- Reject multiple targets, or at least targets in different components. It is
601
+ -- ok to have two module/file targets in the same component, but not two that
602
+ -- live in different components.
603
+ when (Set. size (distinctTargetComponents targets) > 1 && not (useMultiRepl multi_repl_enabled)) $
604
+ reportTargetProblems
605
+ verbosity
606
+ [multipleTargetsProblem multi_repl_enabled targets]
607
+
608
+ return targets
609
+
600
610
-- | First version of GHC which supports multiple home packages
601
611
minMultipleHomeUnitsVersion :: Version
602
612
minMultipleHomeUnitsVersion = mkVersion [9 , 4 ]
0 commit comments