OCamlbuild and camlp4 options

I use camlp4.macro to enable conditional compilation. I have problems telling OCamlbuild that certain files with the "use_jscore" tag should be pre-processed using this camlp4 option. Here is what I have:

let _ = dispatch begin function
  | After_rules ->
    flag ["ocaml"; "use_jscore"] (S[A"-package"; A"camlp4.macro"; A"-syntax"; A"camlp4o"; A"-ppopt"; A"-DUSE_JSCORE"]);

But in OCamlbuild all this avoids. I use ocamlfind, so basically what I want to tell OCamlbuild is that all OCaml files with "use_jscore" tags should be pre-processed by camlp4.macro, which is also provided with -DUSE_JSCORE.

+5
source share
2 answers

A_tags and the command line approach should also work, although it will not target individual files.

_Tags content:

<*.*>: syntax(camlp4o), package(camlp4.macro)

Command line:

ocamlbuild -use-ocamlfind -cflags -ppopt,-DUSE_JSCORE ...
+4
source

, , :

 let options = S[...] in
 flag ["ocaml"; "compile"; "use_jscore"] options;
 flag ["ocaml"; "ocamldep"; "use_jscore"] options

, camlp4 ( "ocamldep" ) ( "" ), ( "pp" ) ( "link" ).

, ocamlbuild -use-ocamlfind <target>, .

+3

All Articles