Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tikv/grpc-rs into aarch-b…
Browse files Browse the repository at this point in the history
…indgen

Signed-off-by: glorv <glorvs@163.com>
  • Loading branch information
glorv committed Mar 3, 2020
2 parents 08abcba + 84b0d7c commit 16106e3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ matrix:

- os: linux
arch: arm64
addons:
apt:
packages:
rust: stable

- os: linux
arch: amd64
Expand Down
14 changes: 7 additions & 7 deletions compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ categories = ["network-programming"]

[features]
default = ["protobuf-codec"]
protobuf-codec = []
prost-codec = ["prost-build", "prost-types", "prost", "derive-new"]
protobuf-codec = ["protobuf"]
prost-codec = ["prost-build", "prost-types", "prost", "derive-new", "tempfile"]

[dependencies]
protobuf = "2"
prost = { version = "0.5", optional = true }
prost-build = { version = "0.5", optional = true }
prost-types = { version = "0.5", optional = true }
protobuf = { version = "2", optional = true }
prost = { version = "0.6", optional = true }
prost-build = { version = "0.6", optional = true }
prost-types = { version = "0.6", optional = true }
derive-new = { version = "0.5", optional = true }
tempfile = "3.0"
tempfile = { version = "3.0", optional = true }

[[bin]]
name = "grpc_rust_plugin"
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

use std::collections::HashMap;
use std::io::Write;

use protobuf::compiler_plugin;
use protobuf::descriptor::*;
use protobuf::descriptorx::*;
use std::io::Write;

struct CodeWriter<'a> {
writer: &'a mut (dyn Write + 'a),
Expand Down
12 changes: 7 additions & 5 deletions compiler/src/prost_codegen.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

use super::util::{fq_grpc, to_snake_case, MethodType};
use std::io::{Error, ErrorKind, Read};
use std::path::Path;
use std::{fs, io, process::Command};

use derive_new::new;
use prost::Message;
use prost_build::{protoc, protoc_include, Config, Method, Service, ServiceGenerator};
use prost_types::FileDescriptorSet;
use std::io::{Error, ErrorKind, Read};
use std::path::Path;
use std::{fs, io, process::Command};

use crate::util::{fq_grpc, to_snake_case, MethodType};

/// Returns the names of all packages compiled.
pub fn compile_protos<P>(protos: &[P], includes: &[P], out_dir: &str) -> io::Result<Vec<String>>
Expand Down Expand Up @@ -50,7 +52,7 @@ where

let mut buf = Vec::new();
fs::File::open(descriptor_set)?.read_to_end(&mut buf)?;
let descriptor_set = FileDescriptorSet::decode(&buf)?;
let descriptor_set = FileDescriptorSet::decode(buf.as_slice())?;

// Get the package names from the descriptor set.
let mut packages: Vec<_> = descriptor_set
Expand Down
1 change: 1 addition & 0 deletions compiler/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ mod test {
}

#[test]
#[cfg(feature = "protobuf-codec")]
fn test_camel_name() {
let cases = vec![
("AsyncRequest", "AsyncRequest"),
Expand Down
2 changes: 1 addition & 1 deletion src/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const BUF_SHRINK_SIZE: usize = 4 * 1024;

/// An gRPC status code structure.
/// This type contains constants for all gRPC status codes.
#[derive(PartialEq, Clone, Copy, Debug)]
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub struct RpcStatusCode(i32);

impl From<i32> for RpcStatusCode {
Expand Down

0 comments on commit 16106e3

Please sign in to comment.