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: Romain Bardou <Romain.Bardou@l...>
Subject: Re: [Caml-list] Ocamlbuild with findlib + camlp4
Hello,

> 		let root = "/home/dario/.godi/lib/ocaml/" in
>                 let str = root ^ "std-lib/str.cma"
>                 and pcre = root ^ "pkg-lib/pcre/pcre.cma"
>                 and extlib = root ^ "pkg-lib/extlib/extLib.cma"
>                 and calendar = root ^ "pkg-lib/calendar/calendar.cma"
>                 and csv = root ^ "pkg-lib/csv/csv.cma"
>                 and pgocaml = root ^ "site-lib/pgocaml/pgocaml.cma"
>                 and pa_pgsql = root ^ "site-lib/pgocaml/pa_pgsql.cmo" in
>                 flag ["ocaml"; "pp"; "use_pgsql"] (S[A str; A pcre; A extlib; A
> calendar; A csv; A pgocaml; A pa_pgsql])

It seems to me that this lines are useless if you use ocamlfind, because 
you:
- changed the ocamlc, ocamlopt and ocamldep variables
- added the -linkpkg option when linking
So normally you shouldn't even have to deal with cma files. Well, at 
least if they have META files.

Moreover, these lines mean that packages str and so on will only be used 
when your files are tagged with use_pgsql. Is it really what you want?

You did nothing to add the "-syntax camlp4o" option.

I have no experience of ocamlbuild with camlp4 extensions but I guess in 
your case I would list all packages correctly in the "let packages = 
..." definition (unless you don't want to add the -package option for 
every file?), tag my files which use the camlp4 extension with 
"use_pgsql", and add a flag such as:

flag ["ocaml"; "use_pgsql"] (S[A "-syntax"; A "camlp4o"])

You could also add the package pgocaml.statements only when using this flag:

flag ["ocaml"; "use_pgsql"] (S[A "-package"; A "pgocaml.statements"])

If you do this you don't have to add the pgocaml.statements package in 
the "let packages = ..." definition of your plugin.

Basically I think what you need is a combination of the two following 
examples from the Wiki:
http://brion.inria.fr/gallium/index.php/A_plugin_for_camlp4_syntax_extension_%28pa_openin%29
http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild

-- 
Romain Bardou