Skip to content

Commit 78bc3cd

Browse files
authored
feat: add target_settings so we can do config transitions (#173)
1 parent eae225d commit 78bc3cd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docs/defs.md

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

toolchain/defs.bzl

+12
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,15 @@ def _gcc_toolchain_impl(rctx):
5555
for v in rctx.attr.target_compatible_with
5656
]
5757

58+
target_settings = [
59+
v.format(target_arch = target_arch)
60+
for v in rctx.attr.target_settings
61+
]
62+
5863
rctx.file("BUILD.bazel", _TOOLCHAIN_BUILD_FILE_CONTENT.format(
5964
gcc_toolchain_workspace_name = rctx.attr.gcc_toolchain_workspace_name,
6065
target_compatible_with = str(target_compatible_with),
66+
target_settings = str(target_settings),
6167
toolchain_files_repository_name = rctx.attr.toolchain_files_repository_name,
6268

6369
# Sysroot
@@ -135,6 +141,11 @@ _FEATURE_ATTRS = {
135141
doc = "contraint_values passed to target_compatible_with of the toolchain. {target_arch} is rendered to the target_arch attribute value.",
136142
mandatory = False,
137143
),
144+
"target_settings": attr.string_list(
145+
default = [],
146+
doc = "config_settings passed to target_compatible_with of the toolchain. {target_arch} is rendered to the target_arch attribute value.",
147+
mandatory = False,
148+
),
138149
"toolchain_files_repository_name": attr.string(
139150
doc = "The name of the repository containing the toolchain files.",
140151
mandatory = True,
@@ -570,6 +581,7 @@ toolchain(
570581
"@platforms//cpu:x86_64",
571582
],
572583
target_compatible_with = {target_compatible_with},
584+
target_settings = {target_settings},
573585
toolchain = ":_cc_toolchain",
574586
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
575587
)

0 commit comments

Comments
 (0)