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.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 83084BBC1 for ; Tue, 11 Mar 2008 11:38:31 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.25,479,1199660400"; d="asc'?scan'208";a="10125903" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail3-relais-sop.national.inria.fr with SMTP; 11 Mar 2008 11:38:31 +0100 Received: by ausone.inria.fr (sSMTP sendmail emulation); Tue, _d Mar 2008 11:37:18 +0100 From: "Nicolas Pouillard" Cc: Caml_mailing list Subject: Re: [Caml-list] Ocamlbuild with findlib + camlp4 To: Dario Teixeira References: <1204976068-sup-9188@ausone.local> <366498.253.qm@web54601.mail.re2.yahoo.com> In-Reply-To: <366498.253.qm@web54601.mail.re2.yahoo.com> Date: Tue, 11 Mar 2008 11:37:14 +0100 Message-Id: <1205230925-sup-3194@ausone.inria.fr> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1205231838-915237-71945-8237-1-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Spam: no; 0.00; findlib:01 camlp:01 findlib:01 ocamlfind:01 camlp:01 syntax:01 syntax:01 bigarray:01 byte:01 cmxa:01 sexp:01 cmo:01 toploop:01 sexp:01 cmo:01 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1205231838-915237-71945-8237-1-= Content-Type: text/plain; charset=UTF-8 Excerpts from Dario Teixeira's message of Mon Mar 10 16:33:56 +0100 2008: > > Nice! Apart the link with findlib.cma that is not supported yet and could > > be with the multiple-plugins support in ocamlbuild. I think that one can > > easily build a generic plugin for ocamlfind packages. > > Hi, Hi, > > I hope so too. However, note that no one has managed yet to provide a solution > to my original question, namely of integrating Ocamlbuild with findlib *and* > camlp4. Perhaps I should have explained better what this entails: > > Suppose you are using the Sexplib syntax extension. This syntax extension > depends on Sexplib itself and on another syntax extension, offered by the > Type-conv package. The META package for Sexplib should contain the following: > (note that the version currently shipping with GODI is incomplete) > > ############################################################### > name="sexplib" > version="3.0.0" > description="Sexplib - automated S-expression conversions" > requires="bigarray" > archive(byte)="sexplib.cma" > archive(native)="sexplib.cmxa" > > package "statements" ( > requires = "sexplib,type-conv.statements,camlp4" > version = "3.0.0" > description = "Syntax extension for Sexplib" > archive(syntax,preprocessor) = "pa_sexp_conv.cmo" > archive(syntax,toploop) = "pa_sexp_conv.cmo" > ) > ############################################################### > > > To compile with Findlib a data.ml file that makes use of the Sexplib syntax > extension is very simple. You just have to specify the "sexplib.statements" > package, and findlib will *automatically* take care of also loading libraries > or even other syntax extensions needed by sexplib.statements: > > ocamlfind ocamlc -package sexplib.statements -syntax camlp4o -c data.ml > > > Why am I insisting on this? Because when we manage to integrate these > three tools, we will essentially have solved the very common request of > providing easy access to common syntax extensions (just last week there was > an OSR on this subject). All that will be required to compile a file such as > data.ml using the Sexplib syntax extension will be to add a line ": > use_sexplib.statements" to the _tags file. You won't even need to create > a custom Ocamlbuild plugin or anything, because this findlib support could > be provided by a default plugin (living on $HOME/.ocamlbuild or something). > So, Nicolas, is this altogether feasible with the current Ocamlbuild? > (And if so, could you lent us a hand -- you are of course the most > competent person to do so). First I would like thanks everyone that participated in also helping you. Keep up! Currently we must add a myocamlbuild.ml file in your project because ocamlbuild does not support multiple plugins (allowing $HOME/.ocamlbuild for instance). However one can have a reusable myocamlbuild.ml file. Here is a starting point: ################################### open Ocamlbuild_plugin open Command (* no longer needed for OCaml >= 3.10.2 *) (* these functions are not really officially exported *) let run_and_read = Ocamlbuild_pack.My_unix.run_and_read let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings (* this lists all supported packages *) let find_packages () = blank_sep_strings & Lexing.from_string & run_and_read "ocamlfind list | cut -d' ' -f1" (* this is supposed to list available syntaxes, but I don't know how to do it. *) let find_syntaxes () = ["camlp4o"; "camlp4r"] (* ocamlfind command *) let ocamlfind x = S[A"ocamlfind"; x] let _ = dispatch begin function | Before_options -> (* override default commands by ocamlfind ones *) Options.ocamlc := ocamlfind & A"ocamlc"; Options.ocamlopt := ocamlfind & A"ocamlopt"; Options.ocamldep := ocamlfind & A"ocamldep"; Options.ocamldoc := ocamlfind & A"ocamldoc" | After_rules -> (* When one link an OCaml library/binary/package, one should use -linkpkg *) flag ["ocaml"; "link"] & A"-linkpkg"; (* For each ocamlfind package one inject the -package option when * compiling, computing dependencies, generating documentation and * linking. *) List.iter begin fun pkg -> flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg]; flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg]; flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg]; flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg]; end (find_packages ()); (* Like -package but for extensions syntax. Morover -syntax is useless * when linking. *) List.iter begin fun syntax -> flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; end (find_syntaxes ()); | _ -> () end ################################### Then consider that I want to compile yahoo.ml that requires the json-static syntax extension, plus json-wheel and netclient. $ cat _tags : pkg_json-static, pkg_netclient, syntax_camlp4o $ ocamlbuild yahoo.byte -- ocaml ... Best regards, [1]: http://martin.jambon.free.fr/yahoo.ml -- Nicolas Pouillard aka Ertai --=-1205231838-915237-71945-8237-1-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkfWYNoACgkQj+FCNw9dwLlJsACeJC6pjgnyBDfzS29jlW4aSJW2 6D8AnRkBgvCPGSKzA7lyo9yynYCH3qCL =m9eO -----END PGP SIGNATURE----- --=-1205231838-915237-71945-8237-1-=--