Flags in cabal files

霸气de小男生 提交于 2019-12-05 16:42:26

问题


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

回答1:


Pass the flags to cabal configure, e.g.:

cabal configure -f debug



回答2:


With cabal-2.1.0 you can do it like this:

cabal new-build -f debug 



回答3:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!