Hooking into the Dune resolution process

Is there any way to programmatically access build artefacts constructed by dune, maybe perhaps by hooking into dune directly?

I’d like to access, for example, the cmi/cmo file produced by a given source code file automatically, but the location of the build artefacts seems to be dependent on the configuration of dune files.

(Note: I’m not referring here to accessing the file as part of a build rule - I understand that there are ways of piping output between files to do that - but rather as a standalone program separate from dune)

I could obviously hardcode a path relative to the current file - i.e _build/default/... but I was hoping there might be a more systematic way of doing this without having to reverse engineer the dune build process myself.

Hello,

You can use dune describe. This command will output a parseable description of every library and executable in the workspace, and for each one the list of modules, the location of each build artifact, dependencies, etc.

A caveat though: this command is experimental and so there is no guarantee of stability. If you find that the command is not providing everything you need or that there is anything to improve, do not hesitate to open an issue over at Issues · ocaml/dune · GitHub.

Hope that helps,
Nicolas

Perfect, this is exactly what I was looking for. Thanks!