Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocamlbuild with findlib + camlp4
[ 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 with findlib + camlp4
Excerpts from romain.bardou's message of Fri Mar 07 10:26:35 +0100 2008:
> > Anyway, ideally one should be able to specify in the _tags file the findlib
> > packages that each ml file depends upon.
> 
> Well, doesn't the following plugin do what you want?

Just to propagate my fixes...

> ###########################
> open Ocamlbuild_plugin
> open Command
> 
> (* list of packages *)
> let packages = ["nums"; "str"; "unix"]
> 
> (* ocamlfind command *)
> let ocamlfind x = S[A"ocamlfind"; x]
> 
> let _ = dispatch begin function
>    | Before_options ->
>        Options.ocamlc := ocamlfind & A"ocamlc";
>        Options.ocamlopt := ocamlfind & A"ocamlopt";
>        Options.ocamldep := ocamlfind & A"ocamldep";
>        Options.ocamldoc := ocamlfind & A"ocamldoc"
>    | After_rules ->
>        flag ["ocaml"; "link"; "linkpkg"] & A"-linkpkg";

The  linkpkg  tag  is  in the way. This does not really make sense to restrict
the  injection  of  -linkpkg  only when the linkpkg tag is present. We want to
put -linkpkg at every ocaml link command.

>        List.iter
>     (fun pkg -> flag ["ocaml"; "pkg_"^pkg] & S[A"-package"; A pkg])

This  too  much,  you  will inject -package pkg also for preprocessing options
for  instance  (-pp  "-package  ...").  You  need  to  restrict  the  scope by
specifying phases (compile,deps,link,doc).

>     packages
>    | _ -> ()
> end
> ###########################

-- 
Nicolas Pouillard aka Ertai