ocamlfind/ocamlbuild 工具链如何与包的项目本地副本一起使用?
我试图保持我的项目独立,所有主要的第三方库依赖项都在项目存储库中构建和引用。我的项目的主要 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用环境变量(或单独的 findlib.conf)是一种方法(而且很简单)。并且它不需要删除全局包的可发现性,请参阅
findlib.conf
中path
和destdir
的参考手册 (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
anddestdir
infindlib.conf
(OCAMLPATH
andOCAMLFIND_DESTDIR
environment variables respectively).Basically you set
destdir
to local path when installing project-local packages, and prepend topath
when using them (don't forget to createstublibs
indestdir
(and add it told.conf
instdlib
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).