* ocamlbuild `Circular dependencies' @ 2008-01-24 14:23 Christian Sternagel 2008-01-28 10:23 ` [Caml-list] " Romain Bardou 0 siblings, 1 reply; 5+ messages in thread From: Christian Sternagel @ 2008-01-24 14:23 UTC (permalink / raw) To: caml-list I use the following setting for a project: Within the root directory of the project there are two subdirectories A and B containing *.ml, *.mli, and *.mly files. additionally there is the file A.mllib in A containing all modules that are in A and B.mllib containing all modules that are in B. ocamlbuild -I A A.cma works fine. Now B should also result in a lib where some modules in B depend on modules in A. When trying ocamlbuild -lib A -Is A,B B.cma the compilation terminates unsuccessful indicating some Circular dependencies. However, the Makefile we used before works fine and there really are no circular dependencies. Am I doing something completely wrong here? Isn't it possible to compile libraries depending on other libraries? cheers christian ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild `Circular dependencies' 2008-01-24 14:23 ocamlbuild `Circular dependencies' Christian Sternagel @ 2008-01-28 10:23 ` Romain Bardou 2008-01-28 10:43 ` Christian Sternagel 0 siblings, 1 reply; 5+ messages in thread From: Romain Bardou @ 2008-01-28 10:23 UTC (permalink / raw) To: caml-list 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 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?... -- Romain Bardou ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild `Circular dependencies' 2008-01-28 10:23 ` [Caml-list] " Romain Bardou @ 2008-01-28 10:43 ` Christian Sternagel 2008-01-28 11:08 ` Romain Bardou 2008-01-28 14:24 ` Nicolas Pouillard 0 siblings, 2 replies; 5+ messages in thread From: Christian Sternagel @ 2008-01-28 10:43 UTC (permalink / raw) To: caml-list 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 =) > 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. 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) cheers christian > > -- > Romain Bardou > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild `Circular dependencies' 2008-01-28 10:43 ` Christian Sternagel @ 2008-01-28 11:08 ` Romain Bardou 2008-01-28 14:24 ` Nicolas Pouillard 1 sibling, 0 replies; 5+ messages in thread From: Romain Bardou @ 2008-01-28 11:08 UTC (permalink / raw) To: caml-list > 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) Well, is it a problem to compile using: ocamlbuild -Is A,B,Main main.byte If you really want to build libraries independently then maybe you could build the cma files, copy them in a "lib" directory which won't be included by ocamlbuild (because of "sanitization" restrictions) and then use the "-lib" option to use "lib/a.cma" and "lib/b.cma"... The script would look like this, supposing B depends on A and Main depends on A and B (not tested): #!/bin/sh ocamlbuild -I A a.cma cp _build/A/a.cma lib ocamlbuild -lib lib/a -I B b.cma cp _build/B/b.cma lib ocamlbuild -libs lib/a,lib/b -I Main main.byte -- Romain Bardou ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild `Circular dependencies' 2008-01-28 10:43 ` Christian Sternagel 2008-01-28 11:08 ` Romain Bardou @ 2008-01-28 14:24 ` Nicolas Pouillard 1 sibling, 0 replies; 5+ messages in thread From: Nicolas Pouillard @ 2008-01-28 14:24 UTC (permalink / raw) To: christian.sternagel; +Cc: caml-list 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 <Main/main.{byte,native}>: 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-01-28 14:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-01-24 14:23 ocamlbuild `Circular dependencies' Christian Sternagel 2008-01-28 10:23 ` [Caml-list] " Romain Bardou 2008-01-28 10:43 ` Christian Sternagel 2008-01-28 11:08 ` Romain Bardou 2008-01-28 14:24 ` Nicolas Pouillard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox