我正在做一个玩具项目,把我对Haskell的享受从理论转移到实际,让我更适应cabal、HUnit等等。
我刚刚在我的项目中添加了一个Makefile:
test: dist/build
cabal-dev test
dist/build: dist/setup-config src/*.hs tests/*.hs
cabal-dev build
touch dist/build
dist/setup-config: ToyProject.cabal
cabal-dev configure --enable-tests因为:
cabal-dev install --enable-tests看起来有点过分(并且警告我要重新安装)cabal-dev configure --enable-tests && cabal-dev build && cabal-dev test做的是不必要的工作,保持状态是否需要重新配置是很无聊的。我担心我可能正在用cabal或cabal-dev已经提供给我的Make重新创建功能,但我还不太熟悉,也不知道这是否是真的,如果是的话,我将如何做到这一点。
这里是否适合生成文件,或者使用cabal/cabal-dev是否有更直接的方法来做到这一点
发布于 2013-11-08 22:35:53
下面是我与另一个依赖于Cabal包的Haskell程序并行开发时使用的Makefile的简化版本(我经常并行地编辑它们,所以我使用另一个Makefile :P)将Cabal包作为程序的构建依赖项。目标是:
cabal。我在一个非常慢的上网本上使用这个Makefile,其中Cabal依赖解析步骤需要10秒钟,所以如果可能的话,我希望完全避免运行cabal install。--ghc-options=-fprof-auto)完成了Cabal构建,然后不进行分析,则Cabal将重新开始,从头开始重新编译所有文件。将构建放在单独的生成dirs中可以避免此问题。我不确定(2)对您是否感兴趣,但是(1)可能是,而且我看到您只在成功而不是失败时触摸了build,而且我希望它不能正确工作。
下面是Makefile:
cabal-install: dist
cabal-install-debug: prof-dist
# You will need to extend this if your cabal build depends on non
# haskell files (here '.lhs' and '.hs' files).
SOURCE = $(shell find src -name '*.lhs' -o -name '*.hs')
# If 'cabal install' fails in building or installing, the
# timestamp on the build dir -- 'dist' or 'prof-dist', stored in
# the make target variable '$@' here -- may still be updated. So,
# we set the timestamp on the build dir to a long time in the past
# with 'touch --date "@0" $@' in case cabal fails.
CABAL_INSTALL = \
cabal install $(CABAL_OPTIONS) \
|| { touch --date "@0" $@ ; \
exit 42 ; }
dist: $(SOURCE)
$(CABAL_INSTALL)
# Build in a non-default dir, so that we can have debug and non-debug
# versions compiled at the same time.
#
# Added '--disable-optimization' because '-O' messes with
# 'Debug.Trace.trace' and other 'unsafePerformIO' hacks.
prof-dist: CABAL_OPTIONS += --ghc-options="-fprof-auto" --builddir=prof-dist --disable-optimization
prof-dist: $(SOURCE)
$(CABAL_INSTALL)https://stackoverflow.com/questions/18649427
复制相似问题