Cabal Preprocessor Defines

Erik Hesselink hesselink at gmail.com
Thu Sep 18 07:46:49 UTC 2014


The way I usually do this, is your last option: I define 'CPP-Options:
-DDEBUG' in the cabal file. I don't know why this doesn't work for
you. Perhaps it is the final 'install' command, which duplicates the
configure and build, but doesn't have the flag? You could try again
with only 'cabal install -fdebug'. If that doesn't help, run cabal
with '-v' to see what options are passed to all tools.

Regards,

Erik

On Thu, Sep 18, 2014 at 2:21 AM, Manuel Schneckenreither
<manuel.schneckenreither at student.uibk.ac.at> wrote:
> Hi all,
>
> I got some prepocessor constrains in one of my library I use for my new
> project. The section look like this:
>
>             ...
>      #ifdef DEBUG
>             [ppSig sig | sig <- sigs ]
>      #else
>             [ppSig sig | sig <- filter ((\(_,_,r) -> not r) . lhsRootSym) sigs ]
>      #endif
>             ...
>
> Due to the reason that I am still developing wanted to specify the DEBUG
> preprocessor symbol to cpphs, gcc, ghc, or whatever program needs it. My
> suggestion was that cpphs should handle these definitions. So I tried
> several things, like:
>
>     cabal configure --cpphs-options="--cpp -DDEBUG"
>         --ghc-options=-DDEBUG --gcc-options=-DDEBUG && cabal build
>         && cabal install
> ,
>
>     cabal configure --cpphs-options="-DDEBUG"
>         --ghc-options=-DDEBUG --gcc-options=-DDEBUG && cabal build
>         && cabal install
> or
>
>     cabal configure && cabal build  --cpphs-options="--cpp -DDEBUG"
>         --cpphs-options=-DDEBUG --gcc-options=-DDEBUG && cabal install
>
>
> I tried it also in the cabal file:
>
>
>       default-extensions: CPP   -- also tried with other-extensions
>       if flag(debug)
>           CPP-Options: -DDEBUG
>           if !os(windows)
>               CC-Options: -DDEBUG
>           else
>               CC-Options: -DNDEBUG
>
> and compiling with cabal configure --flags=debug && cabal build && cabal
> install.
>
>
> None of them worked. Am I doing it wrong, or is there something wrong
> with cabal, cpphs, ghc, etc.
>
>
> Thanks for your reply,
>
> Manuel
>
>
> --
> To reply secure use GnuPG encryption:
> Key Block to use (http://www.pinselzone.com/pgp/public_gpg_key.asc)
> What is GnuPG? (http://www.gnupg.org/)
> _______________________________________________
> cabal-devel mailing list
> cabal-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/cabal-devel


More information about the cabal-devel mailing list