From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id D2835BBC1 for ; Thu, 6 Mar 2008 23:14:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtEAAP76z0eGnQCBhmdsb2JhbACQeAEBAQgEBgcIGJtS X-IronPort-AV: E=Sophos;i="4.25,458,1199660400"; d="scan'208";a="23458284" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Mar 2008 23:14:10 +0100 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.2/jtpda-5.4) with ESMTP id m26ME8mv089238 for ; Thu, 6 Mar 2008 23:14:09 +0100 (CET) X-Ids:165 Received: from hydrogene.pps.jussieu.fr (localhost.localdomain [127.0.0.1]) by hydrogene.pps.jussieu.fr (8.13.4/jtpda-5.4) with ESMTP id m26ME7In000353 for ; Thu, 6 Mar 2008 23:14:07 +0100 Received: (from abate@localhost) by hydrogene.pps.jussieu.fr (8.13.4/8.13.2/Submit) id m26ME7eo000352 for caml-list@yquem.inria.fr; Thu, 6 Mar 2008 23:14:07 +0100 Date: Thu, 6 Mar 2008 23:14:07 +0100 From: Pietro Abate To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Ocamlbuild with findlib + camlp4 Message-ID: <20080306221407.GA31976@uranium.pps.jussieu.fr> References: <20080306154625.GA5148@uranium.pps.jussieu.fr> <182204.66150.qm@web54607.mail.re2.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <182204.66150.qm@web54607.mail.re2.yahoo.com> X-Operating-System: GNU/Linux User-Agent: Mutt/1.5.9i X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (shiva.jussieu.fr [134.157.0.165]); Thu, 06 Mar 2008 23:14:09 +0100 (CET) X-Virus-Scanned: ClamAV 0.92/6154/Thu Mar 6 17:41:42 2008 on shiva.jussieu.fr X-Virus-Status: Clean X-Miltered: at jchkmail.jussieu.fr with ID 47D06CB0.00F by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 47D06CB0.00F/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-j-chkmail-Score: MSGID : 47D06CB0.00F on jchkmail.jussieu.fr : j-chkmail score : . : R=. U=. O=. B=0.048 -> S=0.048 X-j-chkmail-Status: Ham X-Spam: no; 0.00; findlib:01 camlp:01 findlib:01 syntax:01 syntax:01 ocamlfind:01 foo:01 ocamlfind:01 camlp:01 sqrt:01 acos:01 foo:01 -package:01 ocamlc:01 ocamlc:01 On Thu, Mar 06, 2008 at 07:45:05PM +0000, Dario Teixeira wrote: > Thanks for the help. I see -- essentially you're just telling Ocamlbuild > to ignore findlib when dealing with syntax extensions. Unfortunately > it's not working: the database.ml file never seems to be compiled. Moreover, > the core of the problem remains: if we're ever going to simplify the use of > syntax extensions, we must somehow tell Ocamlbuild to use findlib. Any > other thoughts? bar.ml is your database module that uses a syntax extension and str is loaded via ocamlfind in foo.ml. I guess there is a better way to use ocamlfind more selectively. For example I don't need to use ocamlfind to compile the syntax extension. hope this helps. pietro #####$cat _tags "pa_float.ml": use_camlp4, pp(camlp4of) "bar.ml": camlp4o, use_float #####$cat bar.ml let x = Float.( 3/2 - sqrt (1/3) ) let f x = Float.( let pi = acos(-1) in x/(2*pi) - x**(2/3) ) #####$cat foo.ml open Str let x = Bar.x #####$cat myocamlbuild.ml open Ocamlbuild_plugin;; open Command;; let packages = "str";; let ocamlfind x = S[A"ocamlfind"; x; A"-package"; A packages];; dispatch begin function | Before_options -> Options.ocamlc := ocamlfind& A"ocamlc"; Options.ocamlopt := ocamlfind& A"ocamlopt"; | After_rules -> flag ["ocaml"; "pp"; "use_float"] (A"pa_float.cmo"); flag ["ocaml"; "link"] (A"-linkpkg"); dep ["ocaml"; "ocamldep"; "use_float"] ["pa_float.cmo"]; | _ -> () end;; #####$cat pa_float.ml module Id = struct let name = "pa_float" let version = "1.0" end open Camlp4 module Make (Syntax : Sig.Camlp4Syntax) = struct open Sig include Syntax class float_subst _loc = object inherit Ast.map as super method _Loc_t _ = _loc method expr = function | <:expr< ( + ) >> -> <:expr< ( +. ) >> | <:expr< ( - ) >> -> <:expr< ( -. ) >> | <:expr< ( * ) >> -> <:expr< ( *. ) >> | <:expr< ( / ) >> -> <:expr< ( /. ) >> | <:expr< $int:i$ >> -> let f = float(int_of_string i) in <:expr< $`flo:f$ >> | e -> super#expr e end;; EXTEND Gram GLOBAL: expr; expr: LEVEL "simple" [ [ "Float"; "."; "("; e = SELF; ")" -> (new float_subst _loc)#expr e ] ] ; END end let module M = Register.OCamlSyntaxExtension Id Make in () #####$ocamlbuild foo.byte -classic-display /usr/bin/ocamlopt -I /usr/lib/ocaml/3.10.0/ocamlbuild unix.cmxa /usr/lib/ocaml/3.10.0/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/lib/ocaml/3.10.0/ocamlbuild/ocamlbuild.cmx -o myocamlbuild /usr/bin/ocamldep -modules foo.ml > foo.ml.depends /usr/bin/ocamldep -pp camlp4of -modules pa_float.ml > pa_float.ml.depends ocamlfind ocamlc -package str -c -I +camlp4 -pp camlp4of -o pa_float.cmo pa_float.ml /usr/bin/ocamldep -pp 'camlp4o pa_float.cmo' -modules bar.ml > bar.ml.depends ocamlfind ocamlc -package str -c -pp 'camlp4o pa_float.cmo' -o bar.cmo bar.ml ocamlfind ocamlc -package str -c -o foo.cmo foo.ml ocamlfind ocamlc -package str -linkpkg bar.cmo foo.cmo -o foo.byte