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=AWL autolearn=disabled version=3.1.3 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 110D2BBC1 for ; Fri, 7 Mar 2008 10:24:34 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhEBAH+Y0EeBrw8En2dsb2JhbACQfgEBAQEBBgQGCQgYgQ2Zdg X-IronPort-AV: E=Sophos;i="4.25,461,1199660400"; d="scan'208";a="9984789" Received: from ext.lri.fr ([129.175.15.4]) by mail3-smtp-sop.national.inria.fr with ESMTP; 07 Mar 2008 10:24:33 +0100 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 857E5A46E9; Fri, 7 Mar 2008 10:24:33 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uR7Vq-SEXRJw; Fri, 7 Mar 2008 10:24:33 +0100 (CET) Received: from smtp.lri.fr (vhost3-23 [129.175.3.23]) by ext.lri.fr (Postfix) with ESMTP id EDD2DA46EA; Fri, 7 Mar 2008 10:23:23 +0100 (CET) Received: from [129.175.4.107] (lri4-107 [129.175.4.107]) by smtp.lri.fr (Postfix) with ESMTP id E5245E0535; Fri, 7 Mar 2008 10:23:23 +0100 (CET) Message-ID: <47D10A4B.7000904@lri.fr> Date: Fri, 07 Mar 2008 10:26:35 +0100 From: Romain Bardou User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: Dario Teixeira Cc: Romain Bardou , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Ocamlbuild with findlib + camlp4 References: <318509.18876.qm@web54603.mail.re2.yahoo.com> In-Reply-To: <318509.18876.qm@web54603.mail.re2.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; lri:01 findlib:01 camlp:01 findlib:01 ocamlfind:01 ocamlfind:01 ocamlc:01 ocamlc:01 ocamlopt:01 ocamlopt:01 ocamldep:01 ocamldep:01 ocamldoc:01 ocamldoc:01 ocaml:01 > 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? ########################### 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"; List.iter (fun pkg -> flag ["ocaml"; "pkg_"^pkg] & S[A"-package"; A pkg]) packages | _ -> () end ########################### This tells Ocamlbuild to use ocamlfind, and also defines some tags: * The "linkpkg" tag, which adds the "-linkpkg" flag when linking. Tag your output files with it (your .byte or .native files), not the source files. * The "pkg_nums", "pkg_str", and "pkg_unix" tags (simply add packages to the "packages" list if you need other packages) which add the "-package nums", "-package str" and "-package unix" options respectively. Tag your source files with the -package options they should use when compiling, and your output files with the -package options they should use when linking. As an exercise you could even add a tag "ocamlfind" which would allow you to use ocamlfind only when you want to. Now you should be able to use ocamlfind with different options depending on tags. Disclaimer: * I know it compiles but I didn't have time to construct a dummy project which would allow me to test this extension. * It does nothing to handle camlp4, but you should be able to add the correct options yourself. Please tell me if it is what you needed or not :) -- Romain Bardou