I am beginning to think along those lines. Rather than just using top-modules and letting ocamldep guess dependencies, specifying them seems inherently more reliable and predictable. Maybe with something like an import statement. If this is done in each file, it should scale easily. Two things that might be related: - putting more build information in ml files (I recall that Gabriel Scherer mentioned that once, is that right?) - namespaces. More generally, I identify the following problems when building OCaml code: - under-specified dependencies, as discussed - the compiler driver can produce multiple files on a single invocation. File level dependencies turn into an hypergraph rather than a graph (making a Makefile driven system hardly stable) - an ML file alone is hard to understand out of context, because build specification are kept separate - many names and partially overlapping concepts; top-modules, libraries, ocamlfind packages, opam packages. On 07/11/2016 03:15 PM, Martin DeMello wrote: > On Sun, Jul 10, 2016 at 4:03 AM, Gerd Stolpmann > > wrote: > > So how to fix this? In my opinion there are two solutions. You can > either have a more intelligent ocamldep (e.g. one that reads in > non-local cmi files and uses that information and also tries to > interpret all project ml files at once and not file by file - btw, did > anybody check whether there is an algorithm that precisely solves the > problem?). The other solution path is to mark toplevel modules in the > syntax of OCaml (e.g. you'd have to do "open ^M2" is M2 is a toplevel > module). > > > Would an acceptable third option be to simply record the dag > explicitly in your build file? Working with google's build system > [opensourced as bazel: http://www.bazel.io/] has given me a great > appreciation for simply writing out build dependencies manually; sure, > it is relatively tedious to have to write out the graph yourself > rather than have ocamldep figure it out, but the time and effort to do > so is a small fraction of the overall development time of your > project, and the reward is a 100% reliable "detection" of the build > topology. > > martin