Path of spotted location in file is not converted back to source directory when an .ocamlspot file is used.

Issue #37 resolved
Koen De Keyser
created an issue

This is a follow up to issue 34. The .ocamlspot file is now used to convert the path of a source file to the build directory specified in the .ocamlspot file, but the resulting spotted location is not converted back from the build directory to the source directory.

E.g. I've got a source directory at /home/koen/Code/bugfix/src/ocaml, which contains subdirectories as well. Build results are produced in /home/koen/Code/bugfix/build/debug/ocaml/dss_exe.

In /home/koen/Code/bugfix/src/ocaml. I've placed a .ocamlspot file with: build_dir=../../build/debug/ocaml/dss_exe

When running ocamlspot on a source file, I get:

./ocamlspot /home/koen/Code/bugfix/src/ocaml/client/
comp_dir: /home/koen/Code/bugfix/src/ocaml/client => /home/koen/Code/bugfix/build/debug/ocaml/dss_exe/client
load /home/koen/Code/bugfix/build/debug/ocaml/dss_exe/client/Client_put.cmt
Use: Value, EncryptionInfo__0.create__0
Type: EncryptionAdditionalData.t -> EncryptionPolicy.t -> EncryptionInfo.t;
XType: EncryptionAdditionalData.t__G ->
       EncryptionPolicy.t__G -> EncryptionInfo.t__G;
At: Expr;
Tree: l442c18b25695:l442c39b25716
XTree: </home/koen/Code/bugfix/build/debug/ocaml/dss_exe/client/>
Val: val EncryptionInfo.create : EncryptionAdditionalData.t ->
                                 EncryptionPolicy.t -> EncryptionInfo.t
comp_dir: /home/koen/Code/bugfix/build/debug/ocaml/dss_exe/encryption => /home/koen/Code/bugfix/_build/build/debug/ocaml/dss_exe/encryption
Spot: </home/koen/Code/bugfix/build/debug/ocaml/dss_exe/encryption/>

--> the path given by "Spot" still points to the build results and not to the original source file in /home/koen/Code/bugfix/src/ocaml. Changes made to this file will thus be lost when building.

My initial suspicion was that the issue is caused by the final call to comp_dir. i.e: comp_dir: /home/koen/Code/bugfix/build/debug/ocaml/dss_exe/encryption => /home/koen/Code/bugfix/_build/build/debug/ocaml/dss_exe/encryption To execute that call, ocamlspot will try to load a .ocamlspot file from the build directory, and not from the original source directory. Because there is no .ocamlspot file there, it defaults to the standard ocamlbuild _build convention. I verified this by adding a .ocamlspot file to the build directory which does the reverse mapping (i.e. build to source): build_dir=../../../../src/ocaml

Then, the output from ocamlspot becomes:

... (same as first try) ...
comp_dir: /home/koen/Code/bugfix/build/debug/ocaml/dss_exe/encryption => /home/koen/Code/bugfix/src/ocaml/encryption
Spot: </home/koen/Code/bugfix/build/debug/ocaml/dss_exe/encryption/>

So it indeed reads the .ocamlspot file in the build directory and then does the translation, but it is not used by the "Spot: " output.

The behavior that I would expect is: the .ocamlspot file is only read from the source directory, and consists of the build results path. From this, the reverse relation between build and source paths is generated, which is then used to convert back the spotted location. Is this indeed a bug or am I missing something?

Comments (5)

  1. Log in to comment