diff --git a/cabal-install/src/Distribution/Client/InLibrary.hs b/cabal-install/src/Distribution/Client/InLibrary.hs index af9c9f8e85a..c8fdebb70b8 100644 --- a/cabal-install/src/Distribution/Client/InLibrary.hs +++ b/cabal-install/src/Distribution/Client/InLibrary.hs @@ -20,6 +20,7 @@ where import Distribution.Client.Compat.Prelude import Prelude () +import Distribution.Backpack.DescribeUnitId (setupMessage') import Distribution.Client.ProjectPlanning.Types import Distribution.Client.RebuildMonad import qualified Distribution.Client.SetupHooks.CallHooksExe as ExternalHooksExe @@ -136,6 +137,17 @@ configure confHooks = configureHooks $ ExternalHooksExe.buildTypeSetupHooks mbWorkDir distPref bt -- Configure package + let pkgId :: PD.PackageIdentifier + pkgId = PD.package pkgDesc + case mbComp of + Nothing -> setupMessage verbosity "Configuring" pkgId + Just cname -> + setupMessage' + verbosity + "Configuring" + pkgId + cname + (Just (Cabal.configInstantiateWith cfg)) -- SetupHooks TODO: we should avoid re-doing package-wide things -- over and over in the per-component world, e.g. diff --git a/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/SetupHooksRecompilation.cabal b/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/SetupHooksRecompilation.cabal index 23ff1b751bc..f469abdb9e2 100644 --- a/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/SetupHooksRecompilation.cabal +++ b/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/SetupHooksRecompilation.cabal @@ -12,6 +12,6 @@ custom-setup library exposed-modules: MyLib - build-depends: base ^>=4.19.1.0 + build-depends: base >= 4.12 && < 5.0 hs-source-dirs: src default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/cabal.test.hs b/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/cabal.test.hs index b6fb7f87fb9..cdd493d40fa 100644 --- a/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/cabal.test.hs +++ b/cabal-testsuite/PackageTests/SetupHooks/SetupHooksRecompilation/cabal.test.hs @@ -1,11 +1,17 @@ import Test.Cabal.Prelude +import System.Directory ( doesFileExist ) + main = cabalTest $ do - mpkgdb <- testPackageDbPath <$> getTestEnv - case mpkgdb of + env <- getTestEnv + case testPackageDbPath env of Nothing -> skip "Cabal-hooks library unavailable." Just pkgdb -> recordMode DoNotRecord $ do cabal "build" [ "--package-db=" ++ pkgdb ] - liftIO $ appendFile "SetupHooks.hs" "definitely-wrong!" + let setupHooksPath = testCurrentDir env "SetupHooks.hs" + setupHooksExists <- liftIO $ doesFileExist setupHooksPath + unless setupHooksExists $ + error "Broken test: tried to write to a SetupHooks.hs file that doesn't exist." + liftIO $ appendFile setupHooksPath "this should fail to compile!" -- If this doesn't fail, it's because we didn't re-build. fails $ cabal "build" [ "--package-db=" ++ pkgdb ] diff --git a/cabal-testsuite/main/cabal-tests.hs b/cabal-testsuite/main/cabal-tests.hs index c3d167e3b8c..98b02f4eed3 100644 --- a/cabal-testsuite/main/cabal-tests.hs +++ b/cabal-testsuite/main/cabal-tests.hs @@ -142,7 +142,7 @@ buildCabalLibsProject projString verb mbGhc dir = do , "--project-file=" ++ dir "cabal.project-test" , "build" , "-w", programPath ghc - , "Cabal", "Cabal-syntax", "Cabal-hooks" + , "Cabal", "Cabal-syntax", "Cabal-hooks", "hooks-exe" ] ) { progInvokeCwd = Just dir }) return final_package_db @@ -169,7 +169,8 @@ buildCabalLibsSpecific ver verb mbGhc builddir_rel = do buildCabalLibsIntree :: String -> Verbosity -> Maybe FilePath -> FilePath -> IO FilePath buildCabalLibsIntree root verb mbGhc builddir_rel = do dir <- canonicalizePath (builddir_rel "intree") - buildCabalLibsProject ("packages: " ++ root "Cabal" ++ " " ++ root "Cabal-syntax" ++ " " ++ root "Cabal-hooks") verb mbGhc dir + let libs = [ "Cabal", "Cabal-syntax", "Cabal-hooks", "hooks-exe", "../process" ] + buildCabalLibsProject ("packages: " ++ unwords ( map ( root ) libs ) ) verb mbGhc dir main :: IO () main = do