ocaml_test Last updated Mar 27, 2025

load("@rules_ocaml//build/_rules:ocaml_test.bzl", "ocaml_test")

OCaml test rule.

CONFIGURABLE DEFAULTS for rule ocaml_test

In addition to the [OCaml configurable defaults](#configdefs) that apply to all ocaml_* rules, the following apply to this rule:

| Label | Default | opts attrib | | ----- | ------- | ------- | | @rules_ocaml//cfg/executable:linkall | True | -linkall, -no-linkall| | @rules_ocaml//cfg/executable:threads | False | true: -I +thread| | @rules_ocaml//cfg/executable:warnings | @1..3@5..28@30..39@43@46..47@49..57@61..62-40| -w plus option value |

NOTE These do not support :enable, :disable syntax.

See [Configurable Defaults](../ug/configdefs_doc.md) for more information.

Attributes

Name Description Type Mandatory Default

name

A unique name for this target.

Name

required

data

Runtime dependencies: list of labels of data files needed by this executable at runtime.

List of labels

optional

[]

cc_deps

Dictionary specifying C/C++ library dependencies. Key: a target label; value: a linkmode string, which determines which file to link. Valid linkmodes: 'default', 'static', 'dynamic', 'shared' (synonym for 'dynamic'). For more information see [CC Dependencies: Linkmode](../ug/cc_deps.md#linkmode).

Dictionary: Label -> String

optional

{}

cc_libs

-

List of labels

optional

[]

cc_linkall

True: use -whole-archive (GCC toolchain) or -force_load (Clang toolchain). Deps in this attribute must also be listed in cc_deps.

List of labels

optional

[]

cc_linkopts

List of C/C link options. E.g. ["-lstd"].

List of strings

optional

[]

data_prefix_map

Map for replacing path prefixes of data files

Dictionary: String -> String

optional

{}

diff_cmd

-

Label

optional

None

env

Env variables

Dictionary: String -> String

optional

{}

epilogue

List of OCaml dependencies to be linked after main.

List of labels

optional

[]

exe_name

By default, executable name is derived from 'name' attribute; use this to override.

String

optional

""

force_archived_libdeps

Force archiving of library dependencies

Boolean

optional

False

main

Label of module containing entry point of executable. In the list of dependencies, this will be placed after 'prologue' deps and before 'epilogue' deps.

Label

required

opts

List of compile options; overrides configurable default options. Supports -no- prefix for each option; for example, -no-linkall.

List of strings

optional

[]

prologue

List of OCaml dependencies to be linked before main.

List of labels

optional

[]

runtime

Runtime to use. One of @rules_ocaml//rt:std, @rules_ocaml//rt:dbg, @rules_ocaml//rt:instrumented; or, label of an ocaml_runtime target creating a custom runtime.

@rules_ocaml//rt:dbg will set -runtime-variant d; @rules_ocaml//rt:instrumented will set -runtime-variant i; a custom label will set -use-runtime.

Label

optional

"@rules_ocaml//rt:std"

vm_linkage

custom, dynamic or static. Custom means link with -custom flag; static with -output-complete-exe

String

optional

"custom"