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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id ECC25BC69 for ; Mon, 24 Sep 2007 14:29:55 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAB5L90bAXQInemdsb2JhbACOGQIJCg X-IronPort-AV: E=Sophos;i="4.20,291,1186351200"; d="scan'208";a="1674968" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Sep 2007 14:29:55 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l8OCTrpi011370 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 24 Sep 2007 14:29:55 +0200 X-IronPort-AV: E=Sophos;i="4.20,291,1186351200"; d="scan'208";a="16692133" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail4-relais-sop.national.inria.fr with SMTP; 24 Sep 2007 14:29:55 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Mon, _d Sep 2007 14:29:27 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] ocamlbuild: args to tags? To: "jake.donham" References: <46F01294.7060806@skydeck.com> In-Reply-To: <46F01294.7060806@skydeck.com> Date: Mon, 24 Sep 2007 14:29:27 +0200 Message-Id: <1190636327-sup-9586@ausone.inria.fr> User-Agent: Sup/0.1 Content-Type: text/plain; charset=utf-8 X-j-chkmail-Score: MSGID : 46F7ADC1.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 46F7ADC1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 foo:01 -pp:01 foo:01 iter:01 flags:01 syntax:01 arg':01 flags:01 preprocessor:01 preprocessor:01 matched:01 caml-list:01 arbitrary:02 Excerpts from jake.donham's message of Tue Sep 18 20:01:56 +0200 2007: > Hi, > > Is there a way to pass arguments to a preprocessor via the _tags file? Yes, but that's not what you want. Moreover this feature is not really encouraged. > (In particular, I have added a -classes option to Deriving to give > default classes to all the types in a file.). Following the recent > discussion, I have this in myocamlbuild.ml: > > dispatch begin function > | After_rules -> > flag ["ocaml"; "pp"; "deriving"] (A"deriving"); > flag ["ocaml"; "pp"; "Show"] (S[A"-classes"; A"Show"]); > > So now if I put > > : deriving,Show > > in _tags I get -pp 'deriving -classes Show' in the command line. What I > would like, however, is to be able to write > > : deriving(Show,Typeable) > > or > > : deriving,classes(Show,Typeable) Yes but you cannot do that for now. One feasible feature would be: : deriving, classes{Show,Typeable} Which will expands to: : deriving, classesShow, classesTypeable And then in your plugin you can do: List.iter begin fun class_name -> flag ["ocaml"; "pp"; "classes"^class_name] (S[A"-classes"; A class_name]) end ["Show"; "Typeable"] > i.e. to be able to pass some arbitrary args rather than hard-coding Show > as a tag. Is there any way to do this? No I don't really want to complicate tags... > I don't understand how Ocamlbuild > decides whether flags should be associated with the main command or with > the preprocessor command; if I write classes(Foo) in _tags I get > -classes Foo in the main command, no matter what I have tried in > myocamlbuild.ml. Yes thats the not encouraged feature by using the syntax `flag(arg)' you pass the arguments `-flag arg' to *any* command that reference the matched file. It's merely because you cannot control when the flag is applied that this form is not encouraged. However the classic way of using tag have a fine grained control: flag ["ocaml"; "pp"; "Show"] (S[A"-classes"; A"Show"]); Here only commands tagged "ocaml", "pp" and "Show" will add the flags "-classes Show". Both commands and files contribute to this set of tags, and that's the conjunction that trigger the flags (but I think that you've got this one, and that's the flag(arg) behavior that leads to confusion). Regards, HTH -- Nicolas Pouillard aka Ertai