CABAL: conditional executable?

I'm putting together a package consisting of 2 executables. Only one of them is pure Haskell and thus buildable on all platforms, the other relies on Windows API calls and can only be built on that platform. I found the “if os(...)” conditional in the CABAL docs but I'm having problems getting it to do what I want. if os(mingw32) executable foo ... Results in the error “Section expected”. Swapping the two lines like this executable foo if os(mingw32) ... results in “Setup.hs: Error: No 'Main-Is' field found for executable foo”. Is there a way to get CABAL to do what I want or should I raise a feature request on the CABAL trac? /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus.therning@gmail.com http://therning.org/magnus What if I don't want to obey the laws? Do they throw me in jail with the other bad monads? -- Daveman

executable foo main-is: bla if !os(windows): buildable: false Unfortunately this gives rather unhelpful error messages when used with flags, but it works well enough for now. / Thomas On 4 mar 2008, at 09.10, Magnus Therning wrote:
I'm putting together a package consisting of 2 executables. Only one of them is pure Haskell and thus buildable on all platforms, the other relies on Windows API calls and can only be built on that platform. I found the “if os(...)” conditional in the CABAL docs but I'm having problems getting it to do what I want.
if os(mingw32) executable foo ...
Results in the error “Section expected”. Swapping the two lines like this
executable foo if os(mingw32) ...
results in “Setup.hs: Error: No 'Main-Is' field found for executable foo”.
Is there a way to get CABAL to do what I want or should I raise a feature request on the CABAL trac?
/M
-- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus.therning@ gmail.com http://therning.org/magnus
What if I don't want to obey the laws? Do they throw me in jail with the other bad monads? -- Daveman
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 3/4/08, Thomas Schilling
executable foo main-is: bla if !os(windows): buildable: false
Unfortunately this gives rather unhelpful error messages when used with flags, but it works well enough for now.
/ Thomas
Hmmm, I don't seem to get this to work the way I want it. I get a "Parse of field 'buildable' failed:" which means configure failed and then I can't proceed to build the second executable, bar, in the same package. /M

On 4 mar 2008, at 11.37, Magnus Therning wrote:
On 3/4/08, Thomas Schilling
wrote: executable foo main-is: bla if !os(windows): buildable: false Unfortunately this gives rather unhelpful error messages when used with flags, but it works well enough for now.
/ Thomas
Hmmm, I don't seem to get this to work the way I want it. I get a "Parse of field 'buildable' failed:" which means configure failed and then I can't proceed to build the second executable, bar, in the same package.
Oh, right. That's a bug in Cabal 1.2 (fixed in HEAD). Use: buildable: False HTH

On 3/4/08, Thomas Schilling
On 4 mar 2008, at 11.37, Magnus Therning wrote:
On 3/4/08, Thomas Schilling
wrote: executable foo main-is: bla if !os(windows): buildable: false Unfortunately this gives rather unhelpful error messages when used with flags, but it works well enough for now.
/ Thomas
Hmmm, I don't seem to get this to work the way I want it. I get a "Parse of field 'buildable' failed:" which means configure failed and then I can't proceed to build the second executable, bar, in the same package.
Oh, right. That's a bug in Cabal 1.2 (fixed in HEAD). Use:
buildable: False
OK, that solved that problem, now onto the next. Rather surprisingly to me, buildability has an impact on what's included in the source tar-ball created with "sdist". What's the reason for that behaviour? /M

On 3/6/08, Magnus Therning
On 3/4/08, Thomas Schilling
wrote: On 4 mar 2008, at 11.37, Magnus Therning wrote:
On 3/4/08, Thomas Schilling
wrote: executable foo main-is: bla if !os(windows): buildable: false Unfortunately this gives rather unhelpful error messages when used with flags, but it works well enough for now.
/ Thomas
Hmmm, I don't seem to get this to work the way I want it. I get a "Parse of field 'buildable' failed:" which means configure failed and then I can't proceed to build the second executable, bar, in the same package.
Oh, right. That's a bug in Cabal 1.2 (fixed in HEAD). Use:
buildable: False
OK, that solved that problem, now onto the next. Rather surprisingly to me, buildability has an impact on what's included in the source tar-ball created with "sdist". What's the reason for that behaviour?
It seems the source isn't even included on the platform where the executable *is* buildable. I'll see if I can put together a small example and raise a bug. /M

