Skip to main content
function BazelRC.announce
def BazelRC.announce(
*,
command: str,
ansi: bool = False,
max_width: int = 120
) -> str
Return a human-readable summary of all options loaded for command. Options are grouped by source file and wrapped at max_width columns (default 120). Pass ansi = True to enable bold/dim ANSI styling on headers and section names. Useful for debugging which flags were picked up and from which rc file:
print(rc.announce(command = "build"))
print(rc.announce(command = "build", ansi = True))
function BazelRC.expand
def BazelRC.expand(
*,
command: str
) -> list
Expand all --config= flags for command and return the fully-resolved list. Each item is either a plain str (unconditional) or a (str, str) tuple (flag, version_condition) for version-gated flags. This format is directly compatible with ctx.bazel.build(flags=...). function BazelRC.expand_all
def BazelRC.expand_all(
*,
command: str
) -> (list, list)
Expand all --config= flags for command and split results by origin section. Options from common sections cannot be passed directly on the Bazel CLI — they must be injected via startup flags so Bazel applies the correct silent-ignore semantics. All other options (always, build, etc.) are safe to pass as regular command flags. Returns a (startup_flags, flags) tuple:
  • startup_flags: ["--default_override=0:common=<value>", ...]
  • flags: direct command flags (same str | (str, str) format as expand())

Example

startup_flags, flags = rc.expand_all(command = "build")
ctx.bazel.build("//...", flags = flags, startup_flags = startup_flags)
function BazelRC.options_for
def BazelRC.options_for(
*,
command: str
) -> list
Return all options applicable to command without expanding --config= flags. Each item is either a plain str (unconditional) or a (str, str) tuple (flag, version_condition) for version-gated flags. function BazelRC.sources
def BazelRC.sources() -> list
Return the list of source file paths that were loaded.