Skip to content

Commit 78a6f28

Browse files
hvadehracopybara-github
authored andcommitted
Starlarkify and remove native API CcInternal.escape_label
PiperOrigin-RevId: 823501665 Change-Id: I633e601f7b8886d8d6b1228e43a45896988595fe
1 parent b81a4f4 commit 78a6f28

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cc/private/cc_common.bzl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,27 @@ def _create_linkstamp(linkstamp, headers):
678678
_cc_internal.check_private_api(allowlist = _PRIVATE_STARLARKIFICATION_ALLOWLIST)
679679
return create_linkstamp(linkstamp, headers)
680680

681+
_PATH_ESCAPE_REPLACEMENTS = {
682+
"_": "_U",
683+
"/": "_S",
684+
"\\": "_B",
685+
":": "_C",
686+
"@": "_A",
687+
}
688+
681689
def _escape_label(*, label):
682690
_cc_internal.check_private_api(allowlist = _PRIVATE_STARLARKIFICATION_ALLOWLIST)
683-
return _cc_internal.escape_label(label = label)
691+
path = label.package + ":" + label.name
692+
if label.repo_name:
693+
path = label.repo_name + "@" + path
694+
result = []
695+
for idx in range(len(path)):
696+
c = path[idx]
697+
result.append(_PATH_ESCAPE_REPLACEMENTS.get(
698+
c,
699+
c, # no escaping by default
700+
))
701+
return "".join(result)
684702

685703
def _cc_toolchain_features(*, toolchain_config_info, tools_directory):
686704
_cc_internal.check_private_api(allowlist = _PRIVATE_STARLARKIFICATION_ALLOWLIST)

0 commit comments

Comments
 (0)