Buck: ocaml_binary()
Support Ukraine. Help Provide Humanitarian Aid to Ukraine.

ocaml_binary()

This is liable to change in the future.

A ocaml_binary() rule builds both native and bytecode executables from the supplied set of OCaml and C source files and dependencies.

Note: Buck is currently tested with 4.X OCaml series.

Arguments

  • name (required) #

    The short name for this build target.

  • srcs (required) #

    The set of source files to be compiled by this rule. It supports *.ml, *.mli, *.mly, *.mll, and *.c files. (see this test as C interop example and this test as parser and lexer example).

  • deps (defaults to []) #

    The set of dependencies of this rule. It could include references to ocaml_library and cxx_library rules.

  • platform_deps (defaults to []) #

    Platform specific dependencies. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is a list of dependencies (same format as deps) that are exported if the platform matches the regex. See deps for more information.

  • compiler_flags (defaults to []) #

    The set of additional compiler flags to pass to ocaml compiler. It supports specifying ppx (see for example).

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their deps or exported_deps attributes. For more information, see visibility.

  • licenses (defaults to []) #

    Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query.

  • labels (defaults to []) #

    Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using buck query attrfilter().

Examples

For more examples, check out our integration tests.

ocaml_binary(
  name='greet',
  srcs=[
    'main.ml',
    'lex.mll',
    'parser.mly',
    'hashtable.c',
  ],
  deps=[
    ':greeting',
    ':bridge',
  ],
)

ocaml_library(
  name='greeting',
  srcs=[
    'greeting.ml',
  ],
  deps=[
    ':join',
  ],
)

ocaml_library(
  name='join',
  srcs=[
    'join.ml',
  ],
)

cxx_library(
  name='bridge',
  srcs=[
    'bridge.c',
  ],
)