From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "jake.donham" <jake.donham@skydeck.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] ocamlbuild: args to tags?
Date: Mon, 24 Sep 2007 14:29:27 +0200 [thread overview]
Message-ID: <1190636327-sup-9586@ausone.inria.fr> (raw)
In-Reply-To: <46F01294.7060806@skydeck.com>
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
>
> <foo.ml> : 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
>
> <foo.ml> : deriving(Show,Typeable)
>
> or
>
> <foo.ml> : deriving,classes(Show,Typeable)
Yes but you cannot do that for now. One feasible feature would be:
<foo.ml>: deriving, classes{Show,Typeable}
Which will expands to:
<foo.ml>: 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
next prev parent reply other threads:[~2007-09-24 12:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-18 18:01 Jake Donham
2007-09-24 12:29 ` Nicolas Pouillard [this message]
2007-09-24 14:03 ` [Caml-list] " skaller
2007-09-24 15:23 ` Nicolas Pouillard
2007-09-24 17:38 ` skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1190636327-sup-9586@ausone.inria.fr \
--to=nicolas.pouillard@gmail.com \
--cc=caml-list@inria.fr \
--cc=jake.donham@skydeck.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox