From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 3E041BBAF for ; Tue, 30 Sep 2008 12:41:02 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak0DABuf4UjAXQImiGdsb2JhbACLcodPAQEBFSKhS4d+gWc X-IronPort-AV: E=Sophos;i="4.33,337,1220220000"; d="asc'?scan'208";a="15499488" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 30 Sep 2008 12:41:02 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m8UAf1cj012140 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 30 Sep 2008 12:41:01 +0200 X-IronPort-AV: E=Sophos;i="4.33,337,1220220000"; d="asc'?scan'208";a="17928173" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with SMTP; 30 Sep 2008 12:41:01 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Tue, _d Sep 2008 12:40:18 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: OCamlBuild question To: "david.teller" References: <1222759631.6764.4.camel@Blefuscu> In-Reply-To: <1222759631.6764.4.camel@Blefuscu> Date: Tue, 30 Sep 2008 12:40:12 +0200 Message-Id: <1222770687-sup-2064@ausone.local> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1222771218-117073-24350-126-4-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Miltered: at discorde with ID 48E2023D.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; mli:01 mli:01 foo:01 ad-hoc:01 statically:01 deps:01 deps:01 dirs:01 pathname:01 dirs:01 pathname:01 dirname:01 ocaml:01 plug-in:98 dynamically:01 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1222771218-117073-24350-126-4-= Content-Type: text/plain; charset=UTF-8 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 --=-1222771218-117073-24350-126-4-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkjiAgwACgkQj+FCNw9dwLnIfACfezYoqiD/wTtT7VNXuKX3Y9VK lB0An1nJXd6BjZ9hSmQPyE7raI38ei6a =ZNtA -----END PGP SIGNATURE----- --=-1222771218-117073-24350-126-4-=--