ocaml_ns Last updated Mar 27, 2025

ocaml_ns

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

Macro. Expands to an ocaml_ns_config and an ocaml_ns_module target that together define an OCaml build namespace.

Attributes

Name Description Type Mandatory Default

name

A unique name for this macro instance. Normally, this is also the name for the macro’s main or only target. The names of any other targets that this macro might create will be this name with a string suffix.

Name

required

env

Env variables

Dictionary: String -> String

optional

None

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

None

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

None

ns_merge

Merges all submodules of an exogenous namespace.

List of labels

optional

None

ns_name

Use this as the ns name (prefix string)

String

optional

None

opts

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

List of strings

optional

None

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

None

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

None

visibility

The visibility to be passed to this macro’s exported targets. It always implicitly includes the location where this macro is instantiated, so this attribute only needs to be explicitly set if you want the macro’s targets to be additionally visible somewhere else.

List of labels; nonconfigurable

optional