Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 613579953
Change-Id: I4aea8af1b3db8eb532c7c9296fc4dfa0c2ff9481
  • Loading branch information
Googler authored and copybara-github committed Mar 7, 2024
1 parent 1ff1af6 commit e658433
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "platforms", version = "0.0.7")

cc_configure = use_extension("@bazel_tools//tools/cpp:cc_configure.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc_toolchains")

register_toolchains("@local_config_cc_toolchains//:all")

bazel_dep(name = "bazel_skylib", version = "1.3.0", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
1 change: 1 addition & 0 deletions cc/toolchains/args.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ directory as additional files.
""",
),
"args": attr.string_list(
mandatory = True,
doc = """Arguments that should be added to the command-line.
These are evaluated in order, with earlier args appearing earlier in the
Expand Down
2 changes: 1 addition & 1 deletion cc/toolchains/impl/toolchain_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _cc_toolchain_config_impl(ctx):
fail("Features is a reserved attribute in bazel. Did you mean 'toolchain_features'")

if not ctx.attr._enabled[BuildSettingInfo].value and not ctx.attr.skip_experimental_flag_validation_for_test:
fail("Rule based toolchains are experimental. To use it, please add --//cc/toolchains:experimental_enable_rule_based_toolchains to your bazelrc")
fail("Rule based toolchains are experimental. To use it, please add --@rules_cc//cc/toolchains:experimental_enable_rule_based_toolchains to your bazelrc")

toolchain_config = toolchain_config_info(
label = ctx.label,
Expand Down
16 changes: 11 additions & 5 deletions cc/toolchains/tool.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ load(
)

def _cc_tool_impl(ctx):
exe = ctx.executable.executable
runfiles = collect_data(ctx, ctx.attr.data + [ctx.attr.executable])
exe_info = ctx.attr.src[DefaultInfo]
if exe_info.files_to_run != None and exe_info.files_to_run.executable != None:
exe = exe_info.files_to_run.executable
elif len(exe_info.files.to_list()) == 1:
exe = exe_info.files.to_list()[0]
else:
fail("Expected cc_tool's src attribute to be either an executable or a single file")

runfiles = collect_data(ctx, ctx.attr.data + [ctx.attr.src])
tool = ToolInfo(
label = ctx.label,
exe = exe,
Expand All @@ -37,7 +44,7 @@ def _cc_tool_impl(ctx):
link = ctx.actions.declare_file(ctx.label.name)
ctx.actions.symlink(
output = link,
target_file = ctx.executable.executable,
target_file = exe,
is_executable = True,
)
return [
Expand All @@ -55,9 +62,8 @@ cc_tool = rule(
implementation = _cc_tool_impl,
# @unsorted-dict-items
attrs = {
"executable": attr.label(
"src": attr.label(
allow_files = True,
executable = True,
cfg = "exec",
doc = """The underlying binary that this tool represents.
Expand Down
4 changes: 2 additions & 2 deletions tests/rule_based_toolchain/tool/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ load(":tool_test.bzl", "TARGETS", "TESTS")
util.helper_target(
cc_tool,
name = "tool",
src = "//tests/rule_based_toolchain/testdata:bin_wrapper.sh",
data = ["//tests/rule_based_toolchain/testdata:bin"],
executable = "//tests/rule_based_toolchain/testdata:bin_wrapper.sh",
execution_requirements = ["requires-network"],
requires_any_of = ["//tests/rule_based_toolchain/features:direct_constraint"],
)

util.helper_target(
cc_tool,
name = "wrapped_tool",
executable = "//tests/rule_based_toolchain/testdata:bin_wrapper",
src = "//tests/rule_based_toolchain/testdata:bin_wrapper",
visibility = ["//tests/rule_based_toolchain:__subpackages__"],
)

Expand Down
2 changes: 1 addition & 1 deletion tests/rule_based_toolchain/toolchain_config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ util.helper_target(
util.helper_target(
cc_tool,
name = "requires_all_simple_tool",
executable = "//tests/rule_based_toolchain/testdata:bin_wrapper.sh",
src = "//tests/rule_based_toolchain/testdata:bin_wrapper.sh",
requires_any_of = [":all_simple_features"],
)

Expand Down

0 comments on commit e658433

Please sign in to comment.