@@ -55,6 +55,9 @@ import Distribution.Client.ProjectOrchestration
5555import Distribution.Client.ProjectPlanning
5656 ( ElaboratedInstallPlan
5757 , ElaboratedSharedConfig (.. )
58+ , WithStage
59+ , Stage (.. )
60+ , getStage
5861 )
5962import Distribution.Client.ProjectPlanning.Types
6063 ( Toolchain (.. )
@@ -92,7 +95,6 @@ import Distribution.Compiler
9295import Distribution.Package
9396 ( Package (.. )
9497 , UnitId
95- , installedUnitId
9698 , mkPackageName
9799 , packageName
98100 )
@@ -181,6 +183,7 @@ import Distribution.Client.ReplFlags
181183 , topReplOptions
182184 )
183185import Distribution.Compat.Binary (decode )
186+ import qualified Distribution.Compat.Graph as Graph
184187import Distribution.Simple.Flag (flagToMaybe , fromFlagOrDefault , pattern Flag )
185188import Distribution.Simple.Program.Builtin (ghcProgram )
186189import Distribution.Simple.Program.Db (requireProgram )
@@ -196,7 +199,6 @@ import System.FilePath
196199 , splitSearchPath
197200 , (</>)
198201 )
199- import Distribution.Solver.Types.Stage
200202
201203replCommand :: CommandUI (NixStyleFlags ReplFlags )
202204replCommand =
@@ -362,15 +364,14 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g
362364 -- especially in the no-project case.
363365 withInstallPlan (lessVerbose verbosity) baseCtx' $ \ elaboratedPlan sharedConfig -> do
364366 -- targets should be non-empty map, but there's no NonEmptyMap yet.
365- -- TODO: This only makes sense for the build stage
366367 let Toolchain { toolchainCompiler = compiler } = getStage (pkgConfigToolchains sharedConfig) Build
368+ -- FIXME there is total confusion here about who is filtering for the stage
367369 targets <- validatedTargets (projectConfigShared (projectConfig ctx)) compiler elaboratedPlan targetSelectors
368-
369370 let
370- (unitId, _ ) = fromMaybe (error " panic: targets should be non-empty" ) $ safeHead $ Map. toList targets
371- originalDeps = installedUnitId <$> InstallPlan. directDeps elaboratedPlan unitId
372- oci = OriginalComponentInfo unitId originalDeps
373- pkgId = fromMaybe (error $ " cannot find " ++ prettyShow unitId ) $ packageId <$> InstallPlan. lookup elaboratedPlan unitId
371+ (key, _uid ) = fromMaybe (error " panic: targets should be non-empty" ) $ safeHead $ Map. toList targets
372+ originalDeps = Graph. nodeKey <$> InstallPlan. directDeps elaboratedPlan key
373+ oci = OriginalComponentInfo key originalDeps
374+ pkgId = fromMaybe (error $ " cannot find " ++ prettyShow key ) $ packageId <$> InstallPlan. lookup elaboratedPlan key
374375 baseCtx'' = addDepsToProjectTarget (envPackages replEnvFlags) pkgId baseCtx'
375376
376377 return (Just oci, baseCtx'')
@@ -524,6 +525,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g
524525 verbosity = cfgVerbosity normal flags
525526 tempFileOptions = commonSetupTempFileOptions $ configCommonFlags configFlags
526527
528+ -- FIXME: the compiler depends on the stage!!
527529 validatedTargets ctx compiler elaboratedPlan targetSelectors = do
528530 let multi_repl_enabled = multiReplDecision ctx compiler r
529531 -- Interpret the targets on the command line as repl targets
@@ -563,8 +565,8 @@ minMultipleHomeUnitsVersion :: Version
563565minMultipleHomeUnitsVersion = mkVersion [9 , 4 ]
564566
565567data OriginalComponentInfo = OriginalComponentInfo
566- { ociUnitId :: UnitId
567- , ociOriginalDeps :: [UnitId ]
568+ { ociUnitId :: WithStage UnitId
569+ , ociOriginalDeps :: [WithStage UnitId ]
568570 }
569571 deriving (Show )
570572
@@ -599,18 +601,25 @@ addDepsToProjectTarget deps pkgId ctx =
599601generateReplFlags :: Bool -> ElaboratedInstallPlan -> OriginalComponentInfo -> [String ]
600602generateReplFlags includeTransitive elaboratedPlan OriginalComponentInfo {.. } = flags
601603 where
602- exeDeps :: [UnitId ]
604+ exeDeps :: [WithStage UnitId ]
603605 exeDeps =
604606 foldMap
605607 (InstallPlan. foldPlanPackage (const [] ) elabOrderExeDependencies)
606608 (InstallPlan. dependencyClosure elaboratedPlan [ociUnitId])
607609
608- deps , deps' , trans , trans' :: [UnitId ]
609- flags :: [String ]
610- deps = installedUnitId <$> InstallPlan. directDeps elaboratedPlan ociUnitId
610+ deps :: [WithStage UnitId ]
611+ deps = Graph. nodeKey <$> InstallPlan. directDeps elaboratedPlan ociUnitId
612+
613+ deps' :: [WithStage UnitId ]
611614 deps' = deps \\ ociOriginalDeps
612- trans = installedUnitId <$> InstallPlan. dependencyClosure elaboratedPlan deps'
615+
616+ trans :: [WithStage UnitId ]
617+ trans = Graph. nodeKey <$> InstallPlan. dependencyClosure elaboratedPlan deps'
618+
619+ trans' :: [WithStage UnitId ]
613620 trans' = trans \\ ociOriginalDeps
621+
622+ flags :: [String ]
614623 flags =
615624 fmap ((" -package-id " ++ ) . prettyShow) . (\\ exeDeps) $
616625 if includeTransitive then trans' else deps'
@@ -762,7 +771,7 @@ selectComponentTarget = selectComponentTargetBasic
762771data ReplProblem
763772 = TargetProblemMatchesMultiple MultiReplDecision TargetSelector [AvailableTarget () ]
764773 | -- | Multiple 'TargetSelector's match multiple targets
765- TargetProblemMultipleTargets MultiReplDecision TargetsMap
774+ TargetProblemMultipleTargets MultiReplDecision TargetsMapS
766775 deriving (Eq , Show )
767776
768777-- | The various error conditions that can occur when matching a
@@ -779,7 +788,7 @@ matchesMultipleProblem decision targetSelector targetsExesBuildable =
779788
780789multipleTargetsProblem
781790 :: MultiReplDecision
782- -> TargetsMap
791+ -> TargetsMapS
783792 -> ReplTargetProblem
784793multipleTargetsProblem decision = CustomTargetProblem . TargetProblemMultipleTargets decision
785794
0 commit comments