message: ocaml: Generate all relevant source files before running `ocamldep`.
diff: @@ -155,6 +155,29 @@ class Ocamldep(drake.Builder):
  redirect_stdout=self.__target,
  throw=True)
  + def dependencies(self):
  +
  + # Unfortunately, as we rely on the `ocamldep` binary to find such dependencies, we need
  + # generated ml/mli files to be available when it runs or they might be missed (eg a .mly needs
  + # to be processed with menhir first so that a dependency on the parser will be seen by
  + # ocamldep). Thus, we make all .deps files depend on all generated .ml files. This will probably
  + # introduce superfluous dependencies, as not all files require all generated files. To
  + # circumvent this, dependencies detection would have to be reimplemented in a
  + # drake-generated-source aware fashion, as is done for cxx. However this requires a rather deep
  + # semantic understanding of .ml files, much more than parsing '#include <...>'. The current
  + # approach seems a minor setback and a more reasonable implementation for now.
  +
  + for node in drake.Drake.current.nodes.values():
  + if isinstance(node, (Implementation, Interface)):
  + for include in self.__config.include_directories:
  + if node.name().dirname() is include:
  + self.add_dynsrc('ocamldep-need-sources', node)
  +
  +class Dependencies(drake.Node):
  +
  + '''Ocaml dependencies files as generated by ocamldep.'''
  +
  +
  class Compiler(drake.Builder):
  '''OCaml bytecode compiler'''
  @@ -162,7 +185,7 @@ class Compiler(drake.Builder):
  def __init__(self, source, target, toolkit, config):
  self.__config = config
  self.__source = source
  - self.__deps = drake.node(source.name().with_extension(source.name().extension + '.deps'))
  + self.__deps = Dependencies(source.name().with_extension(source.name().extension + '.deps'))
  Ocamldep(self.__source, self.__deps, toolkit, config)
  self.__target = target
  self.__toolkit = toolkit
  