File tree 10 files changed +55
-5
lines changed
Cabal-syntax/src/Distribution/Types
cabal-install/src/Distribution/Client
cabal-testsuite/PackageTests/ReplBuildDepends
10 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 1
1
{-# LANGUAGE DeriveDataTypeable #-}
2
2
{-# LANGUAGE DeriveGeneric #-}
3
3
{-# LANGUAGE FlexibleContexts #-}
4
- {-# LANGUAGE GeneralizedNewtypeDeriving #-}
5
4
{-# LANGUAGE ScopedTypeVariables #-}
6
5
7
6
module Distribution.Types.GenericPackageDescription (
@@ -86,15 +85,14 @@ instance L.HasBuildInfos GenericPackageDescription where
86
85
<*> (traverse . L. _2 . traverseCondTreeBuildInfo) f x4
87
86
<*> (traverse . L. _2 . traverseCondTreeBuildInfo) f x5
88
87
<*> (traverse . L. _2 . traverseCondTreeBuildInfo) f x6
89
- where
90
88
91
89
-- We use this traversal to keep [Dependency] field in CondTree up to date.
92
90
traverseCondTreeBuildInfo
93
91
:: forall f comp v . (Applicative f , L. HasBuildInfo comp )
94
92
=> LensLike' f (CondTree v [Dependency ] comp ) L. BuildInfo
95
93
traverseCondTreeBuildInfo g = node where
96
94
mkCondNode :: comp -> [CondBranch v [Dependency ] comp ] -> CondTree v [Dependency ] comp
97
- mkCondNode comp branches = CondNode comp (view L. targetBuildDepends comp) branches
95
+ mkCondNode comp = CondNode comp (view L. targetBuildDepends comp)
98
96
99
97
node (CondNode comp _ branches) = mkCondNode
100
98
<$> L. buildInfo g comp
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ import Distribution.Types.BuildInfo
75
75
import Distribution.Types.ComponentName
76
76
( componentNameString )
77
77
import Distribution.Types.CondTree
78
- ( CondTree (.. ), traverseCondTreeC )
78
+ ( CondTree (.. ) )
79
79
import Distribution.Types.Dependency
80
80
( Dependency (.. ), mainLibSet )
81
81
import Distribution.Types.Library
@@ -338,7 +338,12 @@ addDepsToProjectTarget deps pkgId ctx =
338
338
| packageId pkg /= pkgId = SpecificSourcePackage pkg
339
339
| SourcePackage {.. } <- pkg =
340
340
SpecificSourcePackage $ pkg { srcpkgDescription =
341
- srcpkgDescription & (\ f -> L. allCondTrees $ traverseCondTreeC f)
341
+ -- New dependencies are added to the original ones found in the
342
+ -- `targetBuildDepends` field.
343
+ -- `traverseBuildInfos` is used in order to update _all_ the
344
+ -- occurrences of the field `targetBuildDepends`. It ensures that
345
+ -- fields depending on the latter are also consistently updated.
346
+ srcpkgDescription & (L. traverseBuildInfos . L. targetBuildDepends)
342
347
%~ (deps ++ )
343
348
}
344
349
addDeps spec = spec
Original file line number Diff line number Diff line change
1
+ module Foo where
2
+
3
+ a :: Int
4
+ a = 42
Original file line number Diff line number Diff line change
1
+ # cabal clean
2
+ # cabal repl
Original file line number Diff line number Diff line change
1
+ # cabal clean
2
+ # cabal repl
Original file line number Diff line number Diff line change
1
+ # cabal clean
2
+ # cabal repl
Original file line number Diff line number Diff line change
1
+ packages : .
Original file line number Diff line number Diff line change
1
+ import Test.Cabal.Prelude
2
+
3
+ -- Test “repl --build-depends”
4
+ main = do
5
+ testWithByteString " normal" []
6
+ -- See https://github.com/haskell/cabal/issues/6859
7
+ testWithByteString " allow-newer" [" --allow-newer" ]
8
+ -- See https://github.com/haskell/cabal/issues/6859
9
+ testWithByteString " allow-older" [" --allow-older" ]
10
+ where
11
+ testWithByteString label extraArgs = cabalTest' label $ do
12
+ cabal' " clean" []
13
+ res <- cabalWithStdin
14
+ " repl"
15
+ (" -v2" : " --build-depends" : " bytestring" : extraArgs)
16
+ " import qualified Data.ByteString as BS"
17
+ assertOutputContains " Ok, one module loaded." res
18
+ -- Ensure we can load ‘bytestring’
19
+ assertOutputDoesNotContain " Could not load" res
Original file line number Diff line number Diff line change
1
+ cabal-version : 2.4
2
+ name : pkg
3
+ version : 0.1.0.0
4
+ library
5
+ exposed-modules : Foo
6
+ build-depends : base
7
+ default-language : Haskell2010
Original file line number Diff line number Diff line change
1
+ synopsis: Fix repl discarding --build-depends
2
+ packages: cabal-install
3
+ prs: #8732
4
+ issues: #6859 #7081
5
+
6
+ description: {
7
+
8
+ - Fix `repl` command discarding `--build-depends` argument when using
9
+ `allow-newer` or `allow-older`.
10
+ }
You can’t perform that action at this time.
0 commit comments