From eff7bf817bcbc1f0d0d1d801517a6e624edd9d0a Mon Sep 17 00:00:00 2001 From: PHO Date: Sun, 12 May 2024 13:03:31 +0900 Subject: [PATCH] Suppress ghc-pkg warnings emitted when an empty packages is being registered 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. --- Cabal/src/Distribution/Simple/Register.hs | 4 ++-- .../HaddockEmptyLib/empty/empty.cabal | 6 ++++++ .../PackageTests/HaddockEmptyLib/setup.cabal.out | 13 +++++++++++++ .../PackageTests/HaddockEmptyLib/setup.out | 13 +++++++++++++ .../PackageTests/HaddockEmptyLib/setup.test.hs | 6 ++++++ changelog.d/pr-9997 | 15 +++++++++++++++ 6 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 cabal-testsuite/PackageTests/HaddockEmptyLib/empty/empty.cabal create mode 100644 cabal-testsuite/PackageTests/HaddockEmptyLib/setup.cabal.out create mode 100644 cabal-testsuite/PackageTests/HaddockEmptyLib/setup.out create mode 100644 cabal-testsuite/PackageTests/HaddockEmptyLib/setup.test.hs create mode 100644 changelog.d/pr-9997 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. + +}