Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: change --rust_out to --rs_out #744

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion CHANGELOG-before-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Changelog after version 3.0.0 lives in [CHANGELOG.md](CHANGELOG.md).
## [3.0.0-alpha.8] - 2022-02-21

- Lite runtime generation is restored. When lite runtime requested, code is generated without reflection support.
- `lite` option can be specified when using `protoc-gen-rust` plugin similarly to how
- `lite` option can be specified when using `protoc-gen-rs` plugin similarly to how
[C++ or Java do](https://github.com/protocolbuffers/protobuf/issues/6489).

## [3.0.0-alpha.7] - 2022-02-20
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
## [3.0.3] - 2022-05-31

* `optional` fields in proto3 are now
[handled correctly in `protoc-gen-rust` plugin for `protoc`](https://github.com/stepancheg/rust-protobuf/issues/625)
[handled correctly in `protoc-gen-rs` plugin for `protoc`](https://github.com/stepancheg/rust-protobuf/issues/625)

## [3.0.2] - 2022-05-06

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
12 changes: 6 additions & 6 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,7 +54,7 @@ protobuf_codegen::Codegen::new()
.run_from_script();
```

## How to use `protoc-gen-rust`
## How to use `protoc-gen-rs`

If you have to.

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
4 changes: 2 additions & 2 deletions protobuf/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ MSYS_NT*)
esac

"$PROTOC" \
--plugin=protoc-gen-rust="$where_am_i/target/debug/protoc-gen-rust$exe_suffix" \
--rust_out tmp-generated \
--plugin=protoc-gen-rs="$where_am_i/target/debug/protoc-gen-rs$exe_suffix" \
--rs_out tmp-generated \
--rust_opt 'inside_protobuf=true gen_mod_rs=false' \
-I../proto \
../proto/google/protobuf/*.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 Expand Up @@ -27,7 +27,7 @@
/// from API Services, which represent a concrete implementation of an interface
/// as opposed to simply a description of methods and bindings. They are also
/// sometimes simply referred to as "APIs" in other contexts, such as the name of
/// this message itself. See https://cloud.google.com/apis/design/glossary for

Check warning on line 30 in protobuf/src/well_known_types/api.rs

View workflow job for this annotation

GitHub Actions / linux nightly (all features)

this URL is not a hyperlink
/// detailed terminology.
// @@protoc_insertion_point(message:google.protobuf.Api)
#[derive(PartialEq,Clone,Default,Debug)]
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
Loading