I am following the user-guide for package developing: https://www.haskell.org/cabal/users-guide/developing-packages.html#quickstart
I got stuck in the Flags
section. How do I pass flags to my files? Is it just at build
time? I have tried to search for it, but found no useful information - just the command option --flags
.
cabal build -f debug
doesn't work
Flag Debug
Description: Enable debug support
Manual: True
Default: False
BenchMark bench-foo
ghc-options: -Wall
type: exitcode-stdio-1.0
default-language: Haskell2010
build-depends: base, time
main-is: bench-foo.hs
if flag(debug) && os(windows)
main-is: bench-bar.hs
Pass the flags to cabal configure
, e.g.:
cabal configure -f debug
With cabal-2.1.0
you can do it like this:
cabal new-build -f debug
With Stack, use
stack build --flag <pkg>:debug
to set debug
flag to True
for <pkg>
, or use --flag '*:debug'
to set debug
flag to True
for all packages. Replace debug
with -debug
to set debug
flag to False
.
You can also specify flag settings in a stack.yaml
file. For example, to set debug
flag to False
for <pkg>
, add this to your stack.yaml
:
flags:
<pkg>:
debug: false
来源:https://stackoverflow.com/questions/31821952/flags-in-cabal-files