cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Componentwise hooks

Open gergoerdi opened this issue 4 years ago • 4 comments

I have a use case for running some random IO action just before each component is built. It is important that my action is run interleaved with the build itself, since the IO action for a component may require the build artifacts of other components that are earlier in the dependency list. The IO action returns an edited BuildInfo, which is then passed to the normal build hook.

I have a prototype implementation at https://github.com/gergoerdi/clashilator/blob/c2561e8465ba235aa4836e3bfae35f84fa578d26/src/Clash/Clashilator/Cabal.hs. I'm not too happy with how deeply it has to fiddle with Cabal internals, so it would be better if this, or something similar to this, was exposed via the Cabal API.

gergoerdi avatar Apr 06 '21 10:04 gergoerdi

Similar to #2910

mpickering avatar Sep 08 '23 15:09 mpickering

I believe this is now possible with a per-component pre-build hook, using build-type: Hooks.

sheaf avatar May 08 '24 08:05 sheaf

I believe this is now possible with a per-component pre-build hook, using build-type: Hooks.

Is there documentation for this new build type somewhere?

gergoerdi avatar May 08 '24 10:05 gergoerdi

I believe this is now possible with a per-component pre-build hook, using build-type: Hooks.

Is there documentation for this new build type somewhere?

It's going to be included in the next Cabal release, 3.14. The documentation is here, but some links won't work due to the fact that the Cabal-hooks package has not yet been uploaded to Hackage. Unfortunately it's the Haddocks for that package that contain the most detailed information.

For the time being, I would suggest reading the HF tech proposal. (I'm updating the link in a separate PR as it is currently wrong in the documentation, I realise.)

sheaf avatar May 08 '24 10:05 sheaf