IMPORTANT: The Bazel docs have moved! Please update your bookmark to https://bazel.build/rules/lib/config

You can read about the migration, and let us know what you think.

Extensions > API reference > config

config

This is a top-level module for creating configuration transitions and build setting descriptors which describe what kind of build setting (if any) a rule is.

ex: the following rule is marked as a build setting by setting the build_setting parameter of the rule() function. Specifically it is a build setting of type int and is a flag which means this build setting is callable on the command line.

  my_rule = rule(
    implementation = _impl,
    build_setting = config.int(flag = True),
    ...
  )

bool

BuildSetting config.bool(flag=False)

A bool-typed build setting

Parameters

Parameter Description
flag default = False
Whether or not this build setting is callable on the command line.

exec

ExecTransitionFactory config.exec(exec_group=None)

Creates an execution transition.

Parameters

Parameter Description
exec_group string; or None; default = None
The name of the exec group whose execution platform this transition will use. If not provided, this exec transition will use the target's default execution platform.

int

BuildSetting config.int(flag=False)

An integer-typed build setting

Parameters

Parameter Description
flag default = False
Whether or not this build setting is callable on the command line.

string

BuildSetting config.string(flag=False, allow_multiple=False)

A string-typed build setting

Parameters

Parameter Description
flag default = False
Whether or not this build setting is callable on the command line.
allow_multiple default = False
If set, this flag is allowed to be set multiple times on the command line. The Value of the flag as accessed in transitions and build setting implementation function will be a list of strings. Insertion order and repeated values are both maintained. This list can be post-processed in the build setting implementation function if different behavior is desired.

string_list

BuildSetting config.string_list(flag=False)

A string list-typed build setting. On the command line pass a list using comma-separated value like '--//my/setting=foo,bar'.

Parameters

Parameter Description
flag default = False
Whether or not this build setting is callable on the command line.