首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >和阴谋集团一起使用制造文件?

和阴谋集团一起使用制造文件?
EN

Stack Overflow用户
提问于 2013-09-06 03:30:25
回答 1查看 1.2K关注 0票数 9

我正在做一个玩具项目,把我对Haskell的享受从理论转移到实际,让我更适应cabalHUnit等等。

我刚刚在我的项目中添加了一个Makefile:

代码语言:javascript
复制
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做的是不必要的工作,保持状态是否需要重新配置是很无聊的。
  • 两者都是大量的打字

我担心我可能正在用cabalcabal-dev已经提供给我的Make重新创建功能,但我还不太熟悉,也不知道这是否是真的,如果是的话,我将如何做到这一点。

这里是否适合生成文件,或者使用cabal/cabal-dev是否有更直接的方法来做到这一点

EN

回答 1

Stack Overflow用户

发布于 2013-11-08 22:35:53

下面是我与另一个依赖于Cabal包的Haskell程序并行开发时使用的Makefile的简化版本(我经常并行地编辑它们,所以我使用另一个Makefile :P)将Cabal包作为程序的构建依赖项。目标是:

  1. 只有当某些源文件实际更改时才运行cabal。我在一个非常慢的上网本上使用这个Makefile,其中Cabal依赖解析步骤需要10秒钟,所以如果可能的话,我希望完全避免运行cabal install
  2. 有独立的调试和定期构建在单独的构建迪尔。默认情况下,如果您使用分析(--ghc-options=-fprof-auto)完成了Cabal构建,然后不进行分析,则Cabal将重新开始,从头开始重新编译所有文件。将构建放在单独的生成dirs中可以避免此问题。

我不确定(2)对您是否感兴趣,但是(1)可能是,而且我看到您只在成功而不是失败时触摸了build,而且我希望它不能正确工作。

下面是Makefile:

代码语言:javascript
复制
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)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18649427

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档