No public description

PiperOrigin-RevId: 613579953
Change-Id: I4aea8af1b3db8eb532c7c9296fc4dfa0c2ff9481
This commit is contained in:
Googler 2024-03-07 07:39:26 -08:00 committed by Copybara-Service
parent 1ff1af662e
commit e658433e23
6 changed files with 17 additions and 10 deletions

View File

@ -4,6 +4,7 @@ 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")
@ -11,5 +12,4 @@ 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)

View File

@ -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

View File

@ -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,

View File

@ -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,
@ -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 [
@ -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.

View File

@ -6,8 +6,8 @@ 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"],
)
@ -15,7 +15,7 @@ util.helper_target(
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__"],
)

View File

@ -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"],
)