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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL 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 473E5BC6C for ; Mon, 28 Jan 2008 15:25:51 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.25,260,1199660400"; d="scan'208";a="6657891" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail2-relais-roc.national.inria.fr with SMTP; 28 Jan 2008 15:25:51 +0100 Received: by ausone.inria.fr (sSMTP sendmail emulation); Mon, _d Jan 2008 15:24:47 +0100 From: "Nicolas Pouillard" Content-Type: text/plain; charset=UTF-8 Cc: caml-list Subject: Re: [Caml-list] ocamlbuild `Circular dependencies' To: christian.sternagel References: <20080124142327.GC761@pc6197-c703.uibk.ac.at> <479DAD21.9040300@lri.fr> <20080128104309.GA3836@pc6197-c703.uibk.ac.at> In-Reply-To: <20080128104309.GA3836@pc6197-c703.uibk.ac.at> Date: Mon, 28 Jan 2008 15:24:47 +0100 Message-Id: <1201526011-sup-1368@ausone.inria.fr> User-Agent: Sup/git X-Spam: no; 0.00; 0100,:01 mli:01 ocamldep:01 makefile:01 dependencies:01 computed:01 dirs:01 foo:01 foo:01 compilation:01 flags:01 ocaml:01 byte:01 ocaml:01 lib:01 Excerpts from christian.sternagel's message of Mon Jan 28 11:43:09 +0100 2008: > On Mon, Jan 28, 2008 at 11:23:29AM +0100, Romain Bardou wrote: > > I tried to reproduce a similar set of directories as yours. I couldn't > > get the "circular dependency" error, but I had to compile everything in > > one command line, otherwise the file a.cma (which is in the _build/A > Today I found out, that we indeed had a circular dependency: > > An interface file B.mli used a type A.t, whereas the implementation > file A.ml uses functions from B. When using ocamldep + a Makefile, no > error occurred. But ocamlbuild refused to compile... I guess that is > the right thing to do =) Yes ocamlbuild treats your module (interface + implementation) as a whole. Then dependencies are computed for modules, so you are in a case that could be compiled but ocamlbuild will refuse it. I'm a bit reluctant to change this, since I think that the right thing to do is to avoid this kind of semi-cycles. > > directory) was deleted before compiling b.cma. The command which I used > > and which worked is: > > > > ocamlbuild -Is A,B a.cma b.cma > > > > I don't really understand how the -lib option works though. Where and > > when does it look for the library x.cma with the "-lib x" option? How > > and what's the semantic of the "+" you can add at the beginning of a > > library name?... > As far as I know, a `+' means that the following name should be searched > relative to the standard library. All ocamlbuild include directories must be implicit and relative to the current dir. So dirs like ../foo, /foo, +foo, ./foo are forbidden. You can make symbolic link to avoid the two first cases. If you really need to give +foo dir, please use non-interpreted compilation flags like -cflags for the command line and tags like ["ocaml"; "compile"] for a tag based approach. > Still my question remains, how one should configure a project > that consists of several libraries and one binary, together > with ocamlbuild. E.g., > > +- prof.dir/ > +-+- A/ > | +- a.mllib > | +- a1.ml > | +- ... > | +- aN.ml > | > +-+- B/ > | +- b.mllib > | +- b1.ml > | +- ... > | +- bN.ml > | > +-+- Main/ > +- main.ml (depending on a.cma and b.cma) The simplest thing to do is what you've tried (ocamlbuild -Is A,B Main/main.byte). But here your mllib's are not used. If you want to use them as libraries you need a small myocamlbuild.ml like: $ cat myocamlbuild.ml open Ocamlbuild_plugin;; dispatch begin function | After_rules -> ocaml_lib "A/a"; ocaml_lib "B/b" | _ -> () end And to tag your files: $ cat _tags # tells that main use a and b libs
: use_a, use_b # this will avoid the need of command line options to ocamlbuild "A" or "B": include $ ocamlbuild Main/main.byte Cheers, PS: I've just updated the wiki [1] [1]: http://brion.inria.fr/gallium/index.php/Using_internal_libraries -- Nicolas Pouillard aka Ertai