* [Caml-list] ocamlbuild plugins and external libraries
@ 2013-12-10 22:20 Gregory Malecha
2013-12-11 6:03 ` Gabriel Scherer
0 siblings, 1 reply; 3+ messages in thread
From: Gregory Malecha @ 2013-12-10 22:20 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]
Hello --
I have several ocamlbuild plugins that are very similar and I'm trying to
figure out how to refactor them. I pulled out a bunch of definitions into
another file (coq_paths.ml) and then said 'open Coq_paths' in '
myocamlbuild.ml'. But when I do this, ocamlbuild can no longer build the
plugin, not even if foo.cmo already exists in the _build directory.
After hacking on this for a long time (and digging through the ocamlbuild
sources) I found that you can write a Makefile that will build
myocamlbuild.cmo using ocamlbuild without a plugin, and then manually link
this against ocamlbuild.cmo and to produce a custom version of ocamlbuild
that uses the plugin (this is exactly what ocamlbuild does). My question
is: 'is there any nicer way to do this?' I'm including my Makefile below:
OCAMLBUILDDIR=$(shell ocamlfind query ocamlbuild)
all: _build/coq_builder
@ ./_build/coq_builder -no-plugin coq.otarget
_build/coq_builder: myocamlbuild.ml coq_paths.ml
@ echo "building builder...."
@ ocamlbuild -cflags -I,`ocamlfind query ocamlbuild` -no-plugin
myocamlbuild.cmo
@ ocamlc.opt unix.cma -I $(OCAMLBUILDDIR)
$(OCAMLBUILDDIR)/ocamlbuildlib.cma \
_build/coq_paths.cmo _build/myocamlbuild.cmo \
$(OCAMLBUILDDIR)/ocamlbuild.cmo -o _build/coq_builder
@ echo "done"
clean:
ocamlbuild -clean
Thanks in advance.
--
gregory malecha
http://www.people.fas.harvard.edu/~gmalecha/
[-- Attachment #2: Type: text/html, Size: 2863 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] ocamlbuild plugins and external libraries
2013-12-10 22:20 [Caml-list] ocamlbuild plugins and external libraries Gregory Malecha
@ 2013-12-11 6:03 ` Gabriel Scherer
2013-12-11 20:27 ` Gregory Malecha
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Scherer @ 2013-12-11 6:03 UTC (permalink / raw)
To: Gregory Malecha; +Cc: caml users
[-- Attachment #1: Type: text/plain, Size: 1895 bytes --]
Since 4.01, ocamlbuild supports a new (experimental) option "-plugin-tag"
that allows to specify (built-in) ocamlbuild tags to use when compiling
myocamlbuild.ml. If you package coq-paths using findlib, you can then use
ocamlbuild -use-ocamlfind -plugin-tag "package(coq-path)" ...
On Tue, Dec 10, 2013 at 11:20 PM, Gregory Malecha
<gmalecha@cs.harvard.edu>wrote:
> Hello --
>
> I have several ocamlbuild plugins that are very similar and I'm trying to
> figure out how to refactor them. I pulled out a bunch of definitions into
> another file (coq_paths.ml) and then said 'open Coq_paths' in '
> myocamlbuild.ml'. But when I do this, ocamlbuild can no longer build the
> plugin, not even if foo.cmo already exists in the _build directory.
>
> After hacking on this for a long time (and digging through the ocamlbuild
> sources) I found that you can write a Makefile that will build
> myocamlbuild.cmo using ocamlbuild without a plugin, and then manually link
> this against ocamlbuild.cmo and to produce a custom version of ocamlbuild
> that uses the plugin (this is exactly what ocamlbuild does). My question
> is: 'is there any nicer way to do this?' I'm including my Makefile below:
>
> OCAMLBUILDDIR=$(shell ocamlfind query ocamlbuild)
>
> all: _build/coq_builder
> @ ./_build/coq_builder -no-plugin coq.otarget
>
> _build/coq_builder: myocamlbuild.ml coq_paths.ml
> @ echo "building builder...."
> @ ocamlbuild -cflags -I,`ocamlfind query ocamlbuild` -no-plugin
> myocamlbuild.cmo
> @ ocamlc.opt unix.cma -I $(OCAMLBUILDDIR)
> $(OCAMLBUILDDIR)/ocamlbuildlib.cma \
> _build/coq_paths.cmo _build/myocamlbuild.cmo \
> $(OCAMLBUILDDIR)/ocamlbuild.cmo -o _build/coq_builder
> @ echo "done"
>
> clean:
> ocamlbuild -clean
>
> Thanks in advance.
>
> --
> gregory malecha
> http://www.people.fas.harvard.edu/~gmalecha/
>
[-- Attachment #2: Type: text/html, Size: 3760 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] ocamlbuild plugins and external libraries
2013-12-11 6:03 ` Gabriel Scherer
@ 2013-12-11 20:27 ` Gregory Malecha
0 siblings, 0 replies; 3+ messages in thread
From: Gregory Malecha @ 2013-12-11 20:27 UTC (permalink / raw)
To: Gabriel Scherer; +Cc: caml users
[-- Attachment #1: Type: text/plain, Size: 2217 bytes --]
Thanks Gabriel --
I couldn't figure out how to get the package included, which you do with
-use-ocamlfind.
On Wed, Dec 11, 2013 at 1:03 AM, Gabriel Scherer
<gabriel.scherer@gmail.com>wrote:
> Since 4.01, ocamlbuild supports a new (experimental) option "-plugin-tag"
> that allows to specify (built-in) ocamlbuild tags to use when compiling
> myocamlbuild.ml. If you package coq-paths using findlib, you can then use
>
> ocamlbuild -use-ocamlfind -plugin-tag "package(coq-path)" ...
>
>
> On Tue, Dec 10, 2013 at 11:20 PM, Gregory Malecha <gmalecha@cs.harvard.edu
> > wrote:
>
>> Hello --
>>
>> I have several ocamlbuild plugins that are very similar and I'm trying to
>> figure out how to refactor them. I pulled out a bunch of definitions into
>> another file (coq_paths.ml) and then said 'open Coq_paths' in '
>> myocamlbuild.ml'. But when I do this, ocamlbuild can no longer build the
>> plugin, not even if foo.cmo already exists in the _build directory.
>>
>> After hacking on this for a long time (and digging through the ocamlbuild
>> sources) I found that you can write a Makefile that will build
>> myocamlbuild.cmo using ocamlbuild without a plugin, and then manually link
>> this against ocamlbuild.cmo and to produce a custom version of ocamlbuild
>> that uses the plugin (this is exactly what ocamlbuild does). My question
>> is: 'is there any nicer way to do this?' I'm including my Makefile below:
>>
>> OCAMLBUILDDIR=$(shell ocamlfind query ocamlbuild)
>>
>> all: _build/coq_builder
>> @ ./_build/coq_builder -no-plugin coq.otarget
>>
>> _build/coq_builder: myocamlbuild.ml coq_paths.ml
>> @ echo "building builder...."
>> @ ocamlbuild -cflags -I,`ocamlfind query ocamlbuild` -no-plugin
>> myocamlbuild.cmo
>> @ ocamlc.opt unix.cma -I $(OCAMLBUILDDIR)
>> $(OCAMLBUILDDIR)/ocamlbuildlib.cma \
>> _build/coq_paths.cmo _build/myocamlbuild.cmo \
>> $(OCAMLBUILDDIR)/ocamlbuild.cmo -o _build/coq_builder
>> @ echo "done"
>>
>> clean:
>> ocamlbuild -clean
>>
>> Thanks in advance.
>>
>> --
>> gregory malecha
>> http://www.people.fas.harvard.edu/~gmalecha/
>>
>
>
--
gregory malecha
http://www.people.fas.harvard.edu/~gmalecha/
[-- Attachment #2: Type: text/html, Size: 4630 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-11 20:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 22:20 [Caml-list] ocamlbuild plugins and external libraries Gregory Malecha
2013-12-11 6:03 ` Gabriel Scherer
2013-12-11 20:27 ` Gregory Malecha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox