Skip to content

Commit f945748

Browse files
Changochencopybara-github
authored andcommitted
Allow cc_bindings_from_rs aspect to generate error reporting.
PiperOrigin-RevId: 653710157 Change-Id: Ib652bec5331ce0172aa4e605b4229415bb56ff82
1 parent 00d93b4 commit f945748

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

cc_bindings_from_rs/bazel_support/BUILD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
load(
3+
"@bazel_skylib//rules:common_settings.bzl",
4+
"bool_flag",
5+
)
26

37
package(default_applicable_licenses = ["//:license"])
48

9+
bool_flag(
10+
name = "generate_error_report",
11+
build_setting_default = False,
12+
visibility = ["//visibility:public"],
13+
)
14+
515
bzl_library(
616
name = "cc_bindings_from_rust_rule_bzl",
717
srcs = ["cc_bindings_from_rust_rule.bzl"],

cc_bindings_from_rs/bazel_support/cc_bindings_from_rust_rule.bzl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ load(
3131
"@rules_rust//rust/private:utils.bzl",
3232
"find_toolchain",
3333
)
34+
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
3435
load(
3536
"//cc_bindings_from_rs/bazel_support:providers.bzl",
3637
"CcBindingsFromRustInfo",
@@ -104,8 +105,17 @@ def _generate_bindings(ctx, basename, inputs, args, rustc_env):
104105
arg = dep_bindings_info.crate_key + "=" + header.short_path
105106
crubit_args.add("--bindings-from-dependency", arg)
106107

108+
outputs = [h_out_file, rs_out_file]
109+
if ctx.attr._generate_error_report[BuildSettingInfo].value:
110+
error_report_output = ctx.actions.declare_file(basename + "_cc_api_error_report.json")
111+
crubit_args.add(
112+
"--error-report-out",
113+
error_report_output.path,
114+
)
115+
outputs.append(error_report_output)
116+
107117
ctx.actions.run(
108-
outputs = [h_out_file, rs_out_file],
118+
outputs = outputs,
109119
inputs = depset(
110120
[ctx.file._clang_format, ctx.file._rustfmt, ctx.file._rustfmt_cfg],
111121
transitive = [inputs],
@@ -360,6 +370,9 @@ cc_bindings_from_rust_aspect = aspect(
360370
"_extra_rustc_flag": attr.label(
361371
default = Label("@rules_rust//:extra_rustc_flag"),
362372
),
373+
"_generate_error_report": attr.label(
374+
default = "//cc_bindings_from_rs/bazel_support:generate_error_report",
375+
),
363376
},
364377
toolchains = [
365378
"@rules_rust//rust:toolchain_type",

0 commit comments

Comments
 (0)