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
  • Loading branch information
fgaz authored Jul 24, 2023
1 parent 667be46 commit 4aa5f88
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
7 changes: 1 addition & 6 deletions Cabal/src/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,18 +1352,13 @@ checkFields 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 4aa5f88

Please sign in to comment.