Cabal多个可执行文件 [英] Cabal Multiple Executables

查看:105
本文介绍了Cabal多个可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Yesod在网站上工作我有正常的构建运行,但我似乎无法可靠地填充我的数据库。我有第二个填充数据库的haskell程序,我已经将它添加到我的cabal文件中,如下所示:

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

问题是,当我运行'cabal build'时,它不会在init.hs更改时重新生成init。我必须做些什么才能做到这一点?

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?

下面是一个示例终端会话(在编辑init.hs之后):

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.

推荐答案

您可以通过将它们作为参数传递给 cabal build cabal run 。例如, cabal build init 。如果没有给出目标名称,则第一个可执行文件是默认文件。

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.

这篇关于Cabal多个可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