MPR#5227: possibility to call ocamlbuild from a sub-directory
PR transferred from https://caml.inria.fr/mantis/view.php?id=5227 [original reporter: Daniel Weil]
I'm working on a multi-directory project for example :
+-+- A/
| +- a1.ml
| +- ...
| +- aN.ml
|
+-+- B/
| +- b1.ml
| +- ...
| +- bN.ml
|
+-+- Main/
+- main.ml (depending on a.cma and b.cma)
So far, the only way to compile my project is to call ocamlbuild from root directory.
While I'm editing b1.ml in directory B, I would like to compile it with the command ocamlbuild b1.cmo. This is not possible so far : I have to go in root directory and type ocamlbuild B/b1.ml.
My wish would be something like a -root option to specify from which parent directory ocamlbuild should be called.
Not something I am planning to implement in the near future (I personally think that cd .. ; ocamlbuild ... is good enough), but pull requests are welcome.
If we had a more canonical notion of "project file", like .merlin for Merlin, we could also implement the logic of looking upward the directory tree to find the root. But we don't have that -- neither myocamlbuild.ml nor _tags are reliably present in ocamlbuild-using projects.
IIRC, the usability problem is with emacs: if we do M-x compile and enter cd ..; ocamlbuild as the compilation command, emacs is likely to be confused by relative paths in the error messages (it thinks they are relative to . but they are relative to ..