mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:51:12 +01:00
Replace use of deprecated outputs rule parameter. (#4074)
Instead compute the output in the implementation and return it via the `DefaultInfo` provider. This matches the latest docs on how to write rules producing a file: https://bazel.build/rules/rules-tutorial#creating_a_file
This commit is contained in:
@@ -10,14 +10,8 @@ a file which can be accessed as a list. This avoids long argument parsing.
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_test")
|
||||
|
||||
DataFilesInfo = provider(
|
||||
"Data files for this target.",
|
||||
fields = {
|
||||
"data_files": "Data files for this target",
|
||||
},
|
||||
)
|
||||
|
||||
def _tests_as_input_file_rule_impl(ctx):
|
||||
out = ctx.actions.declare_file(ctx.label.name + ".txt")
|
||||
data_files = []
|
||||
for tests in ctx.attr.data:
|
||||
data_files.extend(
|
||||
@@ -26,15 +20,13 @@ def _tests_as_input_file_rule_impl(ctx):
|
||||
data_files.extend(
|
||||
[f.path for f in tests[DefaultInfo].files.to_list()],
|
||||
)
|
||||
ctx.actions.write(ctx.outputs.data_files, "\n".join(data_files) + "\n")
|
||||
ctx.actions.write(out, "\n".join(data_files) + "\n")
|
||||
return [DefaultInfo(files = depset([out]))]
|
||||
|
||||
_tests_as_input_file_rule = rule(
|
||||
attrs = {
|
||||
"data": attr.label_list(allow_files = True),
|
||||
},
|
||||
outputs = {
|
||||
"data_files": "%{name}.txt",
|
||||
},
|
||||
implementation = _tests_as_input_file_rule_impl,
|
||||
)
|
||||
|
||||
@@ -69,7 +61,7 @@ def file_test(
|
||||
testonly = 1,
|
||||
)
|
||||
args = ["--test_targets_file=$(rootpath :{0})".format(tests_file)] + args
|
||||
data = [tests_file] + tests + data
|
||||
data = [":" + tests_file] + tests + data
|
||||
|
||||
if prebuilt_binary:
|
||||
native.sh_test(
|
||||
|
||||
Reference in New Issue
Block a user