From 64139c07ddca1f56d630c6e6b4730d8ad505890d Mon Sep 17 00:00:00 2001 From: Dmitrii Mastitskii <89485375+DMoscicki@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:58:14 +0100 Subject: [PATCH] Rename protoc-bin-rust to protoc-bin-rs `protoc --rust_out=` no longer works because Google is working on official Rust plugin. --- .gitignore | 2 +- protobuf-codegen/Cargo.toml | 6 +++--- protobuf-codegen/README.md | 14 +++++++------- protobuf-codegen/src/bin/protoc-gen-rs.rs | 3 +++ protobuf-codegen/src/bin/protoc-gen-rust.rs | 3 --- protobuf-codegen/src/codegen/mod.rs | 6 +++--- protobuf-codegen/src/customize/mod.rs | 2 +- protobuf-codegen/src/lib.rs | 14 +++++++------- .../src/{protoc_gen_rust.rs => protoc_gen_rs.rs} | 2 +- protobuf-examples/pure-vs-protoc/build.rs | 2 +- protobuf-parse/src/protoc/command.rs | 2 +- protobuf/regenerate.sh | 6 +++--- protobuf/src/descriptor.rs | 2 +- protobuf/src/doctest_pb.rs | 2 +- protobuf/src/plugin.rs | 2 +- protobuf/src/rustproto.rs | 2 +- protobuf/src/well_known_types/any.rs | 2 +- protobuf/src/well_known_types/api.rs | 2 +- protobuf/src/well_known_types/duration.rs | 2 +- protobuf/src/well_known_types/empty.rs | 2 +- protobuf/src/well_known_types/field_mask.rs | 2 +- protobuf/src/well_known_types/source_context.rs | 2 +- protobuf/src/well_known_types/struct_.rs | 2 +- protobuf/src/well_known_types/timestamp.rs | 2 +- protobuf/src/well_known_types/type_.rs | 2 +- protobuf/src/well_known_types/wrappers.rs | 2 +- 26 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 protobuf-codegen/src/bin/protoc-gen-rs.rs delete mode 100644 protobuf-codegen/src/bin/protoc-gen-rust.rs rename protobuf-codegen/src/{protoc_gen_rust.rs => protoc_gen_rs.rs} (93%) diff --git a/.gitignore b/.gitignore index 15d92cbc9..c9f644607 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ src/test/v*/pb_*.rs src/test/v*/*_pb.rs src/test/lib protobuf-bin-gen-rust -protoc-gen-rust +protoc-gen-rs target/ Cargo.lock .idea diff --git a/protobuf-codegen/Cargo.toml b/protobuf-codegen/Cargo.toml index 00dabb3ac..ff6332b57 100644 --- a/protobuf-codegen/Cargo.toml +++ b/protobuf-codegen/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/stepancheg/rust-protobuf/" description = """ Code generator for rust-protobuf. -Includes a library to invoke programmatically (e. g. from `build.rs`) and `protoc-gen-rust` binary. +Includes a library to invoke programmatically (e. g. from `build.rs`) and `protoc-gen-rs` binary. """ [lib] @@ -27,8 +27,8 @@ protobuf-parse = { path = "../protobuf-parse", version = "=4.0.0-alpha.0" } [[bin]] -name = "protoc-gen-rust" -path = "src/bin/protoc-gen-rust.rs" +name = "protoc-gen-rs" +path = "src/bin/protoc-gen-rs.rs" test = false [package.metadata.docs.rs] diff --git a/protobuf-codegen/README.md b/protobuf-codegen/README.md index 5f1e2d764..90aa0522f 100644 --- a/protobuf-codegen/README.md +++ b/protobuf-codegen/README.md @@ -7,14 +7,14 @@ This crate is useful mostly from `build.rs` scripts to generate `.rs` files duri # How to generate code There are three main ways to generate `.rs` files from `.proto` files: -* using `protoc` command line tool and `protoc-gen-rust` plugin +* using `protoc` command line tool and `protoc-gen-rs` plugin * using this crate `Codegen` with pure rust parser * using this crate `Codegen` with `protoc` parser Which one should you use depends on your needs. If you are using non-cargo build system (like Bazel), you might prefer -using `protoc-gen-rust` plugin for `protoc`. +using `protoc-gen-rs` plugin for `protoc`. If you build with `cargo`, you probably want to use `Codegen` from this crate. @@ -54,12 +54,12 @@ protobuf_codegen::Codegen::new() .run_from_script(); ``` -## How to use `protoc-gen-rust` +## How to use `protoc-gen-rs` If you have to. (Note `protoc` can be invoked programmatically with -[protoc crate](https://docs.rs/protoc/%3E=3.0.0-alpha)) +[protoc crate](https://docs.rs/protoc/%3E=3.1.0-alpha)) 0) Install protobuf for `protoc` binary. @@ -78,11 +78,11 @@ apt-get install protobuf-compiler Protobuf is needed only for code generation, `rust-protobuf` runtime does not use C++ protobuf library. -1) Install `protoc-gen-rust` program (which is `protoc` plugin) +1) Install `protoc-gen-rs` program (which is `protoc` plugin) It can be installed either from source or with `cargo install protobuf-codegen` command. -2) Add `protoc-gen-rust` to $PATH +2) Add `protoc-gen-rs` to $PATH If you installed it with cargo, it should be @@ -93,7 +93,7 @@ PATH="$HOME/.cargo/bin:$PATH" 3) Generate .rs files: ```sh -protoc --rust_out . foo.proto +protoc --rs_out . foo.proto ``` This will generate .rs files in current directory. diff --git a/protobuf-codegen/src/bin/protoc-gen-rs.rs b/protobuf-codegen/src/bin/protoc-gen-rs.rs new file mode 100644 index 000000000..71de4ce99 --- /dev/null +++ b/protobuf-codegen/src/bin/protoc-gen-rs.rs @@ -0,0 +1,3 @@ +fn main() { + protobuf_codegen::protoc_gen_rs::protoc_gen_rust_main(); +} diff --git a/protobuf-codegen/src/bin/protoc-gen-rust.rs b/protobuf-codegen/src/bin/protoc-gen-rust.rs deleted file mode 100644 index 8c34e49b5..000000000 --- a/protobuf-codegen/src/bin/protoc-gen-rust.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - protobuf_codegen::protoc_gen_rust::protoc_gen_rust_main(); -} diff --git a/protobuf-codegen/src/codegen/mod.rs b/protobuf-codegen/src/codegen/mod.rs index 2e6406cdc..aab0142e8 100644 --- a/protobuf-codegen/src/codegen/mod.rs +++ b/protobuf-codegen/src/codegen/mod.rs @@ -34,7 +34,7 @@ enum CodegenError { /// Entry point for `.proto` to `.rs` code generation. /// -/// This is similar to `protoc --rust_out...`. +/// This is similar to `protoc --rs_out...`. #[derive(Debug, Default)] pub struct Codegen { /// What parser to use to parse `.proto` files. @@ -208,8 +208,8 @@ impl Codegen { /// Invoke the code generation. /// - /// This is roughly equivalent to `protoc --rust_out=...` but - /// without requiring `protoc-gen-rust` command in `$PATH`. + /// This is roughly equivalent to `protoc --rs_out=...` but + /// without requiring `protoc-gen-rs` command in `$PATH`. /// /// This function uses pure Rust parser or `protoc` parser depending on /// how this object was configured. diff --git a/protobuf-codegen/src/customize/mod.rs b/protobuf-codegen/src/customize/mod.rs index 22cc7d550..729aa4dd8 100644 --- a/protobuf-codegen/src/customize/mod.rs +++ b/protobuf-codegen/src/customize/mod.rs @@ -161,7 +161,7 @@ impl Customize { /// So the generated code (and more importantly, generated binary size) is smaller, /// but reflection, text format, JSON serialization won't work. /// - /// Note when using `protoc` plugin `protoc-gen-rust`, the option name is just `lite`. + /// Note when using `protoc` plugin `protoc-gen-rs`, the option name is just `lite`. pub fn lite_runtime(mut self, lite_runtime: bool) -> Self { self.lite_runtime = Some(lite_runtime); self diff --git a/protobuf-codegen/src/lib.rs b/protobuf-codegen/src/lib.rs index 0471d7c2d..847f90e62 100644 --- a/protobuf-codegen/src/lib.rs +++ b/protobuf-codegen/src/lib.rs @@ -5,14 +5,14 @@ //! # How to generate code //! //! There are three main ways to generate `.rs` files from `.proto` files: -//! * using `protoc` command line tool and `protoc-gen-rust` plugin +//! * using `protoc` command line tool and `protoc-gen-rs` plugin //! * using this crate `Codegen` with pure rust parser //! * using this crate `Codegen` with `protoc` parser //! //! Which one should you use depends on your needs. //! //! If you are using non-cargo build system (like Bazel), you might prefer -//! using `protoc-gen-rust` plugin for `protoc`. +//! using `protoc-gen-rs` plugin for `protoc`. //! //! If you build with `cargo`, you probably want to use `Codegen` from this crate. //! @@ -57,7 +57,7 @@ //! .run_from_script(); //! ``` //! -//! ## How to use `protoc-gen-rust` +//! ## How to use `protoc-gen-rs` //! //! If you have to. //! @@ -81,11 +81,11 @@ //! Protobuf is needed only for code generation, `rust-protobuf` runtime //! does not use C++ protobuf library. //! -//! 1) Install `protoc-gen-rust` program (which is `protoc` plugin) +//! 1) Install `protoc-gen-rs` program (which is `protoc` plugin) //! //! It can be installed either from source or with `cargo install protobuf-codegen` command. //! -//! 2) Add `protoc-gen-rust` to $PATH +//! 2) Add `protoc-gen-rs` to $PATH //! //! If you installed it with cargo, it should be //! @@ -96,7 +96,7 @@ //! 3) Generate .rs files: //! //! ```sh -//! protoc --rust_out . foo.proto +//! protoc --rs_out . foo.proto //! ``` //! //! This will generate .rs files in current directory. @@ -136,7 +136,7 @@ mod compiler_plugin; mod customize; mod gen; pub mod gen_and_write; -pub mod protoc_gen_rust; +pub mod protoc_gen_rs; pub use codegen::Codegen; pub use customize::Customize; diff --git a/protobuf-codegen/src/protoc_gen_rust.rs b/protobuf-codegen/src/protoc_gen_rs.rs similarity index 93% rename from protobuf-codegen/src/protoc_gen_rust.rs rename to protobuf-codegen/src/protoc_gen_rs.rs index fcfacabec..8cfb7a0e2 100644 --- a/protobuf-codegen/src/protoc_gen_rust.rs +++ b/protobuf-codegen/src/protoc_gen_rs.rs @@ -11,7 +11,7 @@ pub fn protoc_gen_rust_main() { let customize = Customize::parse_from_parameter(r.parameter).expect("parse options"); gen_all( r.file_descriptors, - "protoc --rust_out=...", + "protoc --rs_out=...", r.files_to_generate, &customize, &CustomizeCallbackDefault, diff --git a/protobuf-examples/pure-vs-protoc/build.rs b/protobuf-examples/pure-vs-protoc/build.rs index 5e4385977..7bafeb814 100644 --- a/protobuf-examples/pure-vs-protoc/build.rs +++ b/protobuf-examples/pure-vs-protoc/build.rs @@ -5,7 +5,7 @@ fn main() { // and with codegen depending on `protoc` binary. // This is for demonstration purposes; in practice you'd need either of them. // - // Note there's a third option: using `protoc` binary directly and `protoc-gen-rust` + // Note there's a third option: using `protoc` binary directly and `protoc-gen-rs` // plugin, this is a canonical way to generate protobuf sources. // This is not possible to do with Cargo (since Cargo cannot depend on binaries) // but can be used with some other build system. diff --git a/protobuf-parse/src/protoc/command.rs b/protobuf-parse/src/protoc/command.rs index f29d7e377..0f972d074 100644 --- a/protobuf-parse/src/protoc/command.rs +++ b/protobuf-parse/src/protoc/command.rs @@ -3,7 +3,7 @@ //! `protoc` command must be in `$PATH`, along with `protoc-gen-LANG` command. //! //! Note that to generate `rust` code from `.proto` files, `protoc-rust` crate -//! can be used, which does not require `protoc-gen-rust` present in `$PATH`. +//! can be used, which does not require `protoc-gen-rs` present in `$PATH`. #![deny(missing_docs)] #![deny(rustdoc::broken_intra_doc_links)] diff --git a/protobuf/regenerate.sh b/protobuf/regenerate.sh index 4987e8eee..f8c23fdbf 100755 --- a/protobuf/regenerate.sh +++ b/protobuf/regenerate.sh @@ -32,9 +32,9 @@ MSYS_NT*) esac "$PROTOC" \ - --plugin=protoc-gen-rust="$where_am_i/target/debug/protoc-gen-rust$exe_suffix" \ - --rust_out tmp-generated \ - --rust_opt 'inside_protobuf=true gen_mod_rs=false' \ + --plugin=protoc-gen-rs="$where_am_i/target/debug/protoc-gen-rs$exe_suffix" \ + --rs_out tmp-generated \ + --rs_opt 'inside_protobuf=true gen_mod_rs=false' \ -I../proto \ ../proto/google/protobuf/*.proto \ ../proto/google/protobuf/compiler/*.proto \ diff --git a/protobuf/src/descriptor.rs b/protobuf/src/descriptor.rs index 2b5459b3b..2c296f4d8 100644 --- a/protobuf/src/descriptor.rs +++ b/protobuf/src/descriptor.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/doctest_pb.rs b/protobuf/src/doctest_pb.rs index 48e174c51..4c7df20f1 100644 --- a/protobuf/src/doctest_pb.rs +++ b/protobuf/src/doctest_pb.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/plugin.rs b/protobuf/src/plugin.rs index 2bd9bf14d..123e3076d 100644 --- a/protobuf/src/plugin.rs +++ b/protobuf/src/plugin.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/rustproto.rs b/protobuf/src/rustproto.rs index 2c634573e..ad38f667b 100644 --- a/protobuf/src/rustproto.rs +++ b/protobuf/src/rustproto.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/any.rs b/protobuf/src/well_known_types/any.rs index fbf92a477..4b4b21979 100644 --- a/protobuf/src/well_known_types/any.rs +++ b/protobuf/src/well_known_types/any.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/api.rs b/protobuf/src/well_known_types/api.rs index 61fa2eb9b..a4f54cb5e 100644 --- a/protobuf/src/well_known_types/api.rs +++ b/protobuf/src/well_known_types/api.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/duration.rs b/protobuf/src/well_known_types/duration.rs index aeb674fd0..6cd6c75e0 100644 --- a/protobuf/src/well_known_types/duration.rs +++ b/protobuf/src/well_known_types/duration.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/empty.rs b/protobuf/src/well_known_types/empty.rs index e7c1ebb29..0e0ffadad 100644 --- a/protobuf/src/well_known_types/empty.rs +++ b/protobuf/src/well_known_types/empty.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/field_mask.rs b/protobuf/src/well_known_types/field_mask.rs index b4b1cdee2..eacb6b292 100644 --- a/protobuf/src/well_known_types/field_mask.rs +++ b/protobuf/src/well_known_types/field_mask.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/source_context.rs b/protobuf/src/well_known_types/source_context.rs index f5eb706df..f85ff6a85 100644 --- a/protobuf/src/well_known_types/source_context.rs +++ b/protobuf/src/well_known_types/source_context.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/struct_.rs b/protobuf/src/well_known_types/struct_.rs index 946e4e650..d63829ec4 100644 --- a/protobuf/src/well_known_types/struct_.rs +++ b/protobuf/src/well_known_types/struct_.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/timestamp.rs b/protobuf/src/well_known_types/timestamp.rs index 1218598e4..0ddde14d0 100644 --- a/protobuf/src/well_known_types/timestamp.rs +++ b/protobuf/src/well_known_types/timestamp.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/type_.rs b/protobuf/src/well_known_types/type_.rs index e291a2eb9..437d26b48 100644 --- a/protobuf/src/well_known_types/type_.rs +++ b/protobuf/src/well_known_types/type_.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702 diff --git a/protobuf/src/well_known_types/wrappers.rs b/protobuf/src/well_known_types/wrappers.rs index b586e6980..2babd0db9 100644 --- a/protobuf/src/well_known_types/wrappers.rs +++ b/protobuf/src/well_known_types/wrappers.rs @@ -1,5 +1,5 @@ // This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit -// .proto file is parsed by protoc --rust_out=... +// .proto file is parsed by protoc --rs_out=... // @generated // https://github.com/rust-lang/rust-clippy/issues/702