* ocamlbuild and installed modules and libraries @ 2008-11-16 18:22 Daniel Bünzli 2008-11-16 20:37 ` [Caml-list] " Nicolas Pouillard 0 siblings, 1 reply; 5+ messages in thread From: Daniel Bünzli @ 2008-11-16 18:22 UTC (permalink / raw) To: OCaml Mailing List 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild and installed modules and libraries 2008-11-16 18:22 ocamlbuild and installed modules and libraries Daniel Bünzli @ 2008-11-16 20:37 ` Nicolas Pouillard 2008-11-17 9:20 ` Daniel Bünzli 0 siblings, 1 reply; 5+ messages in thread From: Nicolas Pouillard @ 2008-11-16 20:37 UTC (permalink / raw) To: daniel.buenzli; +Cc: caml-list 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild and installed modules and libraries 2008-11-16 20:37 ` [Caml-list] " Nicolas Pouillard @ 2008-11-17 9:20 ` Daniel Bünzli 2008-11-17 9:54 ` Romain Bardou 0 siblings, 1 reply; 5+ messages in thread From: Daniel Bünzli @ 2008-11-17 9:20 UTC (permalink / raw) To: Nicolas Pouillard; +Cc: caml-list 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild and installed modules and libraries 2008-11-17 9:20 ` Daniel Bünzli @ 2008-11-17 9:54 ` Romain Bardou 2008-11-17 10:07 ` Daniel Bünzli 0 siblings, 1 reply; 5+ messages in thread From: Romain Bardou @ 2008-11-17 9:54 UTC (permalink / raw) To: Daniel Bünzli; +Cc: Nicolas Pouillard, caml-list 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild and installed modules and libraries 2008-11-17 9:54 ` Romain Bardou @ 2008-11-17 10:07 ` Daniel Bünzli 0 siblings, 0 replies; 5+ messages in thread From: Daniel Bünzli @ 2008-11-17 10:07 UTC (permalink / raw) To: caml-list List Le 17 nov. 08 à 10:54, Romain Bardou a écrit : > 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. Yes, I can live with that. > 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. That is the point, from my perspective the problem is solved for libraries but not for single modules. Daniel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-11-17 10:08 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-11-16 18:22 ocamlbuild and installed modules and libraries Daniel Bünzli 2008-11-16 20:37 ` [Caml-list] " Nicolas Pouillard 2008-11-17 9:20 ` Daniel Bünzli 2008-11-17 9:54 ` Romain Bardou 2008-11-17 10:07 ` Daniel Bünzli
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox