用堆栈构建特定的库?

时间:2019-04-08 01:26:02

标签: haskell haskell-stack

我有一个Haskell堆栈项目,其阴谋文件如下:

library
  exposed-modules:
      Godot.Api
      Godot.Api.Auto
-- ...


library generate 
  exposed-modules:
      Generate
      Spec
      Types
      Types.Internal
-- ...

当我运行stack build时,似乎只构建了第一个library,但是我想堆栈要做的是构建 just library generate。我该怎么做呢?以下内容似乎无效:

stack build project-name:library:generate # doesn't seem to work
stack build project-name:lib:generate # doesn't seem to work

1 个答案:

答案 0 :(得分:1)

很遗憾,you can't write multiple librarys in one cabal file。 因此,您必须为每个库创建一个cabal文件(通常为每个cabal文件创建一个目录)。

然后,将它们列出在stack.yaml中:

packages:
- your-main-library
- generate

然后,运行stack <the-library-to-build>以构建特定的库:

stack build generate

仅供参考。这是一个包含几个库的项目:https://github.com/iij-ii/direct-hs