From 44e2b284e1d16f01cd46483d62650e59bdaf8b9b Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Fri, 12 Jan 2024 18:27:15 +0000 Subject: [PATCH] Account for .buildinfo in repl when build-type: Configure (#9440) In `autoconfUserHooks` we were not updating the `preRepl` hook to read additional build information from /package/@.buildinfo@. Additionally updates `autoconfUserHooks` to read additional build info information for the remaining pre-hooks that are not pre-conf. Fixes #9401 (cherry picked from commit ee1e6b81cbbe30da42e5d3027536c7030af03ef5) # Conflicts: # Cabal/src/Distribution/Simple.hs --- Cabal/src/Distribution/Simple.hs | 43 ++++++++++++++++++++++++++++++-- changelog.d/issue-9401 | 11 ++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 changelog.d/issue-9401 diff --git a/Cabal/src/Distribution/Simple.hs b/Cabal/src/Distribution/Simple.hs index 77ba089fa98..4b4e12a7f69 100644 --- a/Cabal/src/Distribution/Simple.hs +++ b/Cabal/src/Distribution/Simple.hs @@ -576,14 +576,14 @@ simpleUserHooks = -- -- * 'postConf' runs @.\/configure@, if present. -- --- * the pre-hooks 'preBuild', 'preClean', 'preCopy', 'preInst', --- 'preReg' and 'preUnreg' read additional build information from +-- * the pre-hooks, except for pre-conf, read additional build information from -- /package/@.buildinfo@, if present. -- -- Thus @configure@ can use local system information to generate -- /package/@.buildinfo@ and possibly other files. autoconfUserHooks :: UserHooks +<<<<<<< HEAD autoconfUserHooks = simpleUserHooks { @@ -608,6 +608,45 @@ autoconfUserHooks then runConfigureScript verbosity flags lbi else die' verbosity "configure script not found." +======= +autoconfUserHooks = + simpleUserHooks + { postConf = defaultPostConf + , preBuild = readHookWithArgs buildVerbosity buildDistPref + , preRepl = readHookWithArgs replVerbosity replDistPref + , preCopy = readHookWithArgs copyVerbosity copyDistPref + , preClean = readHook cleanVerbosity cleanDistPref + , preInst = readHook installVerbosity installDistPref + , preHscolour = readHook hscolourVerbosity hscolourDistPref + , preHaddock = readHookWithArgs haddockVerbosity haddockDistPref + , preReg = readHook regVerbosity regDistPref + , preUnreg = readHook regVerbosity regDistPref + , preTest = readHookWithArgs testVerbosity testDistPref + , preBench = readHookWithArgs benchmarkVerbosity benchmarkDistPref + } + where + defaultPostConf + :: Args + -> ConfigFlags + -> PackageDescription + -> LocalBuildInfo + -> IO () + defaultPostConf args flags pkg_descr lbi = + do + let verbosity = fromFlag (configVerbosity flags) + baseDir lbi' = + fromMaybe + "" + (takeDirectory <$> cabalFilePath lbi') + confExists <- doesFileExist $ (baseDir lbi) "configure" + if confExists + then + runConfigureScript + verbosity + flags + lbi + else dieWithException verbosity ConfigureScriptNotFound +>>>>>>> ee1e6b81c (Account for .buildinfo in repl when build-type: Configure (#9440)) pbi <- getHookedBuildInfo verbosity (buildDir lbi) sanityCheckHookedBuildInfo verbosity pkg_descr pbi diff --git a/changelog.d/issue-9401 b/changelog.d/issue-9401 new file mode 100644 index 00000000000..40487976543 --- /dev/null +++ b/changelog.d/issue-9401 @@ -0,0 +1,11 @@ +synopsis: Account for .buildinfo in repl, test, and bench +packages: Cabal +prs: #9440 +issues: #9401 + +description: { + +Generated .buildinfo is now respected in cabal repl, cabal test and cabal bench. + +} +