Skip to content

Commit

Permalink
Make rustfmt toolchain optional in bindgen (#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlopko authored Jul 17, 2024
1 parent 147886f commit 6a140b2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bindgen/private/bindgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _rust_bindgen_impl(ctx):

# Vanilla usage of bindgen produces formatted output, here we do the same if we have `rustfmt` in our toolchain.
rustfmt_toolchain = ctx.toolchains[Label("//rust/rustfmt:toolchain_type")]
if toolchain.default_rustfmt:
if rustfmt_toolchain and toolchain.default_rustfmt:
# Bindgen is able to find rustfmt using the RUSTFMT environment variable
env.update({"RUSTFMT": rustfmt_toolchain.rustfmt.path})
tools = depset(transitive = [tools, rustfmt_toolchain.all_files])
Expand Down Expand Up @@ -379,10 +379,10 @@ rust_bindgen = rule(
outputs = {"out": "%{name}.rs"},
fragments = ["cpp"],
toolchains = [
str(Label("//bindgen:toolchain_type")),
str(Label("//rust:toolchain_type")),
str(Label("//rust/rustfmt:toolchain_type")),
"@bazel_tools//tools/cpp:toolchain_type",
config_common.toolchain_type("//bindgen:toolchain_type"),
config_common.toolchain_type("//rust:toolchain_type"),
config_common.toolchain_type("//rust/rustfmt:toolchain_type", mandatory = False),
config_common.toolchain_type("@bazel_tools//tools/cpp:toolchain_type"),
],
)

Expand Down

0 comments on commit 6a140b2

Please sign in to comment.