caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocamlbuild with findlib + camlp4
@ 2008-03-05 13:41 Dario Teixeira
  2008-03-05 15:08 ` [Caml-list] " Romain Bardou
  0 siblings, 1 reply; 22+ messages in thread
From: Dario Teixeira @ 2008-03-05 13:41 UTC (permalink / raw)
  To: caml-list

Hi,

I'm trying to create an Ocamlbuild plugin for an application that uses
PG'OCaml.  This library relies on a Camlp4 syntax extension, and comes by
default with a META file for findlib that enables one to simply type on the
command line:

ocamlfind ocamlc -package pgocaml.statements -syntax camlp4o -c test.ml

I still don't grok Ocamlbuild quite enough to automate this behaviour.
The best I have so far is the plugin below; it adds support for findlib, and
creates a "use_pgocaml" tag that explicitly loads all the modules required by
the syntax extension.  Note that "use_pgocaml" makes no use of the findlib
support; while it works, this is of course hackish and ugly.  Ideally,
"use_pgocaml" should simply tell ocamlbuild to use findlib to automatically
load all the modules.

Any ideas on how this could be achieved?  (And incidentally, I vote for
"built-in findlib support" as my #1 wish for Ocamlbuild).

Thanks in advance!
Dario Teixeira


##############################################################################

open Ocamlbuild_plugin
open Command

let ocamlfind x =
        let packages = "pcre,extlib,lwt,ocsigen,pgocaml,json-wheel" 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 ->
                flag ["ocaml"; "link"] (A"-linkpkg");

		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])

        | _ -> ()
end;;

##############################################################################





      ___________________________________________________________ 
Rise to the challenge for Sport Relief with Yahoo! For Good  

http://uk.promotions.yahoo.com/forgood/


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2008-03-11 20:17 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-05 13:41 Ocamlbuild with findlib + camlp4 Dario Teixeira
2008-03-05 15:08 ` [Caml-list] " Romain Bardou
2008-03-06 15:31   ` Dario Teixeira
2008-03-06 15:46     ` Pietro Abate
2008-03-06 19:45       ` Dario Teixeira
2008-03-06 22:14         ` Pietro Abate
2008-03-07  9:26     ` Romain Bardou
2008-03-07 14:46       ` Dario Teixeira
2008-03-07 15:01         ` Nicolas Pouillard
2008-03-07 16:12           ` Dario Teixeira
2008-03-08 11:36             ` Nicolas Pouillard
2008-03-10 15:33               ` Dario Teixeira
2008-03-10 16:15                 ` Romain Bardou
2008-03-10 21:13                   ` Dario Teixeira
2008-03-10 19:56                 ` Arnaud Spiwack
2008-03-10 21:15                   ` Dario Teixeira
2008-03-11 10:37                 ` Nicolas Pouillard
2008-03-11 13:49                   ` Romain Bardou
2008-03-11 15:03                     ` Romain Bardou
2008-03-11 17:32                   ` Dario Teixeira
2008-03-11 20:17                     ` Richard Jones
2008-03-11 10:41       ` Nicolas Pouillard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).