diff --git a/Cabal/src/Distribution/Simple/Register.hs b/Cabal/src/Distribution/Simple/Register.hs index 76e7528a6c2..0bd7312cbc4 100644 --- a/Cabal/src/Distribution/Simple/Register.hs +++ b/Cabal/src/Distribution/Simple/Register.hs @@ -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 } diff --git a/cabal-testsuite/PackageTests/HaddockEmptyLib/empty/empty.cabal b/cabal-testsuite/PackageTests/HaddockEmptyLib/empty/empty.cabal new file mode 100644 index 00000000000..e848e5ab2d6 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockEmptyLib/empty/empty.cabal @@ -0,0 +1,6 @@ +name: emptyLib +Cabal-version: >= 1.2 +version: 1.0 +build-type: Simple + +Library diff --git a/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.cabal.out b/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.cabal.out new file mode 100644 index 00000000000..90a9995cfb2 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.cabal.out @@ -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 +# Setup register +Registering library for emptyLib-1.0... diff --git a/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.out b/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.out new file mode 100644 index 00000000000..90a9995cfb2 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.out @@ -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 +# Setup register +Registering library for emptyLib-1.0... diff --git a/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.test.hs b/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.test.hs new file mode 100644 index 00000000000..c91d5216275 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockEmptyLib/setup.test.hs @@ -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 [] diff --git a/changelog.d/pr-9997 b/changelog.d/pr-9997 new file mode 100644 index 00000000000..592e29c0963 --- /dev/null +++ b/changelog.d/pr-9997 @@ -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. + +}