[Haskell-cafe] Cabal: Disjunctive Build-Depends

Felipe Almeida Lessa felipe.lessa at gmail.com
Mon Dec 12 21:29:54 CET 2011


On Mon, Dec 12, 2011 at 6:25 PM, Matthew Farkas-Dyck
<strake888 at gmail.com> wrote:
> I have written some code that can be compiled with either of two
> libraries, with no modification. How can I tell Cabal?
>
> I tried "||" but it failed to parse.
>
> I could find which package is available in the build script, and then
> call defaultMainNoRead with the appropriate GenericPackageDescription,
> but I'm not sure how to find this system-agnostically.

You just need to use flags.  Something like

Flag usethis
  Description:  Use this instead of that
  Default:  False

Library
  Build-depends: ...everything else...
  if flag(usethis)
    Build-depends: this == 0.1.*
  else
    Build-depends: that == 4.0.*

You don't need to care about usethis.  If 'that' is not installed but
'this' is, Cabal will automatically turn 'usethis' flag on.

Cheers,

-- 
Felipe.



More information about the Haskell-Cafe mailing list