-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
use tonic_build; | ||
use clap::{Arg, App}; | ||
use clap::{App, Arg}; | ||
use std::path::PathBuf; | ||
use std::vec::Vec; | ||
use tonic_build; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let matches = App::new("Rust gRPC Codegen") | ||
.about("Codegen grpc/protobuf bindings for rust") | ||
.arg(Arg::with_name("input") | ||
.short("i") | ||
.long("input") | ||
.required(true) | ||
.multiple(true) | ||
.takes_value(true) | ||
.help("Input proto file")) | ||
.arg(Arg::with_name("output_dir") | ||
.short("o") | ||
.required(true) | ||
.long("output_dir") | ||
.takes_value(true) | ||
.help("Output directory")) | ||
.arg( | ||
Arg::with_name("input") | ||
.short("i") | ||
.long("input") | ||
.required(true) | ||
.multiple(true) | ||
.takes_value(true) | ||
.help("Input proto file"), | ||
) | ||
.arg( | ||
Arg::with_name("output_dir") | ||
.short("o") | ||
.required(true) | ||
.long("output_dir") | ||
.takes_value(true) | ||
.help("Output directory"), | ||
) | ||
.get_matches(); | ||
let paths = matches.values_of("input").unwrap().collect::<Vec<&str>>(); | ||
let output_dir = PathBuf::from(matches.value_of("output_dir").unwrap()); | ||
|
||
tonic_build::configure() | ||
.out_dir(&output_dir) | ||
.format(true) // don't run `rustfmt`; shouldn't be needed to build | ||
.compile( | ||
&paths, | ||
&["proto"], | ||
)?; | ||
.compile(&paths, &["proto"])?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
// Copyright 2020 Nathan (Blaise) Bruer. All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# Copyright 2020 Nathan (Blaise) Bruer. All rights reserved. | ||
|
||
set -eu -o pipefail | ||
|
||
cd "$(dirname $(realpath $0))" | ||
|
||
RUST_FMT="./bazel-bin/external/raze__rustfmt_nightly__1_4_21/cargo_bin_rustfmt" | ||
if [ "${1:-}" != "" ]; then | ||
FILES="$@" | ||
else | ||
FILES="$(find . -name '*.rs')" | ||
fi | ||
echo "$FILES" | xargs $RUST_FMT --emit files --edition 2018 |