Skip to content

Commit

Permalink
Fix recompilation of SetupHooks file
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-romes committed Apr 18, 2024
1 parent caab57b commit 96b06ad
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ buildInplaceUnpackedPackage
if null xs then m' else return xs
monitors <- case PD.buildType (elabPkgDescription pkg) of
Simple -> listSimple
Hooks -> listSimple
Hooks -> listSdist `ifNullThen` listSimple
-- If a Custom setup was used, AND the Cabal is recent
-- enough to have sdist --list-sources, use that to
-- determine the files that we need to track. This can
Expand Down
5 changes: 4 additions & 1 deletion cabal-install/src/Distribution/Client/SourceFiles.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ needComponent pkg_descr comp =
CBench bench -> needBenchmark pkg_descr bench

needSetup :: Rebuild ()
needSetup = findFirstFileMonitored id ["Setup.hs", "Setup.lhs"] >> return ()
needSetup = do
findFirstFileMonitored id ["Setup.hs", "Setup.lhs"]
findFirstFileMonitored id ["SetupHooks.hs", "SetupHooks.lhs"]
return ()

needLibrary :: PackageDescription -> Library -> Rebuild ()
needLibrary
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module SetupHooks where

import Distribution.Simple.SetupHooks

setupHooks = noSetupHooks

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: 3.14
name: SetupHooksRecompilation
version: 0.1.0.0
license: NONE
author: Rodrigo Mesquita
maintainer: [email protected]
build-type: Hooks
extra-doc-files: CHANGELOG.md

custom-setup
setup-depends: base, Cabal, Cabal-syntax, Cabal-hooks, hooks-exe

library
exposed-modules: MyLib
build-depends: base ^>=4.19.1.0
hs-source-dirs: src
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
packages:
.
~/ghc-dev/cabal-help-sam/Cabal-hooks/
~/ghc-dev/cabal-help-sam/Cabal-syntax/
~/ghc-dev/cabal-help-sam/Cabal/
~/ghc-dev/cabal-help-sam/hooks-exe/

source-repository-package
type: git
location: https://github.com/sheaf/process
tag: 161bd84f8cc9367011465eb0ec420e74e01e9d74
post-checkout-command: autoreconf -i

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Test.Cabal.Prelude

main = cabalTest $ do
recordMode DoNotRecord $ do
cabal "build" []
liftIO $ appendFile "SetupHooks.hs" "definitely-wrong!"
-- If this doesn't fail, it's because we didn't re-build.
fails $ cabal "build" []

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"

0 comments on commit 96b06ad

Please sign in to comment.