Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Grégoire_Sutre <gregoire.sutre@l...>
Subject: ocamlbuild - which source files for tag declarations?
Hi,

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
instance:

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

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

# Target: A.cmo, tags: { byte, compile, extension:ml, file:A.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 A.ml > A.ml.depends
/usr/pkg/bin/ocamlc.opt -c -o A.cmo A.ml
/usr/pkg/bin/ocamlopt.opt -c -pp foo -o A.cmx A.ml

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 (ocaml_specific.ml):

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,

Grégoire