[Omake] More on ocamldep and generated files.

Aleksey Nogin nogin at cs.caltech.edu
Mon Jun 12 17:09:45 PDT 2006


After thinking some more about this, it seems to me that the problem
lies in ocamldep trying to do two things:

1) ocamldep scans the source file and produces the list of modules that
the file compilation may depends on.

2) ocamldep than takes the resulting list of modules and searches the
filesystem to produce the actual list of dependencies.

Note that the first task is something ocamldep is very good at, this is
something where we _want_ ocamldep (for example, it is fine-tuned to the
specific version of OCaml that is being used).

On the other hand, it is obvious that ocamldep is quite lousy at the
second task. But I would claim the problem is not in ocamldep itself -
the problem is that the second task simply does not truly belong in
ocamldep!

The issue is that the second task is simply ill-specified - that is,
until we know a lot more about the kind of the build setup we have. In a
way, each non-trivial project has its own set of ideas on where each
"foo.cmx" might be coming from. Also, the task of finding a dependency
in the filesystem is not at all language-specific (the fact that the
source files for the specific language happen to have standard
extensions is more of a property of the project being built than of the
OCaml language).

So my proposal would be to:
1) Lobby OCaml maintainers to add a "-modules" flag that would cause
ocamldep to forgo the second step, simply printing out the list of modules.

2) Implement an _internal_ function that would use the output of the
"ocamldep -modules" command to search for a _buildable_ target (using
the full knowledge of the internal build state) in the OCAMLINCLUDES path.

Note that a similar approach should work for all other languages as well!

P.S. In order to be able to do step "2" efficiently, we might need to
make some minor modifications to OMake, but this should not be a problem.

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin at cs.caltech.edu (office), aleksey at nogin.org (personal)
Office: Moore 04, tel: (626) 395-2200


More information about the Omake mailing list