Skip to content

Commit

Permalink
feat: add target_settings so we can do config transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
f0rmiga committed Apr 29, 2024
1 parent eae225d commit ab6782b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/defs.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions toolchain/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ def _gcc_toolchain_impl(rctx):
for v in rctx.attr.target_compatible_with
]

target_settings = [
v.format(target_arch = target_arch)
for v in rctx.attr.target_settings
]

rctx.file("BUILD.bazel", _TOOLCHAIN_BUILD_FILE_CONTENT.format(
gcc_toolchain_workspace_name = rctx.attr.gcc_toolchain_workspace_name,
target_compatible_with = str(target_compatible_with),
target_settings = str(target_settings),
toolchain_files_repository_name = rctx.attr.toolchain_files_repository_name,

# Sysroot
Expand Down Expand Up @@ -135,6 +141,11 @@ _FEATURE_ATTRS = {
doc = "contraint_values passed to target_compatible_with of the toolchain. {target_arch} is rendered to the target_arch attribute value.",
mandatory = False,
),
"target_settings": attr.string_list(
default = [],
doc = "config_settings passed to target_compatible_with of the toolchain. {target_arch} is rendered to the target_arch attribute value.",
mandatory = False,
),
"toolchain_files_repository_name": attr.string(
doc = "The name of the repository containing the toolchain files.",
mandatory = True,
Expand Down Expand Up @@ -570,6 +581,7 @@ toolchain(
"@platforms//cpu:x86_64",
],
target_compatible_with = {target_compatible_with},
target_settings = {target_settings},
toolchain = ":_cc_toolchain",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
Expand Down

0 comments on commit ab6782b

Please sign in to comment.