Cabal 配置文件选项
Cabal configure file options
我正在使用 cabal
来管理一个中型项目(不用于分发)。我使用 Makefile
执行基本设置,然后它调用 cabal
configure
/build
来构建项目的其余部分。我还希望能够使用 GHC 内置的工具选择性地分析项目。
这似乎涉及 .cabal
文件中的一组不同的选项,以及将 --enable-executable-profiling
选项传递给 cabal
配置阶段。后者在 Makefile
中很容易实现,但我找不到一种干净的方法来告诉 cabal
使用一组特定的编译器选项,具体取决于我如何调用 make
。简而言之,我正在寻找类似于为 .cabal
文件制定规则的东西。
抱歉,如果我在这里遗漏了一些非常明显的东西 - 我对 Haskell
/cabal
还是有点陌生。谢谢!
想到两个明显的选择:
使用make
的条件赋值。例如,可以写
PROF_FLAGS?=-prof -auto-all
然后将 --ghc-options="${PROF_FLAGS}"
添加到整个 Makefile
中适当的 cabal
调用中。然后,您可以将 make
调用为:
make # use the defaults
PROF_FLAGS="-prof -auto-all" make # another way to use the defaults
PROF_FLAGS="" make # don't do profiling
使用 cabal
标志。这在您的 .cabal
文件中看起来像这样:
flag profiling
default: True
description: ask GHC to produce a profiling version
executable foo
if flag(profiling)
ghc-options: -prof -auto-all
然后在您的 Makefile
中,您可以将 -f profiling
或 -f -profiling
传递给 cabal
以分别打开和关闭此标志。
我正在使用 cabal
来管理一个中型项目(不用于分发)。我使用 Makefile
执行基本设置,然后它调用 cabal
configure
/build
来构建项目的其余部分。我还希望能够使用 GHC 内置的工具选择性地分析项目。
这似乎涉及 .cabal
文件中的一组不同的选项,以及将 --enable-executable-profiling
选项传递给 cabal
配置阶段。后者在 Makefile
中很容易实现,但我找不到一种干净的方法来告诉 cabal
使用一组特定的编译器选项,具体取决于我如何调用 make
。简而言之,我正在寻找类似于为 .cabal
文件制定规则的东西。
抱歉,如果我在这里遗漏了一些非常明显的东西 - 我对 Haskell
/cabal
还是有点陌生。谢谢!
想到两个明显的选择:
使用
make
的条件赋值。例如,可以写PROF_FLAGS?=-prof -auto-all
然后将
--ghc-options="${PROF_FLAGS}"
添加到整个Makefile
中适当的cabal
调用中。然后,您可以将make
调用为:make # use the defaults PROF_FLAGS="-prof -auto-all" make # another way to use the defaults PROF_FLAGS="" make # don't do profiling
使用
cabal
标志。这在您的.cabal
文件中看起来像这样:flag profiling default: True description: ask GHC to produce a profiling version executable foo if flag(profiling) ghc-options: -prof -auto-all
然后在您的
Makefile
中,您可以将-f profiling
或-f -profiling
传递给cabal
以分别打开和关闭此标志。