ocaml_ns_config Last updated Mar 27, 2025

load("@rules_ocaml//build:rules.bzl", "ocaml_ns_config")

Generates a source <ns>.ml file containing the module aliasing equations needed to define an OCaml build namespace.

Attributes

Name Description Type Mandatory Default

name

A unique name for this target.

Name

required

env

Env variables

Dictionary: String -> String

optional

{}

import_as

Import exogenous (non-namepaced) modules.

Exogenous (sub)modules, namespaced or non-namespaced. Aliased names will not be prefixed with ns name of this ns_config.

Keys: labels of modules; Values: alias name to be used in this resolver.

e.g. import_as = {"//mwe/rgb:R": "Red"} will generate

module R = Red

Dictionary: Label -> String

optional

{}

ns_import_as

Import exogenous namespaces (ocaml_ns targets).

Dictionary: keys are exogenous namespaces (ocaml_ns modules), values are strings to serve as ns name aliases. Example: {"//foo/bar:nsbaz": "FBB"}

Dictionary: Label -> String

optional

{}

ns_merge

Merges all submodules of an exogenous namespace.

List of labels

optional

[]

ns_name

Use this as the ns name (prefix string)

String

optional

""

opts

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

List of strings

optional

[]

private

When True, adds suffix __ to ns name. Use this option when you have a module whose name matches the ns name. Such a module will function as the ns resolver, and may export only a subset of the members of the namespace.

Not to be confused with the visibility attribute, which controls visibility of the target within the Bazel environment.

Boolean

optional

False

submodules

List of strings from which submodule names are to be derived for aliasing. Bazel labels may be used; the submodule name will be derived from the target part. For example, '//a/b:c' normalizes to C. But they are just strings, and will not be checked against any files.

The normalized submodule names must match the names of the modules electing membership via the 'ns_config' attribute.

List of strings

optional

[]