当我运行ts
时,cabal会经历两次编译过程。由于编译需要相对较长的时间(约60秒),这开始阻碍我的工作流程。
以下是我的cabal文件中的ghc选项:
cabal build
GHC-Options: -O3 -rtsopts -funbox-strict-fields -threaded -Wall -feager-blackholing -fllvm -optlo-O3
if flag(Eventlog)
GHC-Options: -O3 -rtsopts -funbox-strict-fields -threaded -eventlog -Wall
if flag(Profiling)
ghc-prof-options: -O3 -auto-all
GHC-Options: -O3 -rtsopts -funbox-strict-fields -threaded -fprof-auto -Wall
if flag(Dump)
GHC-options: -O3 -funbox-strict-fields -Wall -ddump-simpl -dsuppress-module-prefixes -dsuppress-uniques -ddump-to-file
的输出看起来完全正常,但是一旦最后一个模块第一次完成编译,编译就会重新开始。
cabal build
我使用的是Ubuntu 14.04,GHC 7.10.1,cabal-install 1.22.4,cabal library 1.22.3。如果您有兴趣尝试重现,这里是回购的link。我建议运行[ 1 of 13] Compiling HaObj ( src/HaObj.hs, nothing )
[ 2 of 13] Compiling Surfaces ( src/Surfaces.hs, nothing )
[ 3 of 13] Compiling Materials ( src/Materials.hs, nothing )
[ 4 of 13] Compiling Geometry3 ( src/Geometry3.hs, nothing )
[ 5 of 13] Compiling Triangles ( src/Triangles.hs, nothing )
[ 6 of 13] Compiling BoundingVolumeHierarchy ( src/BoundingVolumeHierarchy.hs, nothing )
[ 7 of 13] Compiling RayTracer ( src/RayTracer.hs, nothing )
[ 8 of 13] Compiling BenchmarkScene5 ( src/BenchmarkScene5.hs, nothing )
[ 9 of 13] Compiling BenchmarkScene4 ( src/BenchmarkScene4.hs, nothing )
[10 of 13] Compiling BenchmarkScene3 ( src/BenchmarkScene3.hs, nothing )
[11 of 13] Compiling BenchmarkScene2 ( src/BenchmarkScene2.hs, nothing )
[12 of 13] Compiling BenchmarkScene ( src/BenchmarkScene.hs, nothing )
[13 of 13] Compiling Main ( src/Main.hs, nothing )
[ 1 of 13] Compiling HaObj ( src/HaObj.hs, nothing )
[ 2 of 13] Compiling Surfaces ( src/Surfaces.hs, nothing )
[ 3 of 13] Compiling Materials ( src/Materials.hs, nothing )
[ 4 of 13] Compiling Geometry3 ( src/Geometry3.hs, nothing )
[ 5 of 13] Compiling Triangles ( src/Triangles.hs, nothing )
[ 6 of 13] Compiling BoundingVolumeHierarchy ( src/BoundingVolumeHierarchy.hs, nothing )
[ 7 of 13] Compiling RayTracer ( src/RayTracer.hs, nothing )
[ 8 of 13] Compiling BenchmarkScene5 ( src/BenchmarkScene5.hs, nothing )
[ 9 of 13] Compiling BenchmarkScene4 ( src/BenchmarkScene4.hs, nothing )
[10 of 13] Compiling BenchmarkScene3 ( src/BenchmarkScene3.hs, nothing )
[11 of 13] Compiling BenchmarkScene2 ( src/BenchmarkScene2.hs, nothing )
[12 of 13] Compiling BenchmarkScene ( src/BenchmarkScene.hs, nothing )
[13 of 13] Compiling Main ( src/Main.hs, nothing )
以将构建时间减少到几秒钟。
编辑:Zeta指出这是因为我的cabal文件中有可执行文件cabal build --ghc-options="-fno-code"
和基准ray-tracer
。有没有办法只构建其中一个?我试过bench
,但这也建立了两个目标。我也试过了cabal build ray-tracer
。有没有办法选择性地只构建其中一个目标而不重新组织cabal文件的结构?
答案 0 :(得分:1)
将评论的答案发布为community-wiki:
构建单个组件的语法是(例如)cabal build exe:ray-tracer