summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-06-22 11:29:50 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-06-22 11:29:50 +0000
commita29753c0cbc836b60f49a786cd787a11051836be (patch)
tree1f16b733616a9294f03bc41b76f235439ce90b00
parent82392fdfd3ad47af56d8c26a1cb73a9d2509d387 (diff)
parent5a232e5a10e2ea582fe27b633e47924974f1e398 (diff)
downloadgrpcio-compiler-a29753c0cbc836b60f49a786cd787a11051836be.tar.gz
Upgrade rust/crates/grpcio-compiler to 0.9.0 am: 338911bd89 am: faab0d4a22 am: fcfdc54774 am: 5a232e5a10
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/grpcio-compiler/+/1742399 Change-Id: Iea14b072724fc00d3077a82986167d92288fac1e
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp2
-rw-r--r--Cargo.lock68
-rw-r--r--Cargo.toml6
-rw-r--r--Cargo.toml.orig6
-rw-r--r--METADATA8
-rw-r--r--src/bin/grpc_rust_prost.rs9
-rw-r--r--src/codegen.rs10
-rw-r--r--src/prost_codegen.rs25
9 files changed, 75 insertions, 61 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index da15913..2587a95 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "376d262f28aabfb1af755f928c9dd474eebc0e84"
+ "sha1": "7a48e0bb843e702832c1c3ac024c468dedf0023c"
}
}
diff --git a/Android.bp b/Android.bp
index b4c976d..317b655 100644
--- a/Android.bp
+++ b/Android.bp
@@ -65,4 +65,4 @@ rust_library_host {
}
// dependent_library ["feature_list"]
-// protobuf-2.22.1
+// protobuf-2.24.1
diff --git a/Cargo.lock b/Cargo.lock
index 0f0ebdf..72a664e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,9 +2,9 @@
# It is not intended for manual editing.
[[package]]
name = "anyhow"
-version = "1.0.38"
+version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1"
+checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
[[package]]
name = "autocfg"
@@ -55,9 +55,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "getrandom"
-version = "0.2.2"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
+checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if",
"libc",
@@ -66,7 +66,7 @@ dependencies = [
[[package]]
name = "grpcio-compiler"
-version = "0.8.0"
+version = "0.9.0"
dependencies = [
"derive-new",
"prost",
@@ -93,9 +93,9 @@ dependencies = [
[[package]]
name = "indexmap"
-version = "1.6.1"
+version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
+checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
@@ -112,9 +112,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.86"
+version = "0.2.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
+checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
[[package]]
name = "log"
@@ -127,9 +127,9 @@ dependencies = [
[[package]]
name = "multimap"
-version = "0.8.2"
+version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333"
+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]]
name = "petgraph"
@@ -149,9 +149,9 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "proc-macro2"
-version = "1.0.24"
+version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
+checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [
"unicode-xid",
]
@@ -209,9 +209,9 @@ dependencies = [
[[package]]
name = "protobuf"
-version = "2.22.0"
+version = "2.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73f72884896d22e0da0e5b266cb9a780b791f6c3b2f5beab6368d6cd4f0dbb86"
+checksum = "45604fc7a88158e7d514d8e22e14ac746081e7a70d7690074dd0029ee37458d6"
[[package]]
name = "quote"
@@ -264,9 +264,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
-version = "0.2.5"
+version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9"
+checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc"
dependencies = [
"bitflags",
]
@@ -282,9 +282,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.60"
+version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
+checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
dependencies = [
"proc-macro2",
"quote",
@@ -306,26 +306,6 @@ dependencies = [
]
[[package]]
-name = "thiserror"
-version = "1.0.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
-dependencies = [
- "thiserror-impl",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "1.0.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
name = "unicode-segmentation"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -333,9 +313,9 @@ checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-xid"
-version = "0.2.1"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "wasi"
@@ -345,12 +325,12 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "which"
-version = "4.0.2"
+version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef"
+checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe"
dependencies = [
+ "either",
"libc",
- "thiserror",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 52ed1ef..52cb1a5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "grpcio-compiler"
-version = "0.8.0"
+version = "0.9.0"
authors = ["The TiKV Project Developers"]
description = "gRPC compiler for grpcio"
homepage = "https://github.com/tikv/grpc-rs"
@@ -26,6 +26,10 @@ repository = "https://github.com/tikv/grpc-rs"
[[bin]]
name = "grpc_rust_plugin"
required-features = ["protobuf-codec"]
+
+[[bin]]
+name = "grpc_rust_prost"
+required-features = ["prost-codec"]
[dependencies.derive-new]
version = "0.5"
optional = true
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index cd2e87e..46c1e8b 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "grpcio-compiler"
-version = "0.8.0"
+version = "0.9.0"
edition = "2018"
authors = ["The TiKV Project Developers"]
license = "Apache-2.0"
@@ -27,3 +27,7 @@ tempfile = { version = "3.0", optional = true }
[[bin]]
name = "grpc_rust_plugin"
required-features = ["protobuf-codec"]
+
+[[bin]]
+name = "grpc_rust_prost"
+required-features = ["prost-codec"]
diff --git a/METADATA b/METADATA
index bdd92d1..01fad1f 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/grpcio-compiler/grpcio-compiler-0.8.0.crate"
+ value: "https://static.crates.io/crates/grpcio-compiler/grpcio-compiler-0.9.0.crate"
}
- version: "0.8.0"
+ version: "0.9.0"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 4
- day: 1
+ month: 6
+ day: 21
}
}
diff --git a/src/bin/grpc_rust_prost.rs b/src/bin/grpc_rust_prost.rs
new file mode 100644
index 0000000..431e625
--- /dev/null
+++ b/src/bin/grpc_rust_prost.rs
@@ -0,0 +1,9 @@
+// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
+
+extern crate grpcio_compiler;
+
+use grpcio_compiler::prost_codegen;
+
+fn main() {
+ prost_codegen::protoc_gen_grpc_rust_main();
+}
diff --git a/src/codegen.rs b/src/codegen.rs
index 2a41105..e2f6c10 100644
--- a/src/codegen.rs
+++ b/src/codegen.rs
@@ -151,10 +151,6 @@ impl<'a> CodeWriter<'a> {
}
}
- pub fn fn_def(&mut self, sig: &str) {
- self.write_line(&format!("fn {};", sig));
- }
-
pub fn fn_block<F>(&mut self, public: bool, sig: &str, cb: F)
where
F: Fn(&mut CodeWriter),
@@ -502,7 +498,7 @@ impl<'a> MethodGen<'a> {
MethodType::Duplex => ("stream", req_stream_type, "DuplexSink"),
};
let sig = format!(
- "{}(&mut self, ctx: {}, {}: {}, sink: {}<{}>)",
+ "{}(&mut self, ctx: {}, _{}: {}, sink: {}<{}>)",
self.name(),
fq_grpc("RpcContext"),
req,
@@ -510,7 +506,9 @@ impl<'a> MethodGen<'a> {
fq_grpc(resp_type),
self.output()
);
- w.fn_def(&sig);
+ w.fn_block(false, &sig, |w| {
+ w.write_line("grpcio::unimplemented_call!(ctx, sink)");
+ });
}
fn write_bind(&self, w: &mut CodeWriter) {
diff --git a/src/prost_codegen.rs b/src/prost_codegen.rs
index e2d7533..4457c02 100644
--- a/src/prost_codegen.rs
+++ b/src/prost_codegen.rs
@@ -2,7 +2,7 @@
use std::io::{Error, ErrorKind, Read};
use std::path::Path;
-use std::{fs, io, process::Command};
+use std::{env, fs, io, process::Command, str};
use derive_new::new;
use prost::Message;
@@ -510,14 +510,14 @@ fn generate_server_method(
buf.push_str(&method.name);
buf.push_str("(&mut self, ctx: ");
buf.push_str(&fq_grpc("RpcContext"));
- buf.push_str(", ");
+ buf.push_str(", _");
buf.push_str(request_arg);
buf.push_str(", sink: ");
buf.push_str(&fq_grpc(response_type));
buf.push('<');
buf.push_str(&method.output_type);
buf.push('>');
- buf.push_str(");\n");
+ buf.push_str(") { grpcio::unimplemented_call!(ctx, sink) }\n");
}
fn generate_method_bind(service_name: &str, method: &Method, buf: &mut String) {
@@ -536,3 +536,22 @@ fn generate_method_bind(service_name: &str, method: &Method, buf: &mut String) {
buf.push_str(&method.name);
buf.push_str("(ctx, req, resp));\n");
}
+
+pub fn protoc_gen_grpc_rust_main() {
+ let mut args = env::args();
+ args.next();
+ let (mut protos, mut includes, mut out_dir): (Vec<_>, Vec<_>, _) = Default::default();
+ for arg in args {
+ if let Some(value) = arg.strip_prefix("--protos=") {
+ protos.extend(value.split(",").map(|s| s.to_string()));
+ } else if let Some(value) = arg.strip_prefix("--includes=") {
+ includes.extend(value.split(",").map(|s| s.to_string()));
+ } else if let Some(value) = arg.strip_prefix("--out-dir=") {
+ out_dir = value.to_string();
+ }
+ }
+ if protos.is_empty() {
+ panic!("should at least specify protos to generate");
+ }
+ compile_protos(&protos, &includes, &out_dir).unwrap();
+}