GTF
GTF

Reputation: 8385

Is there a way to get `cabal` to detect changes to non-Haskell source files?

I'm using template haskell to include content from non-Haskell files in some of my code, and this content is then parsed and used. The problem that I have with using cabal as a build tool for this is that it doesn't detect when these files changes and so I find myself using cabal clean; cabal build which forces the whole project to be rebuilt (including some dependencies) which is slower than it could otherwise be.

Upvotes: 2

Views: 72

Answers (2)

GTF
GTF

Reputation: 8385

I used the extra-source-files configuration in my .cabal file to get this to work rather than Language.Haskell.TH.Syntax.addDependentFile as it was sufficient for my use case, so the extra configuration looks like this:

extra-source-files:
  src/GTF/Pages/**/*.djot

The wildcard syntax is a bit limited, but for this use-case it is sufficient.

Using addDependentFile would have required me to add a bit more code as my file-loading function does not know it is being used in TH.

Upvotes: 3

Daniel Wagner
Daniel Wagner

Reputation: 152682

Call Language.Haskell.TH.Syntax.addDependentFile, then wait for this cabal issue to get fixed.

As a workaround, you can add a comment to some relevant Haskell source file(s) to get them to rebuild (and re-execute their TH). Don't forget to delete it again next build and certainly before you check your source in!

Upvotes: 4

Related Questions