Skip to content

Commit

Permalink
Backport #10548: Print info about current project file in use to stde…
Browse files Browse the repository at this point in the history
…rr and ignore the imports by default (#10550)

* Print info about current project file in use to stderr and ignore the imports by default (#10548)

* Print info about current project file in use to stderr (fix #10547)

* only report top-level project config files in the default verbosity

in verbose mode report imported files too

* fix tests

* don't print anything when provenance is empty

* fix tests

* Apply suggestions from code review

Co-authored-by: ffaf1 <[email protected]>

---------

Co-authored-by: ffaf1 <[email protected]>
(cherry picked from commit 7de199a)

# Conflicts:
#	cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out

* fixup! fix conflicts

---------

Co-authored-by: Artem Pelenitsyn <[email protected]>
  • Loading branch information
mergify[bot] and ulysses4ever authored Nov 18, 2024
1 parent 9b26613 commit 281927c
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Distribution.Solver.Types.ProjectConfigPath

-- * Checks and Normalization
, isCyclicConfigPath
, isTopLevelConfigPath
, canonicalizeConfigPath
) where

Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions cabal-install/src/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module Distribution.Client.ProjectConfig
, writeProjectLocalFreezeConfig
, writeProjectConfigFile
, commandLineFlagsToProjectConfig
, onlyTopLevelProvenance

-- * Packages within projects
, ProjectPackageLocation (..)
Expand Down Expand Up @@ -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
15 changes: 8 additions & 7 deletions cabal-install/src/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ import Distribution.Backpack.LinkedComponent
import Distribution.Backpack.ModuleShape

import Distribution.Simple.Utils
import Distribution.Verbosity
import Distribution.Version

import qualified Distribution.InstalledPackageInfo as IPI
Expand Down Expand Up @@ -394,13 +395,13 @@ rebuildProjectConfig
localPackages <- phaseReadLocalPackages (projectConfig <> cliConfig)
return (projectConfig, localPackages)

sequence_
[ do
notice verbosity . render . vcat $
text "Configuration is affected by the following files:"
: [text "-" <+> docProjectConfigPath path]
| Explicit path <- Set.toList $ projectConfigProvenance projectConfig
]
let configfiles =
[ text "-" <+> docProjectConfigPath path
| Explicit path <- Set.toList . (if verbosity >= verbose then id else onlyTopLevelProvenance) $ projectConfigProvenance projectConfig
]
unless (null configfiles) $
notice (verboseStderr verbosity) . render . vcat $
text "Configuration is affected by the following files:" : configfiles

return (projectConfig <> cliConfig, localPackages)
where
Expand Down
23 changes: 0 additions & 23 deletions cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Downloading the latest package list from test-local-repo
# cabal v2-run
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- extra.project
imported by: cabal.project
Resolving dependencies...
Expand Down Expand Up @@ -70,9 +69,7 @@ cyclical import of cyclical-2-out-out-self-b.config;
Configuration is affected by the following files:
- noncyclical-same-filename-a.config
imported by: noncyclical-same-filename-a.project
Configuration is affected by the following files:
- noncyclical-same-filename-a.project
Configuration is affected by the following files:
- same-filename/noncyclical-same-filename-a.config
imported by: noncyclical-same-filename-a.config
imported by: noncyclical-same-filename-a.project
Expand All @@ -89,9 +86,7 @@ Configuration is affected by the following files:
- noncyclical-same-filename-b.config
imported by: same-filename/noncyclical-same-filename-b.config
imported by: noncyclical-same-filename-b.project
Configuration is affected by the following files:
- noncyclical-same-filename-b.project
Configuration is affected by the following files:
- same-filename/noncyclical-same-filename-b.config
imported by: noncyclical-same-filename-b.project
Up to date
Expand Down Expand Up @@ -126,25 +121,21 @@ cyclical import of cyclical-same-filename-out-out-back.config;
# cabal v2-build
Configuration is affected by the following files:
- hops-0.project
Configuration is affected by the following files:
- hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops-6.config
imported by: hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops-8.config
imported by: hops/hops-7.config
imported by: hops-6.config
Expand All @@ -154,22 +145,18 @@ Configuration is affected by the following files:
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops/hops-7.config
imported by: hops-6.config
imported by: hops/hops-5.config
Expand All @@ -178,7 +165,6 @@ Configuration is affected by the following files:
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
Configuration is affected by the following files:
- hops/hops-9.config
imported by: hops-8.config
imported by: hops/hops-7.config
Expand All @@ -194,25 +180,21 @@ Up to date
# cabal v2-build
Configuration is affected by the following files:
- oops-0.project
Configuration is affected by the following files:
- oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops-4.config
imported by: oops/oops-3.config
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops-6.config
imported by: oops/oops-5.config
imported by: oops-4.config
imported by: oops/oops-3.config
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops-8.config
imported by: oops/oops-7.config
imported by: oops-6.config
Expand All @@ -222,22 +204,18 @@ Configuration is affected by the following files:
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops/oops-3.config
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops/oops-5.config
imported by: oops-4.config
imported by: oops/oops-3.config
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops/oops-7.config
imported by: oops-6.config
imported by: oops/oops-5.config
Expand All @@ -246,7 +224,6 @@ Configuration is affected by the following files:
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
Configuration is affected by the following files:
- oops/oops-9.config
imported by: oops-8.config
imported by: oops/oops-7.config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# cabal v2-configure
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project.local
'cabal.project.local' already exists, backing it up to 'cabal.project.local~'.
# cabal v2-configure
Configuration is affected by the following files:
- foo.project
Configuration is affected by the following files:
- foo.project.local
'foo.project.local' already exists, backing it up to 'foo.project.local~'.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Wrote freeze file: <ROOT>/cabal.project.freeze
# cabal v2-build
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project.freeze
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Wrote freeze file: <ROOT>/cabal.project.freeze
# cabal v2-build
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project.freeze
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Wrote freeze file: <ROOT>/cabal.project.freeze
# cabal v2-build
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project.freeze
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
Expand All @@ -41,7 +40,6 @@ Building executable 'my-exe' for my-local-package-1.0...
# cabal v2-freeze
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- cabal.project.freeze
Wrote freeze file: <ROOT>/cabal.project.freeze
# cabal v2-build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cabal build
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- dep/cabal.project
imported by: cabal.project
Resolving dependencies...
Expand All @@ -22,7 +21,6 @@ Building library for main-0.1...
# cabal build
Configuration is affected by the following files:
- cabal.project
Configuration is affected by the following files:
- dep/cabal.project
imported by: cabal.project
Resolving dependencies...
Expand Down
2 changes: 0 additions & 2 deletions cabal-testsuite/PackageTests/VersionPriority/1-local.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Downloading the latest package list from test-local-repo
# cabal v2-build
Configuration is affected by the following files:
- 1-local-constraints-import.project
Configuration is affected by the following files:
- stackage-local.config
imported by: 1-local-constraints-import.project
Resolving dependencies...
Expand All @@ -21,7 +20,6 @@ After searching the rest of the dependency tree exhaustively, these were the goa
# cabal v2-build
Configuration is affected by the following files:
- 1-local-import-constraints.project
Configuration is affected by the following files:
- stackage-local.config
imported by: 1-local-import-constraints.project
Resolving dependencies...
Expand Down
4 changes: 0 additions & 4 deletions cabal-testsuite/PackageTests/VersionPriority/1-web.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ Downloading the latest package list from test-local-repo
# cabal v2-build
Configuration is affected by the following files:
- 1-web-constraints-import.project
Configuration is affected by the following files:
- project-stackage/nightly-2023-12-07.config
imported by: 1-web-constraints-import.project
Configuration is affected by the following files:
- with-ghc.config
imported by: 1-web-constraints-import.project
Resolving dependencies...
Expand All @@ -24,10 +22,8 @@ After searching the rest of the dependency tree exhaustively, these were the goa
# cabal v2-build
Configuration is affected by the following files:
- 1-web-import-constraints.project
Configuration is affected by the following files:
- project-stackage/nightly-2023-12-07.config
imported by: 1-web-import-constraints.project
Configuration is affected by the following files:
- with-ghc.config
imported by: 1-web-import-constraints.project
Resolving dependencies...
Expand Down
4 changes: 0 additions & 4 deletions cabal-testsuite/PackageTests/VersionPriority/2-local.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ Downloading the latest package list from test-local-repo
# cabal v2-build
Configuration is affected by the following files:
- 2-local-constraints-import.project
Configuration is affected by the following files:
- hop-local.config
imported by: 2-local-constraints-import.project
Configuration is affected by the following files:
- stackage-local.config
imported by: hop-local.config
imported by: 2-local-constraints-import.project
Expand All @@ -26,10 +24,8 @@ After searching the rest of the dependency tree exhaustively, these were the goa
# cabal v2-build
Configuration is affected by the following files:
- 2-local-import-constraints.project
Configuration is affected by the following files:
- hop-local.config
imported by: 2-local-import-constraints.project
Configuration is affected by the following files:
- stackage-local.config
imported by: hop-local.config
imported by: 2-local-import-constraints.project
Expand Down
6 changes: 0 additions & 6 deletions cabal-testsuite/PackageTests/VersionPriority/2-web.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ Downloading the latest package list from test-local-repo
# cabal v2-build
Configuration is affected by the following files:
- 2-web-constraints-import.project
Configuration is affected by the following files:
- project-stackage/nightly-2023-12-07.config
imported by: stackage-web.config
imported by: 2-web-constraints-import.project
Configuration is affected by the following files:
- stackage-web.config
imported by: 2-web-constraints-import.project
Configuration is affected by the following files:
- with-ghc.config
imported by: 2-web-constraints-import.project
Resolving dependencies...
Expand All @@ -29,14 +26,11 @@ After searching the rest of the dependency tree exhaustively, these were the goa
# cabal v2-build
Configuration is affected by the following files:
- 2-web-import-constraints.project
Configuration is affected by the following files:
- project-stackage/nightly-2023-12-07.config
imported by: stackage-web.config
imported by: 2-web-import-constraints.project
Configuration is affected by the following files:
- stackage-web.config
imported by: 2-web-import-constraints.project
Configuration is affected by the following files:
- with-ghc.config
imported by: 2-web-import-constraints.project
Resolving dependencies...
Expand Down
8 changes: 0 additions & 8 deletions cabal-testsuite/PackageTests/VersionPriority/3-web.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ Downloading the latest package list from test-local-repo
# cabal v2-build
Configuration is affected by the following files:
- 3-web-constraints-import.project
Configuration is affected by the following files:
- hop-web.config
imported by: 3-web-constraints-import.project
Configuration is affected by the following files:
- project-stackage/nightly-2023-12-07.config
imported by: stackage-web.config
imported by: hop-web.config
imported by: 3-web-constraints-import.project
Configuration is affected by the following files:
- stackage-web.config
imported by: hop-web.config
imported by: 3-web-constraints-import.project
Configuration is affected by the following files:
- with-ghc.config
imported by: 3-web-constraints-import.project
Resolving dependencies...
Expand All @@ -35,19 +31,15 @@ After searching the rest of the dependency tree exhaustively, these were the goa
# cabal v2-build
Configuration is affected by the following files:
- 3-web-import-constraints.project
Configuration is affected by the following files:
- hop-web.config
imported by: 3-web-import-constraints.project
Configuration is affected by the following files:
- project-stackage/nightly-2023-12-07.config
imported by: stackage-web.config
imported by: hop-web.config
imported by: 3-web-import-constraints.project
Configuration is affected by the following files:
- stackage-web.config
imported by: hop-web.config
imported by: 3-web-import-constraints.project
Configuration is affected by the following files:
- with-ghc.config
imported by: 3-web-import-constraints.project
Resolving dependencies...
Expand Down

0 comments on commit 281927c

Please sign in to comment.