Skip to content

Commit

Permalink
Update naming function
Browse files Browse the repository at this point in the history
Summary: Update naming function to always add "cfg:" in front of configuration names generated by modifiers

Reviewed By: stepancheg

Differential Revision: D51341821

fbshipit-source-id: 0596b245de8a5dc9d642d7bb9e5f62d5265f0094
  • Loading branch information
Scott Cao authored and facebook-github-bot committed Nov 16, 2023
1 parent 902b6a9 commit 8c7135e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cfg/experimental/name.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ NAMED_CONSTRAINT_SETTINGS = [
"ovr_config//build_mode/constraints:san",
]

# Mark all modifier generated configurations with a `cfg:` prefix.
# We do this so that we can easily recognize which configuration is generated
# by modifiers and query for it in Scuba.
_CFG_PREFIX = "cfg:"
_EMPTY_CFG_NAME = _CFG_PREFIX + "<empty>"

def cfg_name(cfg: ConfigurationInfo) -> str:
"""Derives a reasonable name for a ConfigurationInfo"""

Expand All @@ -24,4 +30,8 @@ def cfg_name(cfg: ConfigurationInfo) -> str:
for constraint_setting in NAMED_CONSTRAINT_SETTINGS:
if constraint_setting in constraints:
name_list.append(constraints[constraint_setting].label.name)
return "-".join(name_list)
if len(name_list) == 0:
name = _EMPTY_CFG_NAME
else:
name = _CFG_PREFIX + "-".join(name_list)
return name

0 comments on commit 8c7135e

Please sign in to comment.