Skip to content

Commit dfde953

Browse files
author
Snow Pettersen
committed
Merge branch 'master' of github.com:stepancheg/rust-protobuf into patch-stack
2 parents 9e9818e + a542121 commit dfde953

File tree

48 files changed

+436
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+436
-310
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ src/test/v*/pb_*.rs
1111
src/test/v*/*_pb.rs
1212
src/test/lib
1313
protobuf-bin-gen-rust
14-
protoc-gen-rust
14+
protoc-gen-rs
1515
target/
1616
Cargo.lock
1717
.idea

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
# Changelog
22

3-
## [3.6] - Unreleased
3+
## Unreleased
44

5-
## [3.5.1] - Unreleased
5+
## [3.7.1] - Unrelease
6+
7+
- `protoc-gen-rust` renamed to `protoc-gen-rs`. `protoc --rust_out=` no longer works with latest Google protobuf,
8+
they are working on official protobuf support for Rust.
9+
- Do not detect nightly in `protobuf` crate (no longer needed)
10+
- [Repeated fields in constants](https://github.com/stepancheg/rust-protobuf/pull/740)
11+
12+
## [3.6.0] - 2024-09-30
13+
14+
- [Fix text format parsing of non-ASCII](https://github.com/stepancheg/rust-protobuf/pull/730)
15+
16+
## [3.5.1] - 2024-08-19
617

718
- [Remove deprecated `box_pointers` lint](https://github.com/stepancheg/rust-protobuf/pull/733)
819

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ members = [
2424
"test-crates/protobuf-test",
2525
"test-crates/protobuf-test-common",
2626
]
27+
28+
[workspace.dependencies]
29+
protoc-bin-vendored = "=3.1.0"

protobuf-codegen/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository = "https://github.com/stepancheg/rust-protobuf/"
99
description = """
1010
Code generator for rust-protobuf.
1111
12-
Includes a library to invoke programmatically (e. g. from `build.rs`) and `protoc-gen-rust` binary.
12+
Includes a library to invoke programmatically (e. g. from `build.rs`) and `protoc-gen-rs` binary.
1313
"""
1414

1515
[lib]
@@ -27,8 +27,8 @@ protobuf-parse = { path = "../protobuf-parse", version = "=4.0.0-alpha.0" }
2727

2828
[[bin]]
2929

30-
name = "protoc-gen-rust"
31-
path = "src/bin/protoc-gen-rust.rs"
30+
name = "protoc-gen-rs"
31+
path = "src/bin/protoc-gen-rs.rs"
3232
test = false
3333

3434
[package.metadata.docs.rs]

protobuf-codegen/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ This crate is useful mostly from `build.rs` scripts to generate `.rs` files duri
77
# How to generate code
88

99
There are three main ways to generate `.rs` files from `.proto` files:
10-
* using `protoc` command line tool and `protoc-gen-rust` plugin
10+
* using `protoc` command line tool and `protoc-gen-rs` plugin
1111
* using this crate `Codegen` with pure rust parser
1212
* using this crate `Codegen` with `protoc` parser
1313

1414
Which one should you use depends on your needs.
1515

1616
If you are using non-cargo build system (like Bazel), you might prefer
17-
using `protoc-gen-rust` plugin for `protoc`.
17+
using `protoc-gen-rs` plugin for `protoc`.
1818

1919
If you build with `cargo`, you probably want to use `Codegen` from this crate.
2020

@@ -54,12 +54,12 @@ protobuf_codegen::Codegen::new()
5454
.run_from_script();
5555
```
5656

57-
## How to use `protoc-gen-rust`
57+
## How to use `protoc-gen-rs`
5858

5959
If you have to.
6060

6161
(Note `protoc` can be invoked programmatically with
62-
[protoc crate](https://docs.rs/protoc/%3E=3.0.0-alpha))
62+
[protoc crate](https://docs.rs/protoc/))
6363

6464
0) Install protobuf for `protoc` binary.
6565

@@ -78,11 +78,11 @@ apt-get install protobuf-compiler
7878
Protobuf is needed only for code generation, `rust-protobuf` runtime
7979
does not use C++ protobuf library.
8080

81-
1) Install `protoc-gen-rust` program (which is `protoc` plugin)
81+
1) Install `protoc-gen-rs` program (which is `protoc` plugin)
8282

8383
It can be installed either from source or with `cargo install protobuf-codegen` command.
8484

85-
2) Add `protoc-gen-rust` to $PATH
85+
2) Add `protoc-gen-rs` to $PATH
8686

8787
If you installed it with cargo, it should be
8888

@@ -93,7 +93,7 @@ PATH="$HOME/.cargo/bin:$PATH"
9393
3) Generate .rs files:
9494

9595
```sh
96-
protoc --rust_out . foo.proto
96+
protoc --rs_out . foo.proto
9797
```
9898

9999
This will generate .rs files in current directory.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
protobuf_codegen::protoc_gen_rs::protoc_gen_rust_main();
3+
}

protobuf-codegen/src/bin/protoc-gen-rust.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

protobuf-codegen/src/codegen/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum CodegenError {
3434

3535
/// Entry point for `.proto` to `.rs` code generation.
3636
///
37-
/// This is similar to `protoc --rust_out...`.
37+
/// This is similar to `protoc --rs_out...`.
3838
#[derive(Debug, Default)]
3939
pub struct Codegen {
4040
/// What parser to use to parse `.proto` files.
@@ -208,8 +208,8 @@ impl Codegen {
208208

209209
/// Invoke the code generation.
210210
///
211-
/// This is roughly equivalent to `protoc --rust_out=...` but
212-
/// without requiring `protoc-gen-rust` command in `$PATH`.
211+
/// This is roughly equivalent to `protoc --rs_out=...` but
212+
/// without requiring `protoc-gen-rs` command in `$PATH`.
213213
///
214214
/// This function uses pure Rust parser or `protoc` parser depending on
215215
/// how this object was configured.

protobuf-codegen/src/customize/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Customize {
168168
/// So the generated code (and more importantly, generated binary size) is smaller,
169169
/// but reflection, text format, JSON serialization won't work.
170170
///
171-
/// Note when using `protoc` plugin `protoc-gen-rust`, the option name is just `lite`.
171+
/// Note when using `protoc` plugin `protoc-gen-rs`, the option name is just `lite`.
172172
pub fn lite_runtime(mut self, lite_runtime: bool) -> Self {
173173
self.lite_runtime = Some(lite_runtime);
174174
self

protobuf-codegen/src/gen/message.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a> MessageGen<'a> {
146146
.collect()
147147
}
148148

149-
fn required_fields(&'a self) -> Vec<&'a FieldGen> {
149+
fn required_fields(&'a self) -> Vec<&'a FieldGen<'a>> {
150150
self.fields
151151
.iter()
152152
.filter(|f| match f.kind {
@@ -156,14 +156,14 @@ impl<'a> MessageGen<'a> {
156156
.collect()
157157
}
158158

159-
fn message_fields(&'a self) -> Vec<&'a FieldGen> {
159+
fn message_fields(&'a self) -> Vec<&'a FieldGen<'a>> {
160160
self.fields
161161
.iter()
162162
.filter(|f| f.proto_type == field_descriptor_proto::Type::TYPE_MESSAGE)
163163
.collect()
164164
}
165165

166-
fn fields_except_oneof(&'a self) -> Vec<&'a FieldGen> {
166+
fn fields_except_oneof(&'a self) -> Vec<&'a FieldGen<'a>> {
167167
self.fields
168168
.iter()
169169
.filter(|f| match f.kind {
@@ -173,14 +173,14 @@ impl<'a> MessageGen<'a> {
173173
.collect()
174174
}
175175

176-
fn fields_except_group(&'a self) -> Vec<&'a FieldGen> {
176+
fn fields_except_group(&'a self) -> Vec<&'a FieldGen<'a>> {
177177
self.fields
178178
.iter()
179179
.filter(|f| f.proto_type != field_descriptor_proto::Type::TYPE_GROUP)
180180
.collect()
181181
}
182182

183-
fn fields_except_oneof_and_group(&'a self) -> Vec<&'a FieldGen> {
183+
fn fields_except_oneof_and_group(&'a self) -> Vec<&'a FieldGen<'a>> {
184184
self.fields
185185
.iter()
186186
.filter(|f| match f.kind {

0 commit comments

Comments
 (0)