Cabal: conditionally override a flag default value

徘徊边缘 提交于 2019-12-23 20:05:16

问题


Is there any way to rewrite either:

flag llvm
    description: compile via LLVM
    default    : if os(mingw32)
                   False
                 else
                   True

or

flag llvm
    description: compile via LLVM
    default    : True

if os(mingw32)
    ?SET-LLVM=False?

and get cabal to work with it?


Note:

Further down in the same file the llvm flag is used like:

if flag(llvm)
  ghc-options: -fllvm -optlo-O3

and there are many other single high-level flags that translate to multiple ghc-options entries, such as static to -static -optl-static.


回答1:


You can do something like this:

flag llvm
    description: compile via LLVM
    default    : True

-- ...

Executable foo
    if flag(llvm) && !os(windows)
        ghc-options: -fllvm -optlo-O3


来源:https://stackoverflow.com/questions/10523935/cabal-conditionally-override-a-flag-default-value

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