I have a Dune-project (an application) A that depends on a third library L, this library is located in the workspace of the project, but it is built with a Make script (not using Dune).
The project tree is similar to:
A |_ dune-project |_ src |_ dune |_ ... |_ L |_ src |_ Makefile
I would like my application to depend on this non-Dune library. I have been looking into the docs and I have tried a number of approaches without much success…
My preferred choice would be to package the library as a Dune-project, while still building it using the existing Make script. I tried following the Foreign build sandboxing idea without success:
(library (name L)) (rule (deps (source_tree src)) (targets L.cmxa) (action (progn (chdir src (run make)) (copy src/L.cmxa L.cmxa) )))
This doesn’t work because the “library” stanza (which is mandatory for declaring a library) must produce “L.cmxa” but it will not know how. I specify a custom rule that produces “L.cmxa”, but this rule conflicts with the “library” stanza.
Another option would be using a pre-compiled “L.cmxa” when building the application A. I could not find the way to specify such dependency. It seems that Dune can only make use of pre-compiled libraries when they are in the “installed world”. I tried copying the .cmxa file with
(copy_files ../L/src/L.cmxa) but one cannot copy files from outside the current directory. Still, if I copy the
L.cm* files of the library into A/src/lib, and then add
(copy_files lib/L.cm*) to A/src/dune, this doesn’t work either (it seems that no file is being copied into _build/default/src).
I would appreciate any recommendations, hints, or pointers to examples.
Thanks in advance!