Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hooking up a build tool in Cabal (Haskell)

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?

like image 381
user5803465 Avatar asked Oct 19 '22 10:10

user5803465


1 Answers

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)

like image 136
sinelaw Avatar answered Oct 21 '22 06:10

sinelaw