On 3/6/08, Magnus Therning
On 3/6/08, Magnus Therning
wrote: On 3/4/08, Thomas Schilling
wrote: On 4 mar 2008, at 11.37, Magnus Therning wrote:
On 3/4/08, Thomas Schilling
wrote: executable foo main-is: bla if !os(windows): buildable: false Unfortunately this gives rather unhelpful error messages when used with flags, but it works well enough for now.
/ Thomas
Hmmm, I don't seem to get this to work the way I want it. I get a "Parse of field 'buildable' failed:" which means configure failed and then I can't proceed to build the second executable, bar, in the same package.
Oh, right. That's a bug in Cabal 1.2 (fixed in HEAD). Use:
buildable: False
OK, that solved that problem, now onto the next. Rather surprisingly to me, buildability has an impact on what's included in the source tar-ball created with "sdist". What's the reason for that behaviour?
It seems the source isn't even included on the platform where the executable *is* buildable. I'll see if I can put together a small example and raise a bug.

On Thu, 2008-03-06 at 16:29 +0000, Magnus Therning wrote:
On 3/6/08, Magnus Therning
wrote: On 3/6/08, Magnus Therning wrote: On 3/4/08, Thomas Schilling wrote:
Oh, right. That's a bug in Cabal 1.2 (fixed in HEAD). Use:
buildable: False
OK, that solved that problem, now onto the next. Rather surprisingly to me, buildability has an impact on what's included in the source tar-ball created with "sdist". What's the reason for that behaviour?
It seems the source isn't even included on the platform where the executable *is* buildable. I'll see if I can put together a small example and raise a bug.
Fixed, thanks. Duncan

On Tue, 4 Mar 2008, Magnus Therning wrote:
I'm putting together a package consisting of 2 executables. Only one of them is pure Haskell and thus buildable on all platforms, the other relies on Windows API calls and can only be built on that platform. I found the âif os(...)â conditional in the CABAL docs but I'm having problems getting it to do what I want.
if os(mingw32) executable foo ...
Results in the error âSection expectedâ. Swapping the two lines like this
executable foo if os(mingw32) ...
results in âSetup.hs: Error: No 'Main-Is' field found for executable fooâ.
It sounds like another instance of the case that parts of a package cannot be build under some circumstances. Keep in mind that other packages might rely on the installed second executable if they find that the package is installed. Thus, I guess it's better to extract the second executable to a different package for Window's only stuff.

On 3/4/08, Henning Thielemann
On Tue, 4 Mar 2008, Magnus Therning wrote:
I'm putting together a package consisting of 2 executables. Only one of them is pure Haskell and thus buildable on all platforms, the other relies on Windows API calls and can only be built on that platform. I
found the â if os(...)â conditional in the CABAL docs but I'm having
problems getting it to do what I want.
if os(mingw32) executable foo ...
Results in the error â Section expectedâ . Swapping the two lines like this
executable foo if os(mingw32) ...
results in â Setup.hs: Error: No 'Main-Is' field found for executable fooâ .
It sounds like another instance of the case that parts of a package cannot be build under some circumstances. Keep in mind that other packages might rely on the installed second executable if they find that the package is installed. Thus, I guess it's better to extract the second executable to a different package for Window's only stuff.
Good point. Does CABAL 1.2 have support for multiple .cabal files in the same directory? If not then I'm not too happy with this solution. /M

On 4 mar 2008, at 10.58, Magnus Therning wrote:
Good point. Does CABAL 1.2 have support for multiple .cabal files in the same directory? If not then I'm not too happy with this solution.
No. Eventually, Cabal will support something like this, but it's unlikely that Cabal 1.4 will.
participants (4)
-
Duncan Coutts
-
Henning Thielemann
-
Magnus Therning
-
Thomas Schilling