Changelog for Cabal-hooks-3.18
Changelog for Cabal-hooks
3.18.1.0 — July 2026
-
Stop exposing constructors of
RuleCommands#11461 #11771The constructors of the
SetupHooksRuleCommandsare no longer exposed fromDistribution.Simple.SetupHooks. These were rather gnarly internal constructors; the intended public API is viastaticRuleanddynamicRule. -
Make Cabal-hooks library more self-sufficient #11772
The
Distribution.Simple.SetupHooksmodule fromCabal-hooksnow re-exports a lot of the functionality that is commonly needed when writingSetupHooks:- File-path related functionality from
Distribution.Utils.Path. - Functionality related to the program database:
lookupProgram,runProgramCwd. - IO utilities such as
warn,createDirectoryIfMissingVerbose, andrewriteFileEx. - Various types frequently used in pre-build rules, such as
Binary,ModuleName. - Functions that extract information from
LocalBuildInfosuch aslocalPkgDescr,mbWorkDirLBI,withPrograms,interpretSymbolicPathLBIandcomponentBuildInfo.
In addition, new file monitoring helper functions
findAndMonitorDirFileGlobandfindAndMonitorSourceDirsFileExtshave been added. These make it very simple and convenient to search for a file glob or files with a particular extension in the source directories, for pre-build rules. - File-path related functionality from
-
Recompilation checking for SetupHooks pre-build rules #11730 #11731
Pre-build rules are now only re-run when stale, according to the conditions described in the SetupHooks API. That is, a rule is re-run if any of the following conditions are satisfied:
- The rule is new, or
- A dependency of the rule is stale. That is, either we have re-run another rule that this rule depends on, or one of the file inputs to the rule is newer than the oldest output of the rule (or the rule output doesn't exist at all), or
- The rule itself has changed, e.g. the parameters stored in
RuleDatahave changed.
In particular, Cabal will now write per-component caches of pre-build rules in order to compute which rules have changed between runs, with file name "setup-hooks-rules.cache".
-
Pre-build rules can generate extra sources and bundled libraries #10791 #11607 #11573
It is now possible to write pre-build rules that generate source files other than Haskell files, as well as extra bundled library files.
Because there is no counterpart to
autogen-modulesfor non-Haskell source files, you will need to proceed in two steps:-
In a per-component pre-configure hook, add the files you want to generate to the relevant fields, e.g. the
cSourcesfield ofBuildInfofor a C source file.These files must be relative to
autogenCompModulesDir. -
Pre-build rules generating these files will now be demanded. This avoids getting an error message "The following pre-build rules are not demanded and will not be run".
Note that include files (such as
.hfiles) are a bit different: any files listed underincludes/autogen-includesare required at configure time. This givesSetupHooksauthors two choices: either list the include files inautogen-includesbut generate them in a pre-configure hook, or don't list them there and generate them in a pre-build rule, relying on the files getting picked up from included directories (this may be brittle). -
-
Fixed binary format mismatch resulting in
runRuleDynDepsCmdbuild error #12053 #12054A build containing a
dynamicRulewould fail with the following error:Error: [Cabal-7125] Failed to build hooks-0.1.0.0. The exception was: Missing ByteString argument in 'ruleExecCmd'. Run 'runRuleDynDepsCmd' on the rule to obtain this data.This was caused by a mismatch between the binary formats used to encode and decode the rules. The hook produced a result of type
([Dependency], LBS.ByteString), which was then encoded into aBinaryblob. However,hooks-exedecoded this data asMaybe ([Dependency], LBS.ByteString), causing the build error.
3.16.1 – December 2025
- No changes
3.16.0 – July 2025
- No changes
3.14.2 – April 2025
- No changes
3.14 – November 2024
- Initial release of the
HooksAPI.