Haskell 对阴谋集团使用Makefile?
我正在做一个玩具项目,以此将我对哈斯克尔的享受从理论转移到实践,让自己更适应Haskell 对阴谋集团使用Makefile?,haskell,makefile,Haskell,Makefile,我正在做一个玩具项目,以此将我对哈斯克尔的享受从理论转移到实践,让自己更适应阴谋集团,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 con
阴谋集团
,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——启用测试
正在做不必要的工作,而保持关于是否需要重新配置的状态很无聊cabal-dev-configure--enable tests&&cabal-dev-build&&cabal-dev-test
- 而且两人都是打字高手
cabal
或cabaldev
已经提供给我的功能,但是
我对两者都不太熟悉,不知道这是不是真的,如果是真的,我会怎么做
Makefile在这里合适吗?还是有一种更直接的方法可以通过使用
cabal
/cabal dev
?下面是我在cabal包中使用的Makefile的简化版本
我正在与另一个Haskell程序并行开发,这取决于
在阴谋集团包上(我经常并行编辑它们,所以我有
Cabal包作为程序的构建依赖项,使用另一个
Makefile:P)。目标是:
cabal
。我
在一个非常慢的上网本上使用这个Makefile
依赖项解析步骤需要10秒,所以我想
尽可能避免运行cabal install
--ghc options=-fprof auto
),然后是一个没有配置文件的选项,
阴谋集团将重新开始,从头开始重新编译你的所有文件。
将构建放在单独的构建目录中可以避免此问题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)
Cabal 1.18使用
Cabal sandbox
命令替换Cabal dev
。我认为如果您使用新版本Cabal的sandbox功能,大多数关于重新安装的警告都会消失。在1.18Cabal test
中,运行build
并自动重新配置,如果需要的话。米哈伊尔·格鲁申科夫:如果你想得到一个答案,我会接受的。我一直在用阴谋集团制造,下面是一个例子: