我怎样才能让 Cabal 搜索外部程序?

发布于 2024-08-29 14:47:23 字数 98 浏览 3 评论 0原文

我正在尝试编写一个 Haskell 程序,它需要外部程序(例如 lame,mp3 编码器)的输出。虽然在 cabal 中声明对库的依赖关系很容易,但如何声明对可执行文件的依赖关系呢?

I'm trying to write a Haskell program which requires the output of external programs (such as lame, the mp3 encoder). While declaring dependency on a library is easy in cabal, how can one declare dependency on an executable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-09-05 14:47:23

目前,您无法在 .cabal 文件中添加外部可执行文件的依赖项,除了已知构建工具的列表(例如,请参阅构建工具:alex)。

但是,您可以指定构建类型:配置,然后使用单独的配置脚本来搜索任何其他二进制文件(例如,基于 autoconf 的配置脚本非常好,并且可用于在源中设置常量)。

请注意,在编译时搜索运行时依赖项(例如蹩脚的编码器)可能是一个坏主意,因为许多包系统上的构建和运行环境都不同。在程序启动时动态搜索所需的二进制文件可能是一个更好的主意。

例如,hmp3 搜索 mpg321,

     mmpg <- findExecutable (MPG321 :: String)

其中 MPG321 是通过 ./configure 选项确定的程序名称。有关更多信息,请参阅黑线鳕:

http://hackage.haskell.org/packages/archive/directory/latest/doc/html/System-Directory.html#v:findExecutable

You can't currently add a dependency in the .cabal file for external executables, other than a list of known build tools (see build-tools: alex for example).

You can however specify build-type: Configure, and then use a separate configure script to search for any additional binaries (for example, an autoconf-based configure script is perfectly fine, and can be used to set constants in your source).

Note that searching for a runtime dependency -- such as a lame encoder -- at compile time may be a bad idea, as the build and run environments are different on many package systems. It might be a better idea to dynamically search for required binaries at program startup.

For example, hmp3 hunts for mpg321 with

     mmpg <- findExecutable (MPG321 :: String)

where MPG321 is the name of the program determined via a ./configure option. For more information, see the haddocks:

http://hackage.haskell.org/packages/archive/directory/latest/doc/html/System-Directory.html#v:findExecutable

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文