Programmatically Listing `C-sources` in Haskell Cabal Files

社会主义新天地 提交于 2020-01-05 05:44:06

问题


I am involved in a Haskell project which involves a lot of C FFI. Thus, for every src/HaskellFile.hs I have in my project, I have a corresponding src/HaskellFile.c C source file. This means I have to manually this all of these C sources in my cabal project:

C-sources:           src/HaskellFile1.c, src/HaskellFile2.c

...and so forth.

Question: Is it possible to programmatically list out these files in my cabal project file? Something like:

C-sources:           src/*.c

..? (For the record, I tried the above and it didn't work).


回答1:


I wanted to add a comment, but stackoverflow tells me that I need 50 reputation to comment!

You should be able to do this with a custom Setup.hs file. Here is an example that might help you: https://hackage.haskell.org/package/base-noprelude-4.7.0.0/src/Setup.hs




回答2:


Sorry, no programming is allowed in cabal files. This level of simplicity has some drawbacks, as you note, but it also has some benefits: tools are more predictable, and it is drop-dead simple to read somebody else's cabal file (you don't have to turn on your programmer brain!).



来源:https://stackoverflow.com/questions/41292462/programmatically-listing-c-sources-in-haskell-cabal-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!