You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say, that we have a preprocessor that can translate files with the .foo extension. If you declare some module in your exposed-modules (f.e. Test.Module), then Cabal will look for the file named Test.Module.foo and run the preprocessor for it. It is one-to-one correspondence.
Now, we have Apache Thrift. The preprocessor can parse Thrift DSL and generate protocols and RPC servers/clients. But, it will translate single Module.thrift file in many others: Module_Types.hs, Module_Consts.hs, RPCPoint_Iface.hs, RPCPoint_Client.hs. The first two files correspond to the source file, while the rest correspond to a single RPCPoint service inside the Module.thrift. There can be other interface/client files, if you declare more services in the Module.thrift.
So, here is a problem: Cabal finds Test.Module in exposed-modules sections, finds Test/Module.thrift among source files and thinks that's it, but after the preprocessing stage, there is no Module.hs among the build files. On the other hand, if you declare Module_Types/Module_Consts and others in your exposed-modules section, that Cabal will ignore Module.thrift source file.
What I did in my project:
I've placed the single pattern thrift/*.thrift in the extra-source-files field.
I've written custom Setup.hs file with overloaded buildHook/testHook. Before running the default hook, they will call the thrift preprocessor for every file matching the pattern in extraSrcFiles with the destination buildDir.
This approach works, but I don't like it:
Files specific for the build are listed in a global parameter.
Part of preprocessing stage is placed in the buildHook. Also, I have duplicated code in the testHook (and I would have it in the benchHook, if I needed to).
There are other preprocessors with similar problems.
I suggest to remove pattern matching on preprocessor stage at all. I think, time savings in case of dropping unnecessary files doesn't make a difference.
Uh oh!
There was an error while loading. Please reload this page.
Hey, Cabal team.
Some time ago, I had to integrate Apache Thrift in one of my projects. But, I faced issues with HookedPreprocessors.
Let's say, that we have a preprocessor that can translate files with the
.foo
extension. If you declare some module in yourexposed-modules
(f.e. Test.Module), then Cabal will look for the file namedTest.Module.foo
and run the preprocessor for it. It is one-to-one correspondence.Now, we have Apache Thrift. The preprocessor can parse Thrift DSL and generate protocols and RPC servers/clients. But, it will translate single
Module.thrift
file in many others:Module_Types.hs
,Module_Consts.hs
,RPCPoint_Iface.hs
,RPCPoint_Client.hs
. The first two files correspond to the source file, while the rest correspond to a single RPCPoint service inside theModule.thrift
. There can be other interface/client files, if you declare more services in theModule.thrift
.So, here is a problem: Cabal finds
Test.Module
in exposed-modules sections, findsTest/Module.thrift
among source files and thinks that's it, but after the preprocessing stage, there is noModule.hs
among the build files. On the other hand, if you declareModule_Types/Module_Consts
and others in yourexposed-modules
section, that Cabal will ignoreModule.thrift
source file.What I did in my project:
thrift/*.thrift
in theextra-source-files
field.Setup.hs
file with overloadedbuildHook/testHook
. Before running the default hook, they will call the thrift preprocessor for every file matching the pattern inextraSrcFiles
with the destinationbuildDir
.This approach works, but I don't like it:
buildHook
. Also, I have duplicated code in thetestHook
(and I would have it in thebenchHook
, if I needed to).I suggest to remove pattern matching on preprocessor stage at all. I think, time savings in case of dropping unnecessary files doesn't make a difference.
P.S. Here is a link on my
Setup.hs
The text was updated successfully, but these errors were encountered: