Skip to content

Commit

Permalink
Rename protoc-bin-rust to protoc-bin-rs
Browse files Browse the repository at this point in the history
`protoc --rust_out=` no longer works because Google is working on
official Rust plugin.
  • Loading branch information
DMoscicki authored and stepancheg committed Oct 15, 2024
1 parent 6c49f4e commit 64139c0
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions protobuf-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
14 changes: 7 additions & 7 deletions protobuf-codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand All @@ -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

Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions protobuf-codegen/src/bin/protoc-gen-rs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
protobuf_codegen::protoc_gen_rs::protoc_gen_rust_main();
}
3 changes: 0 additions & 3 deletions protobuf-codegen/src/bin/protoc-gen-rust.rs

This file was deleted.

6 changes: 3 additions & 3 deletions protobuf-codegen/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion protobuf-codegen/src/customize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions protobuf-codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down Expand Up @@ -57,7 +57,7 @@
//! .run_from_script();
//! ```
//!
//! ## How to use `protoc-gen-rust`
//! ## How to use `protoc-gen-rs`
//!
//! If you have to.
//!
Expand All @@ -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
//!
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion protobuf-examples/pure-vs-protoc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion protobuf-parse/src/protoc/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions protobuf/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/descriptor.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/doctest_pb.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/rustproto.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/any.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/api.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/duration.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/empty.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/field_mask.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/source_context.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/struct_.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/timestamp.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/type_.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion protobuf/src/well_known_types/wrappers.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 64139c0

Please sign in to comment.