Skip to content

Commit 6c3629f

Browse files
mvanbem-googcopybara-github
authored andcommitted
Internal-only change
PiperOrigin-RevId: 833859781
1 parent 37731cc commit 6c3629f

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

rs_bindings_from_cc/bazel_support/additional_rust_srcs_for_crubit_bindings_aspect_hint.bzl

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,45 +85,66 @@ def _additional_rust_srcs_for_crubit_bindings_impl(ctx):
8585
ctx.attr.cc_deps,
8686
)]
8787

88-
additional_rust_srcs_for_crubit_bindings = rule(
88+
_additional_rust_srcs_for_crubit_bindings_rule = rule(
8989
attrs = {
9090
"srcs": attr.label_list(
91-
doc = "The Rust source files to be included in addition to generated Rust bindings.",
9291
allow_files = True,
9392
mandatory = True,
9493
),
9594
"namespace_path": attr.string(
96-
doc = """This allows Rust source files define new entries inside of a specific existing C++ namespace instead of the top level namespace.
97-
For modules which are not existing namespace names, use `pub mod` statement in the Rust source file instead.""",
9895
mandatory = False,
9996
default = "",
10097
),
10198
"deps": attr.label_list(
102-
doc = """List of other libraries to be linked to this library target.
103-
104-
This accepts the same deps as rust_library.""",
10599
mandatory = False,
106100
default = [],
107101
),
108102
"cc_deps": attr.label_list(
109-
doc = """List of cc_library targets whose crubit-generated bindings will be made available to this library target.""",
110103
mandatory = False,
111104
default = [],
112105
aspects = [rust_bindings_from_cc_aspect],
113106
),
114107
},
115108
implementation = _additional_rust_srcs_for_crubit_bindings_impl,
116-
doc = """
117-
Defines an aspect hint that is used to pass extra Rust source files to `rs_bindings_from_cc` tool's
118-
`extra_rs_srcs` CLI argument.
119-
120-
Note: to use `std` in the extra Rust source files, you must use:
121-
```rust
122-
extern crate std;
123-
```
124-
""",
125109
)
126110

111+
def additional_rust_srcs_for_crubit_bindings(
112+
name,
113+
srcs,
114+
namespace_path = "",
115+
deps = [],
116+
cc_deps = [],
117+
**kwargs):
118+
"""
119+
Defines an aspect hint that is used to pass extra Rust source files to `rs_bindings_from_cc` tool's `extra_rs_srcs` CLI argument.
120+
121+
Note: to use `std` in the extra Rust source files, you must use:
122+
```rust
123+
extern crate std;
124+
```
125+
126+
Args:
127+
name: Aspect hint name.
128+
srcs: The Rust source files to be included in addition to generated Rust bindings.
129+
namespace_path: This allows Rust source files define new entries inside of a specific
130+
existing C++ namespace instead of the top level namespace. For modules which are not
131+
existing namespace names, use `pub mod` statement in the Rust source file instead.
132+
deps: List of other libraries to be linked to this library target. This accepts the same
133+
deps as rust_library.
134+
cc_deps: List of cc_library targets whose crubit-generated bindings will be made available
135+
to this library target.
136+
**kwargs: Args passed through to the underlying rule (visibility, etc.).
137+
"""
138+
139+
_additional_rust_srcs_for_crubit_bindings_rule(
140+
name = name,
141+
srcs = srcs,
142+
namespace_path = namespace_path,
143+
deps = deps,
144+
cc_deps = cc_deps,
145+
**kwargs
146+
)
147+
127148
def _create_dep_variant_info(dep):
128149
return DepVariantInfo(
129150
crate_info = dep[CrateInfo] if CrateInfo in dep else None,

0 commit comments

Comments
 (0)