libraries does not enforce any local paths. It does not work with paths at all. Briefly, libraries accepts names that were set either in the name or public_name field of libraries. However, the name field will only be available in the scope of the library (the .opam file defines that).
If you would like to include libraries defined in another project on your file system, you can simply symlink the directory where that library is defined into your project by the way. It does not make so much to copy modules from external libraries.
I made it a mistake, it is actually called (copy_files# ..) and it also accepts globs if you would like to copy multiple files.
Could you describe your problem a bit more by the way? Are you trying to import a source from the same project? Or is it a different project? By project, I mean a dune-project here.
If you’re importing a library from a different project, I recommend that you either:
Create a workspace that would include both projects. This would mean having a dir structure like:
Now, there is another project, HELIX, which wants to use Vellvm as a library. https://github.com/vzaliva/helix/tree/LLVM It also generates some OCaml code from Coq and using dune.
Right now it assumes that vellvm will be a git submodule (or symlink) under lib.
HELIX Coq code depends on Vellvm Coq code. This works pretty well. When generating ML code, it creates files ml/extracted. Vellvm Coq code is re-used and re-extracted as ML here. So far so good.
Now I am trying to find a way to have some additional OCaml code from Vellvm re-usable in projects like HELIX. Currently, it is just llvm_printer.ml but there might be more in the future. The directory structure is:
One of the problems is that llvm_printer.ml depends on some modules from extracted. Luckily they are the same in both Vellvm and HELIX as they generated from the same Vellvm Coq code.
One reason I’ve chosen to use dune here is the promise of composable builds. But I may have misunderstood the limitations…
In dune, the unit of composition of rules is the directory. So dune will discover all rules in starting from a root (workspace or project) and will have a unified view of the build in terms of libraries, executables, etc. However, the unit of sharing code is the library. So if you want your llvm_printer.ml source to be re-usable it must be in some library. Once you define this library (using the library stanza), it will be usable in HELIX it will be usable under the public_name you give this library. This is provided that you’re in a workspace that includes both projects of course. That is usually easy enough to arrange using symlinks or just putting related projects in root directory.