Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
ocamlbuild - which source files for tag declarations?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-06-30 (14:47)
From: Grégoire_Sutre <gregoire.sutre@l...>
Subject: ocamlbuild - which source files for tag declarations?

I'm having difficulties understanding on which files I should declare 
tags: *.ml, or *.cmo/cmx?

For instance, with normal (non-parameterized) tags, declaring the tag
on the .cmo/.cmx seems to have no effect on the compilation, for

$ cat _tags
<*.cmo>: annot
<*.cmx>: annot
$ ocamlbuild -classic-display A.cmo A.cmx
/usr/pkg/bin/ocamldep.opt -modules >
/usr/pkg/bin/ocamlc.opt -c -o A.cmo
/usr/pkg/bin/ocamlopt.opt -c -o A.cmx

Here, tagging *.cmo/cmx has no effect.  The _build/_log says:

# Target: A.cmo, tags: { byte, compile, extension:ml,, implem, 
ocaml, quiet, traverse }

The tag annot is not there.  But if *.ml is used instead of *.cmo in
_tags, then the tag appears in the above target.  Does this mean that
tags to customize compilation commands should be declared on the *.ml
files?  (Hence they necessarily apply to both .cmo and .cmx files?)

The situation looks a bit different with parameterized tags, for
instance :

$ cat _tags
<*.cmo>: pp(foo)
<*.cmx>: pp(foo)
$ ocamlbuild -classic-display A.cmo A.cmx
/usr/pkg/bin/ocamldep.opt -modules >
/usr/pkg/bin/ocamlc.opt -c -o A.cmo
/usr/pkg/bin/ocamlopt.opt -c -pp foo -o A.cmx

Here, the pp(foo) tag is ignored for the *.cmo declaration, but it is
used for the *.cmx declaration.  Is this behavior intended?  The code
says (

pflag ["ocaml"; "compile"] "pp"
     (fun param -> S [A "-pp"; A param]);

So I wonder why pp(foo) only applies to *.cmx.

Thanks for your help,