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