Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add target_settings so we can do config transitions #173

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading