Skip to content

Commit

Permalink
PD check: do not treat library names as package names (#9132)
Browse files Browse the repository at this point in the history
Fixes #9122

(cherry picked from commit 4aa5f88)
  • Loading branch information
fgaz committed Sep 5, 2023
1 parent 529f850 commit d899e53
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 5 deletions.
6 changes: 1 addition & 5 deletions Cabal/src/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,17 +1210,13 @@ checkFields pkg =
| (compiler, vr) <- testedWith pkg
, isNoVersion vr ]

internalLibraries =
map (maybe (packageName pkg) unqualComponentNameToPackageName . libraryNameString . libName)
(allLibraries pkg)

internalExecutables = map exeName $ executables pkg

internalLibDeps =
[ dep
| bi <- allBuildInfo pkg
, dep@(Dependency name _ _) <- targetBuildDepends bi
, name `elem` internalLibraries
, name == packageName pkg
]

internalExeDeps =
Expand Down
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/p/p.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cabal-version: 3.4
name: p
Version: 2
Build-Type: Simple

library
10 changes: 10 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/q/q.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: 3.4
name: q
Version: 1
Build-Type: Simple

library
build-depends: q:p

library p
build-depends: p:p == 2
11 changes: 11 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/setup.cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Setup configure
Configuring p-2...
# Setup build
Preprocessing library for p-2...
Building library for p-2...
# Setup copy
Installing library in <PATH>
# Setup register
Registering library for p-2...
# Setup configure
Configuring q-1...
11 changes: 11 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/setup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Setup configure
Configuring p-2...
# Setup build
Preprocessing library for p-2...
Building library for p-2...
# Setup copy
Installing library in <PATH>
# Setup register
Registering library for p-2...
# Setup configure
Configuring q-1...
5 changes: 5 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T9122/setup.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Test.Cabal.Prelude

main = setupAndCabalTest $ withPackageDb $ do
withDirectory "p" $ setup_install []
withDirectory "q" $ setup "configure" []
4 changes: 4 additions & 0 deletions changelog.d/issue-9122
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
synopsis: Fix dependency on an external package when an internal library with the same name exists
packages: Cabal
issues: #9122
prs: #9132

0 comments on commit d899e53

Please sign in to comment.