Cabal Multiple Executables

蓝咒 提交于 2019-12-05 17:14:18

问题


I'm working on a website using Yesod I have the normal build running but I can't seem to populate my database reliably. I have a second haskell program that populates the database and I've added it to my cabal file like this:

executable         program
  if flag(library-only)
    Buildable: False

  main-is:           ../main.hs
  hs-source-dirs:    dist
  build-depends:     base
                   , myproject
                   , yesod-default

executable         init
  if flag(library-only)
    Buildable: False

  main-is:           init.hs
  hs-source-dirs:    Init
  build-depends:     base
                   , directory
                   , persistent
                   , persistent-sqlite
                   , text
                   , myproject
                   , yesod-default

The problem is that when I run 'cabal build' it does not rebuild init when init.hs changes. What do I have to do to make this happen?

Here's an example terminal session (after editing init.hs):

$ cabal build
Building myproject-0.0.0...
Preprocessing library myproject-0.0.0...
Registering myproject-0.0.0...
$ rm -rf dist/build/myproject/init
$ cabal build
Building myproject-0.0.0...
Preprocessing library myproject-0.0.0...
Registering myproject-0.0.0...

Thank you.


回答1:


You can manage multiple executables by passing them as arguments to cabal build and cabal run. For example, cabal build init. The first executable is the default if no target name is given.



来源:https://stackoverflow.com/questions/11745583/cabal-multiple-executables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!