【问题标题】:how to reuse cabal compiled modules when using ghci使用 ghci 时如何重用 cabal 编译的模块
【发布时间】:2013-02-28 01:23:31
【问题描述】:

我有一个相当大的 haskell 项目,在某些文件上运行 ghci 可能需要编译数十或数百个模块才能得到提示,这可能需要几分钟。我正在使用 cabal,所以我通常已经在 dist/ 下编译了目标文件。但是 ghci 只查找源 .hs 文件旁边的 .o 文件;它不知道 cabal 的 dist/。有没有什么简单又好办法让 ghci 加载那些目标文件,而不是自己重新编译所有东西?

我要求一个简单而好的方法,因为我有复杂而丑陋的方法来做到这一点。 :) 例如,这将使 ghci 重用 cabal 编译的模块。我想出了这个命令 通过复制和修改 cabal 运行 ghc 的方式,确保它将所有内容设置为与上次 cabal 构建相同,这是确保 ghci 加载模块所必需的。

ghci -package-conf dist/package.conf.inplace -i -idist/build/git-annex/git-annex-tmp -i。 -idist/build/autogen -Idist/build/autogen -Idist/build/git-annex/git-annex-tmp -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build/git-annex/ git-annex-tmp -hidir dist/build/git-annex/git-annex-tmp -stubdir dist/build/git-annex/git-annex-tmp -XHaskell98 dist/build/git-annex/git-annex-tmp /Utility/libdiskfree.o dist/build/git-annex/git-annex-tmp/Utility/libmounts.o

在我看来,“cabal ghci”应该可以计算并运行这个命令行,或者可能有一个我不知道的工具已经这样做了。

【问题讨论】:

  • 你是否真的让 cabal register 编译的模块 (cabal install)?
  • 不,因为它们是应用程序的一部分,并且随着我的开发而改变。

标签: haskell ghci


【解决方案1】:

您可以将 odir 和 ohi 选项设置为指向 cabal 构建目录,如下所示:http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/separate-compilation.html#output-files

【讨论】:

  • 仅 -odir 本身似乎不足以让 ghci 对 cabal 对象感到满意。 -ohi 似乎是针对单个接口文件的,没有必要。我上面的命令行确实包含 -odir,并且其中的大多数其他内容似乎也是使 ghci 快乐所必需的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-05
  • 1970-01-01
  • 1970-01-01
  • 2019-03-25
  • 2021-08-13
相关资源
最近更新 更多