Skip to content

Commit

Permalink
Merge pull request #6896 from phadej/issue-6894-fix
Browse files Browse the repository at this point in the history
Fix #6894: circularity check
  • Loading branch information
phadej authored Jun 12, 2020
2 parents 1d18662 + fb9bb5c commit 722e4cf
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 deletions.
25 changes: 19 additions & 6 deletions Cabal/Distribution/Backpack/ComponentsGraph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,25 @@ mkComponentsGraph enabled pkg_descr =
componentDeps component =
(CExeName <$> getAllInternalToolDependencies pkg_descr bi)

++ [ if pkgname == packageName pkg_descr
then CLibName LMainLibName
else CLibName (LSubLibName toolname)
| Dependency pkgname _ _ <- targetBuildDepends bi
, let toolname = packageNameToUnqualComponentName pkgname
, toolname `elem` internalPkgDeps ]
++ do
Dependency pkgname _ lns <- targetBuildDepends bi
let uqn = packageNameToUnqualComponentName pkgname
guard (uqn `elem` internalPkgDeps)
ln <- toList lns

-- given package "pkg" with "sublib" library:
case ln of
LMainLibName
-- build-depends: pkg
| pkgname == packageName pkg_descr -> return (CLibName LMainLibName)
-- build-depends: sublib
| otherwise -> return (CLibName (LSubLibName uqn))
LSubLibName uqn'
-- build-depends: pkg:sublib
| pkgname == packageName pkg_descr
, uqn' `elem` internalPkgDeps -> return (CLibName (LSubLibName uqn'))
-- build-depends: sublib:something else
| otherwise -> []
where
bi = componentBuildInfo component
internalPkgDeps = map (conv . libName) (allLibraries pkg_descr)
Expand Down
16 changes: 13 additions & 3 deletions cabal-testsuite/PackageTests/MultipleLibraries/T6894/cabal.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# cabal v2-build
Resolving dependencies...
Error:
Dependency cycle between the following components: library
In the inplace package 'issue-6894'
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- issue-6894 (lib:sublib) (first run)
- issue-6894 (lib) (first run)
Warning: issue.cabal:7:30: colon specifier is experimental feature (issue #5660)
Configuring library 'sublib' for issue-6894..
Preprocessing library 'sublib' for issue-6894..
Building library 'sublib' for issue-6894..
Warning: issue.cabal:7:30: colon specifier is experimental feature (issue #5660)
Configuring library for issue-6894..
Warning: The package has an extraneous version range for a dependency on an internal library: issue:{sublib} >=0 && ==6894. This version range includes the current package but isn't needed as the current package's library will always be used.
Preprocessing library for issue-6894..
Building library for issue-6894..
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Test.Cabal.Prelude
main = cabalTest $
fails $ cabal "v2-build" ["issue"]
cabal "v2-build" ["issue"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Setup configure
Warning: issue.cabal:7:30: colon specifier is experimental feature (issue #5660)
Configuring issue-6894...
Error:
Components in the package issue-6894 depend on each other in a cyclic way:
'library' depends on 'library'
# Setup build
Preprocessing library 'sublib' for issue-6894..
Building library 'sublib' for issue-6894..
Preprocessing library for issue-6894..
Building library for issue-6894..
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Setup configure
Warning: issue.cabal:7:30: colon specifier is experimental feature (issue #5660)
Configuring issue-6894...
Error:
Components in the package issue-6894 depend on each other in a cyclic way:
'library' depends on 'library'
# Setup build
Preprocessing library 'sublib' for issue-6894..
Building library 'sublib' for issue-6894..
Preprocessing library for issue-6894..
Building library for issue-6894..
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Test.Cabal.Prelude
main = setupAndCabalTest $ do
fails $ setup_build []
setup_build []

0 comments on commit 722e4cf

Please sign in to comment.