cabal文件中的标志

Afo*_*tos 11 haskell cabal

我正在关注软件包开发的用户指南:https://www.haskell.org/cabal/users-guide/developing-packages.html#quickstart

我陷入了困境Flags.如何将标志传递给我的文件?它只是在build时间吗?我试图搜索它,但没有找到有用的信息 - 只是命令选项--flags.

cabal build -f debug 不起作用

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
Run Code Online (Sandbox Code Playgroud)

Eri*_*ikR 21

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

cabal configure -f debug
Run Code Online (Sandbox Code Playgroud)


ntc*_*tc2 6

通过堆栈,使用

stack build --flag <pkg>:debug
Run Code Online (Sandbox Code Playgroud)

debug将标志设置为Truefor <pkg>,或使用将标志--flag '*:debug'设置为所有包。替换为将标志设置为。debugTruedebug-debugdebugFalse

您还可以在文件中指定标志设置stack.yaml。例如,要将debug标志设置为Falsefor <pkg>,请将其添加到您的stack.yaml

flags:
  <pkg>:
    debug: false
Run Code Online (Sandbox Code Playgroud)


vro*_*911 5

有了cabal-2.1.0你可以做这样的:

cabal new-build -f debug 
Run Code Online (Sandbox Code Playgroud)