Skip to content

Commit f2bff67

Browse files
committed
stuff
1 parent 60df884 commit f2bff67

File tree

7 files changed

+51
-46
lines changed

7 files changed

+51
-46
lines changed

cabal-install/cabal-install.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ library
265265
, regex-posix >= 0.96.0.0 && <0.97
266266
, safe-exceptions >= 0.1.7.0 && < 0.2
267267
, semaphore-compat >= 1.0.0 && < 1.1
268+
, ansi-terminal
268269

269270
if flag(native-dns)
270271
if os(windows)

cabal-install/src/Distribution/Client/Dependency.hs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,7 @@ import qualified Data.Map as Map
169169
import qualified Data.Set as Set
170170
import Text.PrettyPrint hiding ((<>))
171171
import GHC.Stack (HasCallStack)
172-
import qualified Data.Tree
173-
import qualified Data.Graph
174-
import Distribution.Simple.Utils (ordNub)
172+
import Distribution.Client.InstallPlan (toForest, renderForest)
175173

176174
-- ------------------------------------------------------------
177175

@@ -825,7 +823,7 @@ resolveDependencies toolchains pkgConfigDB installedPkgIndex params = do
825823
[ text "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
826824
, text "Dependency tree"
827825
, text "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
828-
, renderSolverPlanTree pkgs'
826+
, text (renderForest $ Graph.fromDistinctList pkgs')
829827
]
830828

831829
validateSolverResult toolchains pkgs'
@@ -890,19 +888,6 @@ renderSolverPlanScopes pkgs = vcat
890888
g = Graph.fromDistinctList pkgs
891889
-- (_g', mapG, _invG) = Data.Graph.graphFromEdges [ (pkg, Graph.nodeKey pkg, Graph.nodeNeighbors pkg) | pkg <- pkgs]
892890

893-
894-
renderSolverPlanTree :: HasCallStack => [SolverInstallPlan.SolverPlanPackage] -> Doc
895-
renderSolverPlanTree pkgs = text (Data.Tree.drawForest dfs)
896-
where
897-
g = Graph.fromDistinctList pkgs
898-
899-
(graphForward, graphVertexToNode, graphKeyToVertex) = Graph.toGraph g
900-
901-
dfs = fmap (fmap (prettyShow . solverId . graphVertexToNode)) $ Data.Graph.dfs graphForward roots
902-
903-
Just roots = traverse graphKeyToVertex $ concat $ SolverInstallPlan.libraryRoots g : SolverInstallPlan.setupRoots g
904-
905-
906891
-- | Give an interpretation to the global 'PackagesPreference' as
907892
-- specific per-package 'PackageVersionPreference'.
908893
interpretPackagesPreference

cabal-install/src/Distribution/Client/DistDirLayout.hs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -196,34 +196,16 @@ defaultDistDirLayout projectRoot mdistDirectory haddockOutputDir =
196196
distBuildRootDirectory
197197
</> prettyShow (distParamPlatform params)
198198
</> prettyShow (distParamCompilerId params)
199-
</> prettyShow (distParamPackageId params)
200-
</> ( case distParamComponentName params of
201-
Nothing -> ""
202-
Just (CLibName LMainLibName) -> ""
203-
Just (CLibName (LSubLibName name)) -> "l" </> prettyShow name
204-
Just (CFLibName name) -> "f" </> prettyShow name
205-
Just (CExeName name) -> "x" </> prettyShow name
206-
Just (CTestName name) -> "t" </> prettyShow name
207-
Just (CBenchName name) -> "b" </> prettyShow name
208-
)
209-
</> ( case distParamOptimization params of
210-
NoOptimisation -> "noopt"
211-
NormalOptimisation -> ""
212-
MaximumOptimisation -> "opt"
213-
)
214-
</> ( let uid_str = prettyShow (distParamUnitId params)
215-
in if uid_str == prettyShow (distParamComponentId params)
216-
then ""
217-
else uid_str
218-
)
219-
199+
</> prettyShow (distParamUnitId params)
200+
220201
distUnpackedSrcRootDirectory :: FilePath
221202
distUnpackedSrcRootDirectory = distDirectory </> "src"
222203

223204
distUnpackedSrcDirectory :: PackageId -> FilePath
224205
distUnpackedSrcDirectory pkgid =
225206
distUnpackedSrcRootDirectory
226207
</> prettyShow pkgid
208+
227209
-- we shouldn't get name clashes so this should be fine:
228210
distDownloadSrcDirectory :: FilePath
229211
distDownloadSrcDirectory = distUnpackedSrcRootDirectory

cabal-install/src/Distribution/Client/InstallPlan.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ module Distribution.Client.InstallPlan
7272
, reverseTopologicalOrder
7373
, reverseDependencyClosure
7474
, project
75+
, toForest
76+
, renderForest
77+
, renderPlanForest
7578
) where
7679

7780
import Distribution.Client.Compat.Prelude hiding (lookup, toList)
@@ -120,6 +123,8 @@ import GHC.Stack
120123
import Data.Bifunctor
121124
import Data.Bifoldable
122125
import Data.Bitraversable
126+
import Data.Graph (dfs, topSort)
127+
import Data.Tree (Tree, drawForest)
123128

124129
-- When cabal tries to install a number of packages, including all their
125130
-- dependencies it has a non-trivial problem to solve.
@@ -539,6 +544,18 @@ reverseDependencyClosure plan =
539544
fromMaybe []
540545
. Graph.revClosure (planGraph plan)
541546

547+
toForest :: Graph.Graph a -> [Tree a]
548+
toForest g = fmap (fmap graphVertexToNode) $ dfs graphForward (topSort graphForward)
549+
550+
where
551+
(graphForward, graphVertexToNode, _graphKeyToVertex) = Graph.toGraph g
552+
553+
renderForest :: (IsNode a, Pretty (Key a)) => Graph a -> String
554+
renderForest = drawForest . fmap (fmap (prettyShow . Graph.nodeKey)) . toForest
555+
556+
renderPlanForest :: (IsNode ipkg, IsNode srcpkg, Key ipkg ~ Key srcpkg, Pretty (Key srcpkg)) => GenericInstallPlan' key ipkg srcpkg -> String
557+
renderPlanForest = renderForest . planGraph
558+
542559
project
543560
:: HasCallStack
544561
=> ( IsNode ipkg1, Key ipkg1 ~ keyA

cabal-install/src/Distribution/Client/ProjectBuilding.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ rebuildTarget
542542
_ -> return ()
543543
return $ BuildResult DocsNotTried TestsNotTried Nothing
544544
| otherwise = do
545-
info verbosity $ "[rebuildTarget] Rebuilding " ++ prettyShow (nodeKey pkg) ++ " with current status " ++ buildStatusToString pkgBuildStatus
545+
infoNoWrap verbosity $ "[rebuildTarget] Rebuilding " ++ prettyShow (nodeKey pkg) ++ " with current status " ++ buildStatusToString pkgBuildStatus
546546
-- We rely on the 'BuildStatus' to decide which phase to start from:
547547
case pkgBuildStatus of
548548
BuildStatusDownload -> downloadPhase

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module Distribution.Client.ProjectPlanning
108108
, reportPlanningFailure
109109
) where
110110

111-
import Distribution.Client.Compat.Prelude
111+
import Distribution.Client.Compat.Prelude hiding (get)
112112
import Text.PrettyPrint
113113
( comma
114114
, fsep
@@ -231,7 +231,7 @@ import qualified Distribution.Compat.Graph as Graph
231231
import Control.Exception (assert)
232232
import Control.Monad (sequence)
233233
import Control.Monad.IO.Class (liftIO)
234-
import Control.Monad.State as State (StateT (..), execStateT, gets, modify)
234+
import Control.Monad.State (StateT (..), evalStateT, execStateT, gets, modify, get)
235235
import Data.Foldable (fold)
236236
import Data.List (deleteBy, groupBy)
237237
import qualified Data.List.NonEmpty as NE
@@ -245,6 +245,7 @@ import GHC.Stack (HasCallStack)
245245
import Distribution.Client.InstallPlan (foldPlanPackage)
246246
import Distribution.Solver.Types.ResolverPackage (solverId)
247247
import qualified Distribution.Solver.Types.ResolverPackage as ResolverPackage
248+
import System.Console.ANSI
248249

249250
-- | Check that an 'ElaboratedConfiguredPackage' actually makes
250251
-- sense under some 'ElaboratedSharedConfig'.
@@ -694,6 +695,23 @@ rebuildInstallPlan
694695
-- changes, so it's worth caching them separately.
695696
improvedPlan <- phaseImprovePlan elaboratedPlan elaboratedShared
696697

698+
let s = flip foldMap (InstallPlan.toList elaboratedPlan) $
699+
foldPlanPackage
700+
(Set.singleton . Graph.nodeKey)
701+
(const Set.empty)
702+
badMsg s = Disp.text (setSGRCode [SetColor Foreground Vivid Red] <> s <> setSGRCode [Reset])
703+
goodMsg s = Disp.text (setSGRCode [SetColor Foreground Vivid Green] <> s <> setSGRCode [Reset])
704+
flip evalStateT s $ for_ (InstallPlan.executionOrder elaboratedPlan) $ \(ReadyPackage pkg) -> do
705+
s' <- get
706+
liftIO $ infoNoWrap verbosity $ show $
707+
Disp.hang (Disp.text "Elaborated package: " <+> pretty (Graph.nodeKey pkg)) 4 $ vcat
708+
[ Disp.hang (text "elabOrderDependencies") 4 $ Disp.vcat
709+
[ pretty dep <+> Disp.parens (if Set.member dep s' then goodMsg "preset" else badMsg "missing")
710+
| dep <- sort (elabOrderDependencies pkg)
711+
]
712+
]
713+
modify (Set.insert (Graph.nodeKey pkg))
714+
697715
return (improvedPlan, elaboratedPlan, elaboratedShared, totalIndexState, activeRepos)
698716
where
699717
fileMonitorSolverPlan = newFileMonitorInCacheDir "solver-plan"
@@ -2305,15 +2323,17 @@ elaborateInstallPlan
23052323
elabRegisterPackageDBStack = buildAndRegisterDbs elabStage
23062324
elabSetupPackageDBStack = buildAndRegisterDbs (prevStage elabStage)
23072325

2326+
-- used in fixupBuildStyle :facepalm:
23082327
elabInplaceBuildPackageDBStack = inplacePackageDbs elabStage
23092328
elabInplaceRegisterPackageDBStack = inplacePackageDbs elabStage
23102329
elabInplaceSetupPackageDBStack = inplacePackageDbs (prevStage elabStage)
23112330

23122331
buildAndRegisterDbs stage
23132332
| shouldBuildInplaceOnly pkg = inplacePackageDbs stage
23142333
| otherwise = corePackageDbs stage
2334+
23152335
-- Same as corePackageDbs but with the addition of the in-place packagedb.
2316-
inplacePackageDbs stage = corePackageDbs stage ++ [distPackageDB (compilerId (getStage compilers stage))]
2336+
inplacePackageDbs stage = corePackageDbs stage ++ [SpecificPackageDB (distDirectory </> "packagedb" </> prettyShow stage </> prettyShow (compilerId (getStage compilers stage)))]
23172337

23182338
-- The project packagedbs (typically the global packagedb but others can be added) followed by the store.
23192339
corePackageDbs stage = getStage packageDbs stage ++ [storePackageDB storeDirLayout (getStage compilers stage)]

cabal-install/src/Distribution/Client/SetupWrapper.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ import Distribution.Utils.Generic
169169
)
170170

171171
import Distribution.Compat.Stack
172-
import Distribution.ReadE
173172
import Distribution.System (Platform (..), buildPlatform)
174173
import Distribution.Utils.NubList
175174
( toNubListR
@@ -1139,9 +1138,10 @@ getExternalSetupMethod verbosity options pkg bt = do
11391138
-- when compiling a Simple Setup.hs file.
11401139
, ghcOptExtensionMap = Map.fromList . Simple.compilerExtensions $ compiler
11411140
}
1142-
debug verbosity $ "maybeCabalLibInstalledPkgId: " ++ show maybeCabalLibInstalledPkgId
1143-
debug verbosity $ "cabalDep: " ++ show cabalDep
1144-
debug verbosity $ "packages: " ++ show selectedDeps
1141+
infoNoWrap verbosity $ prettyShow options'
1142+
infoNoWrap verbosity $ "maybeCabalLibInstalledPkgId: " ++ show maybeCabalLibInstalledPkgId
1143+
infoNoWrap verbosity $ "cabalDep: " ++ show cabalDep
1144+
infoNoWrap verbosity $ "packages: " ++ show selectedDeps
11451145
let ghcCmdLine = renderGhcOptions compiler platform ghcOptions
11461146
when (useVersionMacros options') $
11471147
rewriteFileEx verbosity (i cppMacrosFile) $

0 commit comments

Comments
 (0)