Skip to content

Commit 9373d61

Browse files
committed
wip add tcw/ecw
1 parent 2a1766e commit 9373d61

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

python/private/py_toolchain_suite.bzl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def _internal_toolchain_suite(prefix, runtime_repo_name, target_compatible_with,
145145
def define_local_toolchain_suites(
146146
name,
147147
version_aware_repo_names,
148-
repo_target_settings,
149-
version_unaware_repo_names):
148+
version_unaware_repo_names,
149+
repo_target_settings):
150150
"""Define toolchains for `local_runtime_repo` backed toolchains.
151151
152152
This generates `toolchain` targets that can be registered using `:all`. The
@@ -160,26 +160,37 @@ def define_local_toolchain_suites(
160160
version-aware toolchains defined.
161161
version_unaware_repo_names: `list[str]` of the repo names that will have
162162
version-unaware toolchains defined.
163+
repo_target_settings: {type}`dict[str, list[str]]` mapping of repo names
164+
to string labels that are added to the `target_settings` for the
165+
respective repo's toolchain.
166+
repo_target_compatible_with: {type}`dict[str, list[str]]` mapping of repo names
167+
to string labels that are added to the `target_compatible_with` for
168+
the respective repo's toolchain.
169+
repo_exec_compatible_with: {type}`dict[str, list[str]]` mapping of repo names
170+
to string labels that are added to the `exec_compatible_with` for
171+
the respective repo's toolchain.
163172
"""
164173
i = 0
165174
for i, repo in enumerate(version_aware_repo_names, start = i):
166-
prefix = render.left_pad_zero(i, 4)
167175
target_settings = ["@{}//:is_matching_python_version".format(repo)]
168176
target_settings.extend(repo_target_settings.get(repo, []))
177+
target_compatible_with = ["@{}//:os".format(repo)]
178+
target_compatible_with.extend(repo_target_compatible_with.get(repo, []))
169179
_internal_toolchain_suite(
170-
prefix = prefix,
180+
prefix = render.left_pad_zero(i, 4),
171181
runtime_repo_name = repo,
172182
target_settings = target_settings,
173-
target_compatible_with = ["@{}//:os".format(repo)],
183+
target_compatible_with = target_compatible_with,
184+
exec_compatible_with = repo_exec_compatible_with.get(repo, []),
174185
)
175186

176187
# The version unaware entries must go last because they will match any Python
177188
# version.
178189
for i, repo in enumerate(version_unaware_repo_names, start = i + 1):
179-
prefix = render.left_pad_zero(i, 4)
190+
target_compatible_with = ["@{}//:os".format(repo)]
191+
target_compatible_with.extend(repo_target_compatible_with.get(repo, []))
180192
_internal_toolchain_suite(
181-
prefix = prefix,
193+
prefix = render.left_pad_zero(i, 4),
182194
runtime_repo_name = repo,
183195
target_settings = repo_target_settings.get(repo, []),
184-
target_compatible_with = ["@{}//:os".format(repo)],
185196
)

python/private/text_util.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def _render_list(items, *, hanging_indent = ""):
108108
def _render_str(value):
109109
return repr(value)
110110

111+
def _render_string_list_dict(value):
112+
"""Render an attr.string_list_dict value (`dict[str, list[str]`)"""
113+
return _render_dict(value, value_repr = _render_list)
114+
111115
def _render_tuple(items, *, value_repr = repr):
112116
if not items:
113117
return "tuple()"
@@ -166,4 +170,5 @@ render = struct(
166170
str = _render_str,
167171
toolchain_prefix = _toolchain_prefix,
168172
tuple = _render_tuple,
173+
string_list_dict = _render_string_list_dict,
169174
)

0 commit comments

Comments
 (0)