Hi,
When using dune, is there a simple way to locate the .cmt[i] file for a given .ml[i] file ? (Parsing output of dune describe
is not a simple way)
Hi,
When using dune, is there a simple way to locate the .cmt[i] file for a given .ml[i] file ? (Parsing output of dune describe
is not a simple way)
I agree that dune describe
is not a satisfying solution.
What I have done in the past is to traverse the _build
directory iterating over every .cmt
file found there. The corresponding source file can be found in the cmt_sourcefile
field of the cmt_infos
record that is stored in the .cmt
file. Of course this approach may not be useful depending on what you are trying to achieve.
Cheers,
Nicolas
Thanks for your answer.
I want to load a .cmt file for example to display type information in my editor (Chamo). Indeed the solution you propose is the one I’m heading to, using the most recently modified .cmt file If I find more than one.
Alternatively you could query Dune for the Merlin configuration for that specific file:
$ FILE=src/main.ml
$ echo "(4:File${#FILE}:$FILE)" | dune ocaml-merlin
The output is a CSEXP containing a list of potential paths in which the .cmt
file could be.
(or you could query Merlin directly for type information)
Thanks. I do not use merlin, though.
In fact, the source filename in the .cmt
file may not be the original one, for example when some preprocessing is required, dune will rename foo.ml
to foo.pp.ml