Skip to content

Commit 7de199a

Browse files
ulysses4everffaf1
andauthored
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]>
1 parent 287d347 commit 7de199a

File tree

14 files changed

+21
-87
lines changed

14 files changed

+21
-87
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
@@ -195,6 +195,7 @@ import Distribution.Backpack.LinkedComponent
195195
import Distribution.Backpack.ModuleShape
196196

197197
import Distribution.Simple.Utils
198+
import Distribution.Verbosity
198199
import Distribution.Version
199200

200201
import qualified Distribution.InstalledPackageInfo as IPI
@@ -397,13 +398,13 @@ rebuildProjectConfig
397398
localPackages <- phaseReadLocalPackages (projectConfig <> cliConfig)
398399
return (projectConfig, localPackages)
399400

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

408409
return (projectConfig <> cliConfig, localPackages)
409410
where

cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out

Lines changed: 0 additions & 48 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
@@ -281,57 +258,47 @@ After searching the rest of the dependency tree exhaustively, these were the goa
281258
# cabal v2-build
282259
Configuration is affected by the following files:
283260
- yops-0.project
284-
Configuration is affected by the following files:
285261
- yops-2.config
286262
imported by: yops/yops-1.config
287263
imported by: yops-0.project
288-
Configuration is affected by the following files:
289264
- yops-4.config
290265
imported by: yops/yops-3.config
291266
imported by: yops-0.project
292-
Configuration is affected by the following files:
293267
- yops-4.config
294268
imported by: yops/yops-3.config
295269
imported by: yops-2.config
296270
imported by: yops/yops-1.config
297271
imported by: yops-0.project
298-
Configuration is affected by the following files:
299272
- yops-6.config
300273
imported by: yops/yops-5.config
301274
imported by: yops-0.project
302-
Configuration is affected by the following files:
303275
- yops-6.config
304276
imported by: yops/yops-5.config
305277
imported by: yops-4.config
306278
imported by: yops/yops-3.config
307279
imported by: yops-0.project
308-
Configuration is affected by the following files:
309280
- yops-6.config
310281
imported by: yops/yops-5.config
311282
imported by: yops-4.config
312283
imported by: yops/yops-3.config
313284
imported by: yops-2.config
314285
imported by: yops/yops-1.config
315286
imported by: yops-0.project
316-
Configuration is affected by the following files:
317287
- yops-8.config
318288
imported by: yops/yops-7.config
319289
imported by: yops-0.project
320-
Configuration is affected by the following files:
321290
- yops-8.config
322291
imported by: yops/yops-7.config
323292
imported by: yops-6.config
324293
imported by: yops/yops-5.config
325294
imported by: yops-0.project
326-
Configuration is affected by the following files:
327295
- yops-8.config
328296
imported by: yops/yops-7.config
329297
imported by: yops-6.config
330298
imported by: yops/yops-5.config
331299
imported by: yops-4.config
332300
imported by: yops/yops-3.config
333301
imported by: yops-0.project
334-
Configuration is affected by the following files:
335302
- yops-8.config
336303
imported by: yops/yops-7.config
337304
imported by: yops-6.config
@@ -341,48 +308,38 @@ Configuration is affected by the following files:
341308
imported by: yops-2.config
342309
imported by: yops/yops-1.config
343310
imported by: yops-0.project
344-
Configuration is affected by the following files:
345311
- yops/yops-1.config
346312
imported by: yops-0.project
347-
Configuration is affected by the following files:
348313
- yops/yops-3.config
349314
imported by: yops-0.project
350-
Configuration is affected by the following files:
351315
- yops/yops-3.config
352316
imported by: yops-2.config
353317
imported by: yops/yops-1.config
354318
imported by: yops-0.project
355-
Configuration is affected by the following files:
356319
- yops/yops-5.config
357320
imported by: yops-0.project
358-
Configuration is affected by the following files:
359321
- yops/yops-5.config
360322
imported by: yops-4.config
361323
imported by: yops/yops-3.config
362324
imported by: yops-0.project
363-
Configuration is affected by the following files:
364325
- yops/yops-5.config
365326
imported by: yops-4.config
366327
imported by: yops/yops-3.config
367328
imported by: yops-2.config
368329
imported by: yops/yops-1.config
369330
imported by: yops-0.project
370-
Configuration is affected by the following files:
371331
- yops/yops-7.config
372332
imported by: yops-0.project
373-
Configuration is affected by the following files:
374333
- yops/yops-7.config
375334
imported by: yops-6.config
376335
imported by: yops/yops-5.config
377336
imported by: yops-0.project
378-
Configuration is affected by the following files:
379337
- yops/yops-7.config
380338
imported by: yops-6.config
381339
imported by: yops/yops-5.config
382340
imported by: yops-4.config
383341
imported by: yops/yops-3.config
384342
imported by: yops-0.project
385-
Configuration is affected by the following files:
386343
- yops/yops-7.config
387344
imported by: yops-6.config
388345
imported by: yops/yops-5.config
@@ -391,22 +348,18 @@ Configuration is affected by the following files:
391348
imported by: yops-2.config
392349
imported by: yops/yops-1.config
393350
imported by: yops-0.project
394-
Configuration is affected by the following files:
395351
- yops/yops-9.config
396352
imported by: yops-0.project
397-
Configuration is affected by the following files:
398353
- yops/yops-9.config
399354
imported by: yops-8.config
400355
imported by: yops/yops-7.config
401356
imported by: yops-0.project
402-
Configuration is affected by the following files:
403357
- yops/yops-9.config
404358
imported by: yops-8.config
405359
imported by: yops/yops-7.config
406360
imported by: yops-6.config
407361
imported by: yops/yops-5.config
408362
imported by: yops-0.project
409-
Configuration is affected by the following files:
410363
- yops/yops-9.config
411364
imported by: yops-8.config
412365
imported by: yops/yops-7.config
@@ -415,7 +368,6 @@ Configuration is affected by the following files:
415368
imported by: yops-4.config
416369
imported by: yops/yops-3.config
417370
imported by: yops-0.project
418-
Configuration is affected by the following files:
419371
- yops/yops-9.config
420372
imported by: yops-8.config
421373
imported by: yops/yops-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

0 commit comments

Comments
 (0)