ocamlfind/ocamlbuild 工具链如何与包的项目本地副本一起使用?

发布于 2024-12-02 16:15:26 字数 464 浏览 1 评论 0原文

我试图保持我的项目独立,所有主要的第三方库依赖项都在项目存储库中构建和引用。我的项目的主要 ocaml 部分依赖于 ocamlbuild。

但对于像 Batteries Included 这样的复杂包,人们似乎强烈期望它们通过 ocamlfind 链接到一个项目中。 ocamlfind 似乎假设软件包将被全局安装。 (我意识到它允许环境变量及其conf指向备用位置,但从根本上来说它似乎仍然是围绕包是全局配置的假设构建的——它没有等价于-I或<例如,使用 code>-L 标志动态扩展包的搜索路径,可以设置环境变量来动态覆盖 ocamlfind 配置以搜索项目本地树,但这比 更尴尬。仅仅是争论,而且似乎也具有挑战性这样做不需要同时删除site-lib中主系统包的可发现性,这可能也是需要的。)

构建和构建的合理策略是什么使用 ocamlbuild 的项目的项目本地树中是否有重要的第 3 方包?

I am trying to keep my project self-contained, with all major 3rd party library dependencies built and referenced within the project repository. The main ocaml portions of my project rely on ocamlbuild.

But for complex packages like Batteries Included, there seems to be a strong expectation that they be linked into a project via ocamlfind. ocamlfind seems to assume that packages will be installed globally. (I realize it allows environment variables and its conf to point to alternate locations, but it fundamentally still seems to be built around the assumption that packages are globally configured--it has no equivalent of -I or -L flags to dynamically extend the search path for packages, for example. It may be possible to set environment variables to dynamically override the ocamlfind configuration to search the project-local tree, but this is much more awkward than mere arguments, and it also seems like it would be challenging to do so without simultaneously removing discoverability of the main system packages in the primary site-lib, which may also be needed.)

What is a sane strategy for building and building against nontrivial 3rd party packages within a project-local tree for a project using ocamlbuild?

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

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

发布评论

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

评论(1

韶华倾负 2024-12-09 16:15:26

使用环境变量(或单独的 findlib.conf)是一种方法(而且很简单)。并且它不需要删除全局包的可发现性,请参阅 findlib.confpathdestdir 的参考手册 (OCAMLPATH< /code> 和 OCAMFIND_DESTDIR 环境变量)。

基本上,您在安装项目本地包时将 destdir 设置为本地路径,并在使用它们时将prepend 设置为 path (不要忘记创建 < code>stublibsdestdir 中(如果您正在构建字节码二进制文件,请将其添加到 stdlib 中的 ld.conf))。

PS我认为这是 ocsigen-bundler 中使用的方法。

如果您遇到任何问题,请告知(因为我也有兴趣使用相同的方法)。

Using environment variables (or separate findlib.conf) is a way to go (and easy). And it doesn't require removing discoverability of global packages, see reference manual for path and destdir in findlib.conf (OCAMLPATH and OCAMLFIND_DESTDIR environment variables respectively).

Basically you set destdir to local path when installing project-local packages, and prepend to path when using them (don't forget to create stublibs in destdir (and add it to ld.conf in stdlib if you are building bytecode binaries)).

PS I think this is the approach used in ocsigen-bundler.

Please tell if you experience any problems (cause I am interested in using this same approach too).

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