Skip to content

Commit 2844e3e

Browse files
committed
Prevent rebuilds when the project file changes
...provided that nothing else changes.
1 parent 0546f08 commit 2844e3e

File tree

2 files changed

+15
-19
lines changed
  • cabal-install/src/Distribution/Client/ProjectPlanning
  • cabal-testsuite/PackageTests/ConditionalAndImport

2 files changed

+15
-19
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ import Distribution.Simple.Setup
110110
import Distribution.Simple.Utils (ordNub)
111111
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
112112
import qualified Distribution.Solver.Types.ComponentDeps as CD
113+
import Distribution.Solver.Types.ConstraintSource
114+
( ConstraintSource (..)
115+
)
113116
import Distribution.Solver.Types.OptionalStanza
114117
import Distribution.Solver.Types.WithConstraintSource
115118
( WithConstraintSource (..)
@@ -348,7 +351,15 @@ normaliseConfiguredPackage
348351
-> ElaboratedConfiguredPackage
349352
-> ElaboratedConfiguredPackage
350353
normaliseConfiguredPackage ElaboratedSharedConfig{pkgConfigCompilerProgs} pkg =
351-
pkg{elabProgramArgs = Map.mapMaybeWithKey lookupFilter (elabProgramArgs pkg)}
354+
pkg
355+
{ elabProgramArgs = Map.mapMaybeWithKey lookupFilter (elabProgramArgs pkg)
356+
, -- Wipe the constraint source so that if (e.g.) a project file changes we
357+
-- don't necessarily force a rebuild if nothing else changes.
358+
elabPkgSourceLocation =
359+
(elabPkgSourceLocation pkg)
360+
{ constraintSource = ConstraintSourceUnknown
361+
}
362+
}
352363
where
353364
knownProgramDb = addKnownPrograms builtinPrograms pkgConfigCompilerProgs
354365

cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ Configuration is affected by the following files:
9090
- same-filename/noncyclical-same-filename-b.config
9191
imported by: noncyclical-same-filename-b.project
9292
Resolving dependencies...
93-
Build profile: -w ghc-<GHCVER> -O1
94-
In order, the following will be built:
95-
- my-0.1 (lib:my) (configuration changed)
96-
Configuring my-0.1...
97-
Preprocessing library for my-0.1...
98-
Building library for my-0.1...
93+
Up to date
9994
# checking that cyclical check catches a same file name that imports itself
10095
# cabal v2-build
10196
Error: [Cabal-7090]
@@ -182,12 +177,7 @@ Configuration is affected by the following files:
182177
imported by: hops/hops-1.config
183178
imported by: hops-0.project
184179
Resolving dependencies...
185-
Build profile: -w ghc-<GHCVER> -O1
186-
In order, the following will be built:
187-
- my-0.1 (lib:my) (configuration changed)
188-
Configuring my-0.1...
189-
Preprocessing library for my-0.1...
190-
Building library for my-0.1...
180+
Up to date
191181
# checking conflicting constraints skipping into a subfolder and then back out again and again
192182
# cabal v2-build
193183
Configuration is affected by the following files:
@@ -391,12 +381,7 @@ Configuration is affected by the following files:
391381
imported by: yops/yops-1.config
392382
imported by: yops-0.project
393383
Resolving dependencies...
394-
Build profile: -w ghc-<GHCVER> -O1
395-
In order, the following will be built:
396-
- my-0.1 (lib:my) (configuration changed)
397-
Configuring my-0.1...
398-
Preprocessing library for my-0.1...
399-
Building library for my-0.1...
384+
Up to date
400385
# checking bad conditional
401386
# cabal v2-build
402387
Error: [Cabal-7090]

0 commit comments

Comments
 (0)