Skip to content

Commit f47e7f4

Browse files
authored
Merge pull request #11351 from ffaf1/check-setup
Recognise SetupHooks.hs
2 parents 69f6bd4 + e71de2b commit f47e7f4

9 files changed

Lines changed: 53 additions & 4 deletions

File tree

Cabal/src/Distribution/PackageDescription/Check.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,9 @@ checkSetupExists _ =
833833
( \ops -> do
834834
ba <- doesFileExist ops "Setup.hs"
835835
bb <- doesFileExist ops "Setup.lhs"
836-
return (not $ ba || bb)
836+
bc <- doesFileExist ops "SetupHooks.hs"
837+
bd <- doesFileExist ops "SetupHooks.lhs"
838+
return (not $ ba || bb || bc || bd)
837839
)
838840
(PackageDistInexcusable MissingSetupFile)
839841

Cabal/src/Distribution/PackageDescription/Check/Warning.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,8 @@ ppExplanation (UnknownFile fieldname file) =
14631463
++ quote (getSymbolicPath file)
14641464
++ " which does not exist."
14651465
ppExplanation MissingSetupFile =
1466-
"The package is missing a Setup.hs or Setup.lhs script."
1466+
"The package is missing a Setup.hs or Setup.lhs or SetupHooks.hs "
1467+
++ "or SetupHooks.lhs script."
14671468
ppExplanation MissingConfigureScript =
14681469
"The 'build-type' is 'Configure' but there is no 'configure' script. "
14691470
++ "You probably need to run 'autoreconf -i' to generate it."
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# cabal check
22
The following errors will cause portability problems on other environments:
3-
Error: [missing-setup] The package is missing a Setup.hs or Setup.lhs script.
3+
Error: [missing-setup] The package is missing a Setup.hs or Setup.lhs or
4+
SetupHooks.hs or SetupHooks.lhs script.
45
Error: Hackage would reject this package.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module SetupHooks where
2+
3+
import Distribution.Simple.SetupHooks ( SetupHooks, noSetupHooks )
4+
5+
setupHooks :: SetupHooks
6+
setupHooks = noSetupHooks
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- SetupHooks.hs is a valid setup script.
4+
main = cabalTest $
5+
cabal "check" []
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cabal-version: 3.14
2+
name: pkg
3+
version: 0.1.0.0
4+
synopsis: pkg
5+
description: pkg description
6+
license: GPL-3.0-or-later
7+
author: Joris Dral
8+
maintainer: joris@well-typed.com
9+
build-type: Hooks
10+
category: Data
11+
12+
common warnings
13+
ghc-options: -Wall
14+
15+
library
16+
import: warnings
17+
exposed-modules: MyLib
18+
build-depends: base ^>=4.18.3.0
19+
default-language: Haskell2010
20+
21+
custom-setup
22+
setup-depends:
23+
Cabal-hooks >=3.14 && <3.17,
24+
base >=4.18 && <5

changelog.d/pr-11351

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
synopsis: Recognise SetupHooks.hs
3+
packages: [cabal-install]
4+
prs: 11351
5+
issues: 11349
6+
---
7+
8+
`cabal check` now recogsnises `SetupHooks.hs` as a valid setup script.

doc/cabal-commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ A list of all warnings with their constructor:
15211521
- ``no-cabal-file``: no ``.cabal`` file found in folder.
15221522
- ``multiple-cabal-file``: multiple ``.cabal`` files found in folder.
15231523
- ``unknown-file``: path refers to a file which does not exist.
1524-
- ``missing-setup``: missing ``Setup.hs`` or ``Setup.lsh``.
1524+
- ``missing-setup``: missing ``Setup.hs`` or ``Setup.lhs`` or ``SetupHooks.hs`` or ``SetupHooks.lhs``.
15251525
- ``missing-conf-script``: missing ``configure`` script with ``build-type: Configure``.
15261526
- ``unknown-directory``: paths refer to a directory which does not exist.
15271527
- ``no-repository``: missing ``source-repository`` section.

0 commit comments

Comments
 (0)