简体   繁体   中英

Flags in cabal files

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

将标志传递给cabal configure ,例如:

cabal configure -f debug

使用cabal-2.1.0您可以这样做:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM