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:
-
ppx
takes the label of appx_executable
target; the executable will be used to preprocess the source file; -
ppx_args
is used to pass command args to theppx_executable
-
ppx_data
passes data files needed atppx_executable
runtime -
ppx_print
controls the form of PPX processing output, eitherbinary
ortext
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