Skip to content

Commit

Permalink
Extract targetForms
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 31, 2024
1 parent d804e44 commit 1c73eca
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cabal-install/src/Distribution/Client/CmdTarget.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,10 @@ reportBuildTargetProblems verbosity problems =

printTargetForms :: TargetsMap -> ElaboratedInstallPlan -> IO ()
printTargetForms targets elaboratedPlan = do
putStrLn . render . nest 1 . vcat . ((text "-" <+>) . text <$>) . sort $
catMaybes
[ targetForm ct pkgs
| (u :: UnitId, xs) <- Map.toAscList targets
, (ct :: ComponentTarget, _) <- xs
, let pkgs = filter ((== u) . elabUnitId) localPkgs
putStrLn . render $
vcat
[ text "Fully qualified target forms" Pretty.<> colon
, nest 1 $ vcat [text "-" <+> text tf | tf <- targetForms]
]
where
localPkgs =
Expand All @@ -163,3 +161,12 @@ printTargetForms targets elaboratedPlan = do
targetForm ct (x : _) =
let pkgId@PackageIdentifier{pkgName = n} = elabPkgSourceId x
in Just . render $ pretty n Pretty.<> colon Pretty.<> text (showComponentTarget pkgId ct)

targetForms =
sort $
catMaybes
[ targetForm ct pkgs
| (u :: UnitId, xs) <- Map.toAscList targets
, (ct :: ComponentTarget, _) <- xs
, let pkgs = filter ((== u) . elabUnitId) localPkgs
]

0 comments on commit 1c73eca

Please sign in to comment.