Hooking up a build tool in Cabal (Haskell)

319 Views Asked by At

I was trying to use bnfc tool to generate a bunch of files, like lexer, parser, etc. for me. This works fine. Now I wanted to clean this up a bit by not having to manually compile the bnfc file and having it generate a number of files which clutter my /src folder.

I tried the Cabal mechanism where you list the tool in build-tools field of the .cabal file and mention the files you expect to be generated by extra-source-files field. This worked for me for Alex and Happy as they are recognised as build-tools by Cabal but bnfc isn't. Is there a way I can hook up bnfc or any tool in general with Cabal and have Cabal recognise them as build-tools?

1

There are 1 best solutions below

0
On

Apparently cabal doesn't know about bnfc (doesn't appear on the list).

Looks like there's no way to do it using just the .cabal file, but there's an example of how to hook up a preprocessor in your Setup.hs in the cabal sources under tests/PackageTests/CustomPreProcess/Setup.hs using the user hook hookedPreProcessors (all hooks are in UserHooks.hs)