Preprocessing Last updated June 2, 2022
Most preprocessing tasks can be handled by Bazel’s standard genrule,
which is designed to run shell scripts. OBazl version 2 adds some new
rules to support standard code generation tools, such as ocaml_lex
and ocaml_yacc.
genrule
ocamllex
ocamlyacc
ppx
PPX processing is a little more complicated, and requires some
specialized support. OBazl provides one specialized rule,
ppx_executable, and a collection of ppx-specific attributes on
ocaml_module and ocaml_signature rules, including:
- 
ppxtakes the label of appx_executabletarget; the executable will be used to preprocess the source file;
- 
ppx_argsis used to pass command args to theppx_executable
- 
ppx_datapasses data files needed atppx_executableruntime
- 
ppx_printcontrols the form of PPX processing output, eitherbinaryortext
Some PPX transformers inject dependencies into the sources they
transform. Dune calls these "runtime" dependencies, but this is
inaccurate; they become compile-time dependencies of the files
output by the PPX transformation. OBazl version 1 called these adjunt
dependencies, for lack of a better term; version 2 calls them ppx
co-dependencies. They are passed to the ppx_executable through a
ppx_codeps attribute.
ppx_inline_test
See comments in demos - ppx_inine_test