From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "david.teller" <david.teller@univ-orleans.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: OCamlBuild question
Date: Tue, 30 Sep 2008 12:40:12 +0200 [thread overview]
Message-ID: <1222770687-sup-2064@ausone.local> (raw)
In-Reply-To: <1222759631.6764.4.camel@Blefuscu>
[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
next prev parent reply other threads:[~2008-09-30 10:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-30 7:27 David Teller
2008-09-30 10:40 ` Nicolas Pouillard [this message]
2008-09-30 14:49 ` David Teller
2008-09-30 15:12 ` David Teller
2009-02-11 22:26 Ocamlbuild question Matthieu Dubuget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1222770687-sup-2064@ausone.local \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@inria.fr \
--cc=david.teller@univ-orleans.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox