Re: [Caml-list] ocamlbuild and installed modules and libraries

2008-11-17 Thread Daniel Bünzli


Le 16 nov. 08 à 21:37, Nicolas Pouillard a écrit :


I'm a bit uncomfortable with this kind of dynamic or special tags.

However the simplest solution to your problem is probably one of  
those:


 1/ ocamlbuild -cflags -I,+xmlm,xmlm.cmx test.native


You meant,


ocamlbuild -cflags -I,+xmlm -lflags -I,+xmlm,xmlm.cmx test.native



I still think using ocamlbuild with installed libraries/modules is a  
little bit problematic. If we have to do it that way [1] we are hard- 
coding the location of the library in the plugin which doesn't feel  
right.


For me there should be (1) a way of defining the dependency on a  
module/library (hopefully without needing a plugin) and (2) a way of  
defining its location (-I). These two aspects should be decoupled.  
This makes it easier to drive the installation process in build  
scripts by using environment variables, i.e. I just need
to specify the location of the module/library I depend on via a  
suitable -I $DEPDIR to compile the sources.


Best,

Daniel

[1] http://brion.inria.fr/gallium/index.php/Using_an_external_library

___
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


Re: [Caml-list] ocamlbuild and installed modules and libraries

2008-11-17 Thread Romain Bardou

Daniel Bünzli a écrit :


Le 16 nov. 08 à 21:37, Nicolas Pouillard a écrit :


I'm a bit uncomfortable with this kind of dynamic or special tags.

However the simplest solution to your problem is probably one of those:

 1/ ocamlbuild -cflags -I,+xmlm,xmlm.cmx test.native


You meant,


ocamlbuild -cflags -I,+xmlm -lflags -I,+xmlm,xmlm.cmx test.native



I still think using ocamlbuild with installed libraries/modules is a 
little bit problematic. If we have to do it that way [1] we are 
hard-coding the location of the library in the plugin which doesn't feel 
right.


For me there should be (1) a way of defining the dependency on a 
module/library (hopefully without needing a plugin) and (2) a way of 
defining its location (-I). These two aspects should be decoupled. This 
makes it easier to drive the installation process in build scripts by 
using environment variables, i.e. I just need
to specify the location of the module/library I depend on via a suitable 
-I $DEPDIR to compile the sources.


Isn't it almost as simple to write, in a script:
  ocamlbuild -cflags -I,$DEPDIR -lflags -I,$DEPDIR
instead of:
  ocamlbuild -I $DEPDIR
Remember that $DEPDIR must be absolute, or relative to the _build directory.

Then you can use ocamlbuild with the -lib option as usual, in a 
decoupled way. For instance, if bla/bla.cma is in your current directory:


$ ocamlbuild -classic-display -lib bla -cflags -I,../bla -lflags 
-I,../bla test.byte

ocamldep.opt -modules test.ml  test.ml.depends
ocamlc.opt -c -I ../bla -o test.cmo test.ml
ocamlc.opt -I ../bla bla.cma test.cmo -o test.byte

And for modules, instead of -lib bla, you write -lflags bla.cmo or 
-lflags bla.cmx. You can have several -lflags if you want. Unfortunately 
you have to specify the extension, so it is true that a -mod option 
would actually add something.


I admit, though, that it is not really easy to understand how to include 
a library. One solution would be to have findlib in ocamlbuild, but even 
then, there would be problems if you want a Makefile which is supposed 
to work also when findlib is not installed.


I think there is a recent debate about the -I option of Ocamlbuild...

--
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


[Caml-list] ocamlbuild and installed modules and libraries

2008-11-16 Thread Daniel Bünzli

Hello,

Is it possible to specify a single installed module (instead of a lib)  
for link time ? That is is there something like -lib but for module so  
that I can type :


ocamlbuild -I +xmlm -mod xmlm test.native

where test.ml uses the xmlm module

And what about having special tags use_lib_$LIB and use_mod_$MOD that  
automatically create rules to use libraries $LIB.cm(x)a and module  
$MOD.cm(o|x) so that just the appropriate -I to find the files has to  
be specified. In most cases having to use a plugin just for that seems  
overkill. Or is there another way ?


Best,

Daniel

___
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


Re: [Caml-list] ocamlbuild and installed modules and libraries

2008-11-16 Thread Nicolas Pouillard
Excerpts from daniel.buenzli's message of Sun Nov 16 19:22:02 +0100 2008:
 Hello,
 
 Is it possible to specify a single installed module (instead of a lib)  
 for link time ? That is is there something like -lib but for module so  
 that I can type :
 
 ocamlbuild -I +xmlm -mod xmlm test.native
 
 where test.ml uses the xmlm module

This would make sense, but I would prefer not to push things in this
direction. Options like -lib,-cflag,-lflag... are intended to be used
only in a quick hack usage, indeed they are global and tags are much
more powerful.

 And what about having special tags use_lib_$LIB and use_mod_$MOD that  
 automatically create rules to use libraries $LIB.cm(x)a and module  
 $MOD.cm(o|x) so that just the appropriate -I to find the files has to  
 be specified. In most cases having to use a plugin just for that seems  
 overkill. Or is there another way ?

I'm a bit uncomfortable with this kind of dynamic or special tags.

However the simplest solution to your problem is probably one of those:

  1/ ocamlbuild -cflags -I,+xmlm,xmlm.cmx test.native

  2/ ln -s sources-of-xmlm xmlm
 ocamlbuild -I xmlm test.native

  3/ ln -s $(ocamlc -where)/xmlm .
 ocamlbuild -tag_line 'xmlm: not_hygienic' -I xmlm test.native

Hope that helps,

-- 
Nicolas Pouillard aka Ertai

___
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