Skip to content

Commit

Permalink
Suppress ghc-pkg warnings emitted when an empty packages is being reg…
Browse files Browse the repository at this point in the history
…istered

When a package contains a library that has no modules, "./Setup register"
tries to register the library with fields "haddock-interfaces:" and
"haddock-html:" pointing at non-existent files or directories, and "ghc-pkg
register" warns about them.

To suppress the warnings prevent these fields from being generated when
there are no modules.
  • Loading branch information
depressed-pho committed Jan 9, 2025
1 parent 04db7d0 commit eff7bf8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cabal/src/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
, IPI.ldOptions = ldOptions bi
, IPI.frameworks = map getSymbolicPath $ frameworks bi
, IPI.frameworkDirs = map getSymbolicPath $ extraFrameworkDirs bi
, IPI.haddockInterfaces = [haddockdir installDirs </> haddockLibraryPath pkg lib]
, IPI.haddockHTMLs = [htmldir installDirs]
, IPI.haddockInterfaces = [haddockdir installDirs </> haddockLibraryPath pkg lib | hasModules]
, IPI.haddockHTMLs = [htmldir installDirs | hasModules]
, IPI.pkgRoot = Nothing
, IPI.libVisibility = libVisibility lib
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: emptyLib
Cabal-version: >= 1.2
version: 1.0
build-type: Simple

Library
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/HaddockEmptyLib/setup.cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Setup configure
Configuring emptyLib-1.0...
# Setup build
Preprocessing library for emptyLib-1.0...
Building library for emptyLib-1.0...
# Setup haddock
Preprocessing library for emptyLib-1.0...
Running Haddock on library for emptyLib-1.0...
Warning: Haddocks are being requested, but there aren't any modules given to create documentation for.
# Setup copy
Installing library in <PATH>
# Setup register
Registering library for emptyLib-1.0...
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/HaddockEmptyLib/setup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Setup configure
Configuring emptyLib-1.0...
# Setup build
Preprocessing library for emptyLib-1.0...
Building library for emptyLib-1.0...
# Setup haddock
Preprocessing library for emptyLib-1.0...
Running Haddock on library for emptyLib-1.0...
Warning: Haddocks are being requested, but there aren't any modules given to create documentation for.
# Setup copy
Installing library in <PATH>
# Setup register
Registering library for emptyLib-1.0...
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/HaddockEmptyLib/setup.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude
-- Test install when the library is empty, for #9997
main = setupAndCabalTest $
withPackageDb $
withDirectory "empty" $
setup_install_with_docs []
15 changes: 15 additions & 0 deletions changelog.d/pr-9997
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
synopsis: Suppress ghc-pkg warnings emitted when an empty packages is being registered
packages: Cabal
prs: #9997

description: {

When a package contains a library that has no modules, `./Setup register`
tries to register the library with fields `haddock-interfaces:` and
`haddock-html:` pointing at non-existent files or directories, and `ghc-pkg
register` warns about them.

To suppress the warnings prevent these fields from being generated when
there are no modules.

}

0 comments on commit eff7bf8

Please sign in to comment.