Skip to content

Commit e80632a

Browse files
mergify[bot]TeofilCulysses4ever
authored
Downgrade NoLibraryFound from an error to a warning (backport #9926) (#10076)
* Downgrade NoLibraryFound from an error to a warning This makes Setup copy/install succeed if there's nothing to do because the package doesn't contain a library or executable. This allows downstream users of Cabal to avoid having to add workarounds for this edge case. Resolves #6750 (cherry picked from commit 312a412) # Conflicts: # Cabal/src/Distribution/Simple/Install.hs * fixup! fix conflicts --------- Co-authored-by: Teo Camarasu <[email protected]> Co-authored-by: Artem Pelenitsyn <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 639928f commit e80632a

File tree

8 files changed

+53
-2
lines changed

8 files changed

+53
-2
lines changed

Cabal/src/Distribution/Simple/Errors.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ data CabalException
4848
| EnableBenchMark
4949
| BenchMarkNameDisabled String
5050
| NoBenchMark String
51-
| NoLibraryFound
51+
| -- | @NoLibraryFound@ has been downgraded to a warning, and is therefore no longer emitted.
52+
NoLibraryFound
5253
| CompilerNotInstalled CompilerFlavor
5354
| CantFindIncludeFile String
5455
| UnsupportedTestSuite String

Cabal/src/Distribution/Simple/Install.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ install pkg_descr lbi flags = do
114114

115115
checkHasLibsOrExes =
116116
unless (hasLibs pkg_descr || hasForeignLibs pkg_descr || hasExes pkg_descr) $
117-
dieWithException verbosity NoLibraryFound
117+
warn verbosity "No executables and no library found. Nothing to do."
118118

119119
-- | Copy package global files.
120120
copyPackage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cabal-version: 3.0
2+
name: OnlyTestSuite
3+
version: 0.1.0.0
4+
build-type: Simple
5+
6+
common warnings
7+
ghc-options: -Wall
8+
9+
test-suite OnlyTestSuite-test
10+
import: warnings
11+
default-language: Haskell2010
12+
type: exitcode-stdio-1.0
13+
hs-source-dirs: test
14+
main-is: Main.hs
15+
build-depends: base
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Setup configure
2+
Configuring OnlyTestSuite-0.1.0.0...
3+
# Setup build
4+
Building OnlyTestSuite-0.1.0.0...
5+
# Setup copy
6+
Warning: No executables and no library found. Nothing to do.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Setup configure
2+
Configuring OnlyTestSuite-0.1.0.0...
3+
# Setup build
4+
Building OnlyTestSuite-0.1.0.0...
5+
# Setup copy
6+
Warning: No executables and no library found. Nothing to do.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Test.Cabal.Prelude
2+
main = setupAndCabalTest $ do
3+
withPackageDb $ do
4+
setup "configure" []
5+
setup "build" []
6+
setup "copy" []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main (main) where
2+
3+
main :: IO ()
4+
main = putStrLn "Test suite not yet implemented."

changelog.d/issue-6750

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
synopsis: Make Setup copy/install succeed when there's no executable or library
2+
packages: Cabal
3+
prs: #9926
4+
issues: #6750
5+
6+
description: {
7+
Historically the Setup copy and install steps would fail if the package didn't
8+
contain an executable or library component. In this case there's nothing to do.
9+
10+
This required workarounds for downstream users of Cabal to handle this edge case.
11+
Now that this error has been downgraded to a warning, Cabal will succeed if
12+
there's nothing to do.
13+
}

0 commit comments

Comments
 (0)