Skip to content

Commit 281927c

Browse files
Backport #10548: Print info about current project file in use to stderr 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]>
1 parent 9b26613 commit 281927c

File tree

14 files changed

+21
-62
lines changed

14 files changed

+21
-62
lines changed

cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module Distribution.Solver.Types.ProjectConfigPath
1616

1717
-- * Checks and Normalization
1818
, isCyclicConfigPath
19+
, isTopLevelConfigPath
1920
, canonicalizeConfigPath
2021
) where
2122

@@ -138,6 +139,11 @@ nullProjectConfigPath = ProjectConfigPath $ "unused" :| []
138139
isCyclicConfigPath :: ProjectConfigPath -> Bool
139140
isCyclicConfigPath (ProjectConfigPath p) = length p /= length (NE.nub p)
140141

142+
-- | Check if the project config path is top-level, meaning it was not included by
143+
-- some other project config.
144+
isTopLevelConfigPath :: ProjectConfigPath -> Bool
145+
isTopLevelConfigPath (ProjectConfigPath p) = NE.length p == 1
146+
141147
-- | Prepends the path of the importee to the importer path.
142148
consProjectConfigPath :: FilePath -> ProjectConfigPath -> ProjectConfigPath
143149
consProjectConfigPath p ps = ProjectConfigPath (p <| coerce ps)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module Distribution.Client.ProjectConfig
3737
, writeProjectLocalFreezeConfig
3838
, writeProjectConfigFile
3939
, commandLineFlagsToProjectConfig
40+
, onlyTopLevelProvenance
4041

4142
-- * Packages within projects
4243
, ProjectPackageLocation (..)
@@ -1753,3 +1754,9 @@ checkBadPerPackageCompilerPaths compilerPrograms packagesConfig =
17531754
] of
17541755
[] -> return ()
17551756
ps -> throwIO (BadPerPackageCompilerPaths ps)
1757+
1758+
-- | Filter out non-top-level project configs.
1759+
onlyTopLevelProvenance :: Set ProjectConfigProvenance -> Set ProjectConfigProvenance
1760+
onlyTopLevelProvenance = Set.filter $ \case
1761+
Implicit -> False
1762+
Explicit ps -> isTopLevelConfigPath ps

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ import Distribution.Backpack.LinkedComponent
192192
import Distribution.Backpack.ModuleShape
193193

194194
import Distribution.Simple.Utils
195+
import Distribution.Verbosity
195196
import Distribution.Version
196197

197198
import qualified Distribution.InstalledPackageInfo as IPI
@@ -394,13 +395,13 @@ rebuildProjectConfig
394395
localPackages <- phaseReadLocalPackages (projectConfig <> cliConfig)
395396
return (projectConfig, localPackages)
396397

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

405406
return (projectConfig <> cliConfig, localPackages)
406407
where

cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Downloading the latest package list from test-local-repo
33
# cabal v2-run
44
Configuration is affected by the following files:
55
- cabal.project
6-
Configuration is affected by the following files:
76
- extra.project
87
imported by: cabal.project
98
Resolving dependencies...
@@ -70,9 +69,7 @@ cyclical import of cyclical-2-out-out-self-b.config;
7069
Configuration is affected by the following files:
7170
- noncyclical-same-filename-a.config
7271
imported by: noncyclical-same-filename-a.project
73-
Configuration is affected by the following files:
7472
- noncyclical-same-filename-a.project
75-
Configuration is affected by the following files:
7673
- same-filename/noncyclical-same-filename-a.config
7774
imported by: noncyclical-same-filename-a.config
7875
imported by: noncyclical-same-filename-a.project
@@ -89,9 +86,7 @@ Configuration is affected by the following files:
8986
- noncyclical-same-filename-b.config
9087
imported by: same-filename/noncyclical-same-filename-b.config
9188
imported by: noncyclical-same-filename-b.project
92-
Configuration is affected by the following files:
9389
- noncyclical-same-filename-b.project
94-
Configuration is affected by the following files:
9590
- same-filename/noncyclical-same-filename-b.config
9691
imported by: noncyclical-same-filename-b.project
9792
Up to date
@@ -126,25 +121,21 @@ cyclical import of cyclical-same-filename-out-out-back.config;
126121
# cabal v2-build
127122
Configuration is affected by the following files:
128123
- hops-0.project
129-
Configuration is affected by the following files:
130124
- hops-2.config
131125
imported by: hops/hops-1.config
132126
imported by: hops-0.project
133-
Configuration is affected by the following files:
134127
- hops-4.config
135128
imported by: hops/hops-3.config
136129
imported by: hops-2.config
137130
imported by: hops/hops-1.config
138131
imported by: hops-0.project
139-
Configuration is affected by the following files:
140132
- hops-6.config
141133
imported by: hops/hops-5.config
142134
imported by: hops-4.config
143135
imported by: hops/hops-3.config
144136
imported by: hops-2.config
145137
imported by: hops/hops-1.config
146138
imported by: hops-0.project
147-
Configuration is affected by the following files:
148139
- hops-8.config
149140
imported by: hops/hops-7.config
150141
imported by: hops-6.config
@@ -154,22 +145,18 @@ Configuration is affected by the following files:
154145
imported by: hops-2.config
155146
imported by: hops/hops-1.config
156147
imported by: hops-0.project
157-
Configuration is affected by the following files:
158148
- hops/hops-1.config
159149
imported by: hops-0.project
160-
Configuration is affected by the following files:
161150
- hops/hops-3.config
162151
imported by: hops-2.config
163152
imported by: hops/hops-1.config
164153
imported by: hops-0.project
165-
Configuration is affected by the following files:
166154
- hops/hops-5.config
167155
imported by: hops-4.config
168156
imported by: hops/hops-3.config
169157
imported by: hops-2.config
170158
imported by: hops/hops-1.config
171159
imported by: hops-0.project
172-
Configuration is affected by the following files:
173160
- hops/hops-7.config
174161
imported by: hops-6.config
175162
imported by: hops/hops-5.config
@@ -178,7 +165,6 @@ Configuration is affected by the following files:
178165
imported by: hops-2.config
179166
imported by: hops/hops-1.config
180167
imported by: hops-0.project
181-
Configuration is affected by the following files:
182168
- hops/hops-9.config
183169
imported by: hops-8.config
184170
imported by: hops/hops-7.config
@@ -194,25 +180,21 @@ Up to date
194180
# cabal v2-build
195181
Configuration is affected by the following files:
196182
- oops-0.project
197-
Configuration is affected by the following files:
198183
- oops-2.config
199184
imported by: oops/oops-1.config
200185
imported by: oops-0.project
201-
Configuration is affected by the following files:
202186
- oops-4.config
203187
imported by: oops/oops-3.config
204188
imported by: oops-2.config
205189
imported by: oops/oops-1.config
206190
imported by: oops-0.project
207-
Configuration is affected by the following files:
208191
- oops-6.config
209192
imported by: oops/oops-5.config
210193
imported by: oops-4.config
211194
imported by: oops/oops-3.config
212195
imported by: oops-2.config
213196
imported by: oops/oops-1.config
214197
imported by: oops-0.project
215-
Configuration is affected by the following files:
216198
- oops-8.config
217199
imported by: oops/oops-7.config
218200
imported by: oops-6.config
@@ -222,22 +204,18 @@ Configuration is affected by the following files:
222204
imported by: oops-2.config
223205
imported by: oops/oops-1.config
224206
imported by: oops-0.project
225-
Configuration is affected by the following files:
226207
- oops/oops-1.config
227208
imported by: oops-0.project
228-
Configuration is affected by the following files:
229209
- oops/oops-3.config
230210
imported by: oops-2.config
231211
imported by: oops/oops-1.config
232212
imported by: oops-0.project
233-
Configuration is affected by the following files:
234213
- oops/oops-5.config
235214
imported by: oops-4.config
236215
imported by: oops/oops-3.config
237216
imported by: oops-2.config
238217
imported by: oops/oops-1.config
239218
imported by: oops-0.project
240-
Configuration is affected by the following files:
241219
- oops/oops-7.config
242220
imported by: oops-6.config
243221
imported by: oops/oops-5.config
@@ -246,7 +224,6 @@ Configuration is affected by the following files:
246224
imported by: oops-2.config
247225
imported by: oops/oops-1.config
248226
imported by: oops-0.project
249-
Configuration is affected by the following files:
250227
- oops/oops-9.config
251228
imported by: oops-8.config
252229
imported by: oops/oops-7.config
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# cabal v2-configure
22
Configuration is affected by the following files:
33
- cabal.project
4-
Configuration is affected by the following files:
54
- cabal.project.local
65
'cabal.project.local' already exists, backing it up to 'cabal.project.local~'.
76
# cabal v2-configure
87
Configuration is affected by the following files:
98
- foo.project
10-
Configuration is affected by the following files:
119
- foo.project.local
1210
'foo.project.local' already exists, backing it up to 'foo.project.local~'.

cabal-testsuite/PackageTests/NewFreeze/BuildTools/new_freeze.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Wrote freeze file: <ROOT>/cabal.project.freeze
1818
# cabal v2-build
1919
Configuration is affected by the following files:
2020
- cabal.project
21-
Configuration is affected by the following files:
2221
- cabal.project.freeze
2322
Resolving dependencies...
2423
Build profile: -w ghc-<GHCVER> -O1

cabal-testsuite/PackageTests/NewFreeze/Flags/new_freeze.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Wrote freeze file: <ROOT>/cabal.project.freeze
1717
# cabal v2-build
1818
Configuration is affected by the following files:
1919
- cabal.project
20-
Configuration is affected by the following files:
2120
- cabal.project.freeze
2221
Resolving dependencies...
2322
Build profile: -w ghc-<GHCVER> -O1

cabal-testsuite/PackageTests/NewFreeze/FreezeFile/new_freeze.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Wrote freeze file: <ROOT>/cabal.project.freeze
2424
# cabal v2-build
2525
Configuration is affected by the following files:
2626
- cabal.project
27-
Configuration is affected by the following files:
2827
- cabal.project.freeze
2928
Resolving dependencies...
3029
Build profile: -w ghc-<GHCVER> -O1
@@ -41,7 +40,6 @@ Building executable 'my-exe' for my-local-package-1.0...
4140
# cabal v2-freeze
4241
Configuration is affected by the following files:
4342
- cabal.project
44-
Configuration is affected by the following files:
4543
- cabal.project.freeze
4644
Wrote freeze file: <ROOT>/cabal.project.freeze
4745
# cabal v2-build

cabal-testsuite/PackageTests/RelativePathProjectImports/cabal.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# cabal build
22
Configuration is affected by the following files:
33
- cabal.project
4-
Configuration is affected by the following files:
54
- dep/cabal.project
65
imported by: cabal.project
76
Resolving dependencies...
@@ -22,7 +21,6 @@ Building library for main-0.1...
2221
# cabal build
2322
Configuration is affected by the following files:
2423
- cabal.project
25-
Configuration is affected by the following files:
2624
- dep/cabal.project
2725
imported by: cabal.project
2826
Resolving dependencies...

cabal-testsuite/PackageTests/VersionPriority/1-local.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Downloading the latest package list from test-local-repo
33
# cabal v2-build
44
Configuration is affected by the following files:
55
- 1-local-constraints-import.project
6-
Configuration is affected by the following files:
76
- stackage-local.config
87
imported by: 1-local-constraints-import.project
98
Resolving dependencies...
@@ -21,7 +20,6 @@ After searching the rest of the dependency tree exhaustively, these were the goa
2120
# cabal v2-build
2221
Configuration is affected by the following files:
2322
- 1-local-import-constraints.project
24-
Configuration is affected by the following files:
2523
- stackage-local.config
2624
imported by: 1-local-import-constraints.project
2725
Resolving dependencies...

0 commit comments

Comments
 (0)