How can I use the ocamlfind / ocamlbuild program chain with project local package copies?

I try to make my project stand-alone, with all the main dependencies of third-party libraries created and mentioned in the project repository. The main ocaml parts of my project are based on ocamlbuild.

But for complex packages like Batteries Included, there seems to be a strong expectation that they will be connected to the project through ocamlfind. Ocamlfind is supposed to assume that packages will be installed globally. (I understand that it allows environment variables and its conf to point to alternative locations, but it still seems to be built around the assumption that packages are configured globally - it does not have the equivalent of -I or -L flags for dynamic expansion, for example , the search path for packages It’s possible to set environment variables to dynamically override ocamlfind configuration to search for the local project tree, but this is much more inconvenient than just arguments, and it also seems to be difficult to do without one temporarily removing the detection capabilities of the main system packages, mainly site-lib , which may also be needed.)

What is a reasonable strategy for creating and creating against non-trivial third-party packages in a local project for a project using ocamlbuild?

+6
source share
1 answer

Using environment variables (or a separate findlib.conf) is the way to go (and easy). And this does not require eliminating the ability to detect global packages, see the Reference Guide for path and destdir in findlib.conf ( OCAMLPATH and OCAMLFIND_DESTDIR environment variables respectively).

Basically you install destdir in a local path when installing local project packages and add to path when using them (remember to create stublibs in destdir (and add it to ld.conf in stdlib if you are creating binary bytecode files)).

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

Tell me if you have any problems (because I'm also interested in using the same approach).

+3
source

Source: https://habr.com/ru/post/896436/


All Articles