From 7f89bd04e4d55185ed66b7f3c9e0ff985ad9b30c Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Mon, 11 Nov 2024 20:48:54 -0500 Subject: [PATCH] only report top-level project config files in the default verbosity in verbose mode report imported files too --- .../src/Distribution/Solver/Types/ProjectConfigPath.hs | 6 ++++++ cabal-install/src/Distribution/Client/ProjectConfig.hs | 7 +++++++ cabal-install/src/Distribution/Client/ProjectPlanning.hs | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs b/cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs index c57ade0c3e3..b98d493656c 100644 --- a/cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs +++ b/cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs @@ -16,6 +16,7 @@ module Distribution.Solver.Types.ProjectConfigPath -- * Checks and Normalization , isCyclicConfigPath + , isTopLevelConfigPath , canonicalizeConfigPath ) where @@ -138,6 +139,11 @@ nullProjectConfigPath = ProjectConfigPath $ "unused" :| [] isCyclicConfigPath :: ProjectConfigPath -> Bool isCyclicConfigPath (ProjectConfigPath p) = length p /= length (NE.nub p) +-- | Check if the project config path is top-level, meaning it was not included by +-- some other project config. +isTopLevelConfigPath :: ProjectConfigPath -> Bool +isTopLevelConfigPath (ProjectConfigPath p) = NE.length p == 1 + -- | Prepends the path of the importee to the importer path. consProjectConfigPath :: FilePath -> ProjectConfigPath -> ProjectConfigPath consProjectConfigPath p ps = ProjectConfigPath (p <| coerce ps) diff --git a/cabal-install/src/Distribution/Client/ProjectConfig.hs b/cabal-install/src/Distribution/Client/ProjectConfig.hs index 72328978d2f..c0036d45dc5 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig.hs @@ -37,6 +37,7 @@ module Distribution.Client.ProjectConfig , writeProjectLocalFreezeConfig , writeProjectConfigFile , commandLineFlagsToProjectConfig + , onlyTopLevelProvenance -- * Packages within projects , ProjectPackageLocation (..) @@ -1753,3 +1754,9 @@ checkBadPerPackageCompilerPaths compilerPrograms packagesConfig = ] of [] -> return () ps -> throwIO (BadPerPackageCompilerPaths ps) + +-- | Filter out non-top-level project configs +onlyTopLevelProvenance :: Set ProjectConfigProvenance -> Set ProjectConfigProvenance +onlyTopLevelProvenance = Set.filter $ \case + Implicit -> False + Explicit ps -> isTopLevelConfigPath ps diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 5f1b98d8136..95a03e1a1af 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -401,7 +401,7 @@ rebuildProjectConfig notice (verboseStderr verbosity) . render . vcat $ text "Configuration is affected by the following files:" : [ text "-" <+> docProjectConfigPath path - | Explicit path <- Set.toList $ projectConfigProvenance projectConfig + | Explicit path <- Set.toList . (if verbosity >= verbose then id else onlyTopLevelProvenance) $ projectConfigProvenance projectConfig ] return (projectConfig <> cliConfig, localPackages)