问题
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