Skip to content

Commit 7677c61

Browse files
authored
Add support for rustc flags to rust_proto_library (#1932)
* Add support for rustc flags to `rust_proto_library` * Regenerate documentation
1 parent fa304ae commit 7677c61

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

docs/flatten.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ Running `bazel test //hello_lib:hello_lib_doc_test` will run all documentation t
594594
## rust_grpc_library
595595

596596
<pre>
597-
rust_grpc_library(<a href="#rust_grpc_library-name">name</a>, <a href="#rust_grpc_library-deps">deps</a>, <a href="#rust_grpc_library-rust_deps">rust_deps</a>)
597+
rust_grpc_library(<a href="#rust_grpc_library-name">name</a>, <a href="#rust_grpc_library-deps">deps</a>, <a href="#rust_grpc_library-rust_deps">rust_deps</a>, <a href="#rust_grpc_library-rustc_flags">rustc_flags</a>)
598598
</pre>
599599

600600
Builds a Rust library crate from a set of `proto_library`s suitable for gRPC.
@@ -630,6 +630,7 @@ rust_binary(
630630
| <a id="rust_grpc_library-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
631631
| <a id="rust_grpc_library-deps"></a>deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding gRPC stubs. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
632632
| <a id="rust_grpc_library-rust_deps"></a>rust_deps | The crates the generated library depends on. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
633+
| <a id="rust_grpc_library-rustc_flags"></a>rustc_flags | List of compiler flags passed to <code>rustc</code>.<br><br> These strings are subject to Make variable expansion for predefined source/output path variables like <code>$location</code>, <code>$execpath</code>, and <code>$rootpath</code>. This expansion is useful if you wish to pass a generated file of arguments to rustc: <code>@$(location //package:target)</code>. | List of strings | optional | <code>[]</code> |
633634

634635

635636
<a id="rust_library"></a>
@@ -771,7 +772,7 @@ Builds a Rust proc-macro crate.
771772
## rust_proto_library
772773

773774
<pre>
774-
rust_proto_library(<a href="#rust_proto_library-name">name</a>, <a href="#rust_proto_library-deps">deps</a>, <a href="#rust_proto_library-rust_deps">rust_deps</a>)
775+
rust_proto_library(<a href="#rust_proto_library-name">name</a>, <a href="#rust_proto_library-deps">deps</a>, <a href="#rust_proto_library-rust_deps">rust_deps</a>, <a href="#rust_proto_library-rustc_flags">rustc_flags</a>)
775776
</pre>
776777

777778
Builds a Rust library crate from a set of `proto_library`s.
@@ -807,6 +808,7 @@ rust_binary(
807808
| <a id="rust_proto_library-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
808809
| <a id="rust_proto_library-deps"></a>deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding stubs. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
809810
| <a id="rust_proto_library-rust_deps"></a>rust_deps | The crates the generated library depends on. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
811+
| <a id="rust_proto_library-rustc_flags"></a>rustc_flags | List of compiler flags passed to <code>rustc</code>.<br><br> These strings are subject to Make variable expansion for predefined source/output path variables like <code>$location</code>, <code>$execpath</code>, and <code>$rootpath</code>. This expansion is useful if you wish to pass a generated file of arguments to rustc: <code>@$(location //package:target)</code>. | List of strings | optional | <code>[]</code> |
810812

811813

812814
<a id="rust_proto_toolchain"></a>

docs/rust_proto.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ configuration.
120120
## rust_grpc_library
121121

122122
<pre>
123-
rust_grpc_library(<a href="#rust_grpc_library-name">name</a>, <a href="#rust_grpc_library-deps">deps</a>, <a href="#rust_grpc_library-rust_deps">rust_deps</a>)
123+
rust_grpc_library(<a href="#rust_grpc_library-name">name</a>, <a href="#rust_grpc_library-deps">deps</a>, <a href="#rust_grpc_library-rust_deps">rust_deps</a>, <a href="#rust_grpc_library-rustc_flags">rustc_flags</a>)
124124
</pre>
125125

126126
Builds a Rust library crate from a set of `proto_library`s suitable for gRPC.
@@ -156,14 +156,15 @@ rust_binary(
156156
| <a id="rust_grpc_library-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
157157
| <a id="rust_grpc_library-deps"></a>deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding gRPC stubs. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
158158
| <a id="rust_grpc_library-rust_deps"></a>rust_deps | The crates the generated library depends on. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
159+
| <a id="rust_grpc_library-rustc_flags"></a>rustc_flags | List of compiler flags passed to <code>rustc</code>.<br><br> These strings are subject to Make variable expansion for predefined source/output path variables like <code>$location</code>, <code>$execpath</code>, and <code>$rootpath</code>. This expansion is useful if you wish to pass a generated file of arguments to rustc: <code>@$(location //package:target)</code>. | List of strings | optional | <code>[]</code> |
159160

160161

161162
<a id="rust_proto_library"></a>
162163

163164
## rust_proto_library
164165

165166
<pre>
166-
rust_proto_library(<a href="#rust_proto_library-name">name</a>, <a href="#rust_proto_library-deps">deps</a>, <a href="#rust_proto_library-rust_deps">rust_deps</a>)
167+
rust_proto_library(<a href="#rust_proto_library-name">name</a>, <a href="#rust_proto_library-deps">deps</a>, <a href="#rust_proto_library-rust_deps">rust_deps</a>, <a href="#rust_proto_library-rustc_flags">rustc_flags</a>)
167168
</pre>
168169

169170
Builds a Rust library crate from a set of `proto_library`s.
@@ -199,6 +200,7 @@ rust_binary(
199200
| <a id="rust_proto_library-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
200201
| <a id="rust_proto_library-deps"></a>deps | List of proto_library dependencies that will be built. One crate for each proto_library will be created with the corresponding stubs. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
201202
| <a id="rust_proto_library-rust_deps"></a>rust_deps | The crates the generated library depends on. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
203+
| <a id="rust_proto_library-rustc_flags"></a>rustc_flags | List of compiler flags passed to <code>rustc</code>.<br><br> These strings are subject to Make variable expansion for predefined source/output path variables like <code>$location</code>, <code>$execpath</code>, and <code>$rootpath</code>. This expansion is useful if you wish to pass a generated file of arguments to rustc: <code>@$(location //package:target)</code>. | List of strings | optional | <code>[]</code> |
202204

203205

204206
<a id="rust_proto_toolchain"></a>

proto/proto.bzl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ rust_proto_library = rule(
310310
"rust_deps": attr.label_list(
311311
doc = "The crates the generated library depends on.",
312312
),
313+
"rustc_flags": attr.string_list(
314+
doc = """\
315+
List of compiler flags passed to `rustc`.
316+
317+
These strings are subject to Make variable expansion for predefined
318+
source/output path variables like `$location`, `$execpath`, and
319+
`$rootpath`. This expansion is useful if you wish to pass a generated
320+
file of arguments to rustc: `@$(location //package:target)`.
321+
""",
322+
),
313323
"_cc_toolchain": attr.label(
314324
default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
315325
),
@@ -388,6 +398,16 @@ rust_grpc_library = rule(
388398
"rust_deps": attr.label_list(
389399
doc = "The crates the generated library depends on.",
390400
),
401+
"rustc_flags": attr.string_list(
402+
doc = """\
403+
List of compiler flags passed to `rustc`.
404+
405+
These strings are subject to Make variable expansion for predefined
406+
source/output path variables like `$location`, `$execpath`, and
407+
`$rootpath`. This expansion is useful if you wish to pass a generated
408+
file of arguments to rustc: `@$(location //package:target)`.
409+
""",
410+
),
391411
"_cc_toolchain": attr.label(
392412
default = "@bazel_tools//tools/cpp:current_cc_toolchain",
393413
),

0 commit comments

Comments
 (0)