Skip to content

Commit

Permalink
Prevent rebuilds when the project file changes
Browse files Browse the repository at this point in the history
...provided that nothing else changes.
  • Loading branch information
9999years committed Dec 6, 2024
1 parent 0546f08 commit e180d68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
13 changes: 12 additions & 1 deletion cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ import Distribution.Simple.Utils (ordNub)
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.OptionalStanza
import Distribution.Solver.Types.ConstraintSource
( ConstraintSource (..)
)
import Distribution.Solver.Types.WithConstraintSource
( WithConstraintSource (..)
)
Expand Down Expand Up @@ -348,7 +351,15 @@ normaliseConfiguredPackage
-> ElaboratedConfiguredPackage
-> ElaboratedConfiguredPackage
normaliseConfiguredPackage ElaboratedSharedConfig{pkgConfigCompilerProgs} pkg =
pkg{elabProgramArgs = Map.mapMaybeWithKey lookupFilter (elabProgramArgs pkg)}
pkg
{ elabProgramArgs = Map.mapMaybeWithKey lookupFilter (elabProgramArgs pkg)
, -- Wipe the constraint source so that if (e.g.) a project file changes we
-- don't necessarily force a rebuild if nothing else changes.
elabPkgSourceLocation =
(elabPkgSourceLocation pkg)
{ constraintSource = ConstraintSourceUnknown
}
}
where
knownProgramDb = addKnownPrograms builtinPrograms pkgConfigCompilerProgs

Expand Down
21 changes: 3 additions & 18 deletions cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ Configuration is affected by the following files:
- same-filename/noncyclical-same-filename-b.config
imported by: noncyclical-same-filename-b.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- my-0.1 (lib:my) (configuration changed)
Configuring my-0.1...
Preprocessing library for my-0.1...
Building library for my-0.1...
Up to date
# checking that cyclical check catches a same file name that imports itself
# cabal v2-build
Error: [Cabal-7090]
Expand Down Expand Up @@ -182,12 +177,7 @@ Configuration is affected by the following files:
imported by: hops/hops-1.config
imported by: hops-0.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- my-0.1 (lib:my) (configuration changed)
Configuring my-0.1...
Preprocessing library for my-0.1...
Building library for my-0.1...
Up to date
# checking conflicting constraints skipping into a subfolder and then back out again and again
# cabal v2-build
Configuration is affected by the following files:
Expand Down Expand Up @@ -391,12 +381,7 @@ Configuration is affected by the following files:
imported by: yops/yops-1.config
imported by: yops-0.project
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- my-0.1 (lib:my) (configuration changed)
Configuring my-0.1...
Preprocessing library for my-0.1...
Building library for my-0.1...
Up to date
# checking bad conditional
# cabal v2-build
Error: [Cabal-7090]
Expand Down

0 comments on commit e180d68

Please sign in to comment.