[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Nicolas Pouillard <nicolas.pouillard@g...> |
| Subject: | Re: OCamlBuild question |
Excerpts from david.teller's message of Tue Sep 30 09:27:11 +0200 2008:
> Hi everyone,
> I'm trying to write a OCamlBuild plug-in to automatically generate
> the .mli corresponding to a .mlpack (for documentation purposes).
>
> I've written a [rule] which lets me depend a .mli on the
> corresponding .mlpack . From this .mlpack, I can obtain the list of
> modules involved in the construction of the pack. Now, I only have to
> 1. find the corresponding source .mli files
> 2. find the corresponding .mli.depends files
> 3. do a topological sort and create the destination .mli .
>
> Part 3 is no problem. On the other hand, I haven't been able to progress
> much with parts 1 and 2.
>
> Part 2 requires waiting until the corresponding .mli.depends have been
> created, but
> * neither [~insert:`bottom] nor [~insert:(`after foo)] seem to help here
> * attempting to [build] an ad-hoc list of files somehow extracted from
> the mlpack only gives me dependency errors
> * attempting [Solve.solve_target] doesn't seem to help any further.
If you need (depend) on files that you statically know then the ~deps argument
is fine (~deps:["%.mli.depends"; "%.mli"]). If you need files that you only
know dynamically then the 'build' argument function is for that purpose.
> As for part 1, it requires the ability to find which source .ml / .mli
> correspond to a given module. I can only assume OCamlBuild offers some
> kind of API for this purpose, because I'd rather avoid folding through
> the whole tree, resolving [include] directives myself to find a .ml or
> a .mli which may be the right file.
Yes the function is called expand_module it takes 3 arguments, the include
directories, the module name, the extensions.
Example: let include_dirs = Pathname.include_dirs_of (Pathname.dirname mlpack)
in build (expand_module include_dirs module_name ["mli"; "mli.depends"])
Have a look to the ocamlbuild/ocaml_tools.ml file for a similar function
(import_mlypack).
--
Nicolas Pouillard aka Ertai