Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocamlbuild plugins
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Ocamlbuild plugins
Excerpts from Dario Teixeira's message of Wed Nov 07 14:39:19 +0100 2007:
> Hi,
> 
> > (...)
> > Sadly you're right. As always any help/contribution will be appreciated :)
> 
> Well, I'll do my part: once I grok Ocamlbuild I'll profusely document
> the myocamlbuild.ml for my project.
> 
> Anyway, thanks again for your help.  I have at the moment a myocamlbuild.ml
> that can handle almost everything I need; the only bit that isn't working
> is precisely the part that handles camlp4.  So, here's the myocamlbuild.ml:
> ______________________________________________________________
> 
> open Ocamlbuild_plugin
> open Command
> 
> let ocamlfind x =
>         let packages = "calendar, ocsigen" in
>         S[A "ocamlfind"; x; A "-package"; A packages];;
> 
> dispatch begin function
>         | Before_options ->
>              Options.ocamlc := ocamlfind & A"ocamlc";
>              Options.ocamlopt := ocamlfind & A"ocamlopt";
>              Options.ocamldep := ocamlfind & A"ocamldep"
>         | After_rules ->
>                 let some_flags = S[A"-package"; A"pgocaml.statements";
> A"-syntax"; A"camlp4o"] in
>                 flag ["ocaml"; "compile"; "use_pgocaml_statements"] 
> some_flags;
>                 flag ["ocaml"; "ocamldep"; "use_pgocaml_statements"]
> some_flags;
>                 flag ["ocaml"; "link"] (A"-linkpkg")
>         | _ -> ()
> end;;
> ______________________________________________________________
> 
> I also have a _tags file with just one line:
> "database.ml": use_pgocaml_statements, thread
> 
> And this is the error I get when I run "ocamlbuild database.cmo":
> ______________________________________________________________
> 
> + ocamlfind ocamldep -package 'calendar, ocsigen' -package pgocaml.statements
> -syntax camlp4o -pp '-package pgocaml.statements -syntax camlp4o' -modules
> database.ml > database.ml.depends
> Warning: -pp overrides the effect of -syntax partly
> sh: Illegal option -p
> Preprocessing error on file database.ml
> Command exited with code 2.

Arg  too bad, that's an ocamlbuild bug. I didn't see it since I always use -pp
and not -syntax of ocamlfind.

You should try to use the .cmo of your syntax extension.
Use these declarations and replace pa_openin.cmo by the cmo of pgocaml.statements.

(* One add pa_openin.cmo to the ocaml pre-processor when use_opening is set *)
flag ["ocaml"; "pp"; "use_openin"] (A"pa_openin.cmo");

(* Running ocamldep on ocaml code that is tagged use_openin will require the cmo *)
dep ["ocaml"; "ocamldep"; "use_openin"] ["pa_openin.cmo"];

Let me know if it works...
-- 
Nicolas Pouillard aka Ertai