简体   繁体   English

如何在使用ghci时重用cabal编译的模块

[英]how to reuse cabal compiled modules when using ghci

I have a fairly large haskell project, and running ghci on some files can require compiling dozens or hundreds of modules before it gets to a prompt, which can take a number of minutes. 我有一个相当大的haskell项目,并且在某些文件上运行ghci可能需要在得到提示之前编译几十个或几百个模块,这可能需要几分钟。 I'm using cabal, and so I generally have already compiled object files under dist/. 我正在使用cabal,所以我通常已经在dist /下编译了目标文件。 But ghci only looks for .o files next to the source .hs files; 但是ghci只查找源.hs文件旁边的.o文件; it does not know about cabal's dist/. 它不知道cabal的dist /。 Is there any simple and good way to make ghci load those object files rather than recompiling everything on its own? 是否有任何简单而好的方法使ghci加载这些目标文件而不是自己重新编译所有内容?

I'm asking for a simple and good way, because I have complicated and ugly ways to do it. 我要求一个简单而好的方法,因为我有复杂而丑陋的方法。 :) For example, this will make ghci reuse the cabal compiled modules. :)例如,这将使ghci重用cabal编译的模块。 I came up with this command line by copying, and modifying the way cabal runs ghc, ensuring that it sets everything the same as the last cabal build, which is necessary to make sure ghci will load the modules. 我通过复制和修改cabal运行ghc的方式想出了这个命令行,确保它设置的一切与最后的cabal构建相同,这是确保ghci加载模块所必需的。

ghci -package-conf dist/package.conf.inplace -i -idist/build/git-annex/git-annex-tmp -i. 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 -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

Seems to me it should be possible for a "cabal ghci" to calculate this command line and run it, or perhaps there is a tool I don't know of that already does so. 在我看来,“cabal ghci”应该可以计算这个命令行并运行它,或者可能有一个我不知道的工具已经这样做了。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM