
A while ago I moved a project away from using a mix of Cabal and make to build (Cabal to build the library and make to build the tests) to using only Cabal. I added a flag and then made a construct like this: flag BuildTests Description: Build unit and quickcheck tests. Default: False ... executable tests if flag(BuildTests) main-is: Test.hs build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 hs-source-dirs: test-src src else main-is: Test.hs buildable: False Interestingly that does work for things like 'configure' and 'build', but it doesn't work for 'sdist': % ./Setup.hs sdist Distribution quality errors: Building source dist for dataenc-0.13.0.1... Setup.hs: Test.hsTest.hs doesn't exist To make this work I had to move the 'main-is' outside of the if-else: executable tests main-is: Test.hs hs-source-dirs: test-src src if flag(BuildTests) build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 else buildable: False I found this surprising, so I'm tempted to call it a bug. A quick search didn't tell me whether this is well-known already, hence the email. Would you consider it a bug? Has it been raised already? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

To make this work I had to move the 'main-is' outside of the if-else:
executable tests main-is: Test.hs hs-source-dirs: test-src src if flag(BuildTests) build-depends: test-framework, test-framework-hunit, HUnit, test-framework-quickcheck2, QuickCheck >= 2.1.0.0 else buildable: False
I found this surprising, so I'm tempted to call it a bug. A quick search didn't tell me whether this is well-known already, hence the email. Would you consider it a bug? Has it been raised already?
I do something similar with EMGM, but I never tried to put the main-is inside the if. I just did this for the test executable. if flag(test) build-depends: QuickCheck >= 2.1 && < 2.2, HUnit >= 1.2 && < 1.3 else buildable: False Sean

On Thu, 2009-10-08 at 09:31 +0100, Magnus Therning wrote:
A while ago I moved a project away from using a mix of Cabal and make to build (Cabal to build the library and make to build the tests) to using only Cabal. I added a flag and then made a construct like this:
[..]
Interestingly that does work for things like 'configure' and 'build', but it doesn't work for 'sdist':
I found this surprising, so I'm tempted to call it a bug. A quick search didn't tell me whether this is well-known already, hence the email. Would you consider it a bug? Has it been raised already?
Yes, I'd consider it a bug. I don't think it has been reported. Duncan
participants (3)
-
Duncan Coutts
-
Magnus Therning
-
Sean Leather