-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate attestation tonic and message committed
Add build steps to generate the attestation tonic services and messages
- Loading branch information
1 parent
dfc282a
commit 89f6dac
Showing
7 changed files
with
100 additions
and
32 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
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
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,40 @@ | ||
// Copyright (c) 2023 The MobileCoin Foundation | ||
|
||
//! Generate the prost messages for the gRPC service. | ||
use std::{ | ||
env, | ||
io::{Error, ErrorKind}, | ||
path::PathBuf, | ||
process::Command, | ||
}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR")?); | ||
let protoc = prost_build::protoc_from_env(); | ||
let mut cmd = Command::new(protoc); | ||
cmd.arg(format!("--prost_out={}", out_dir.display())); | ||
|
||
let protos = &["../v1/attest.proto"]; | ||
let includes = &["../../../", "../"]; | ||
|
||
for i in includes { | ||
cmd.arg("-I").arg(i); | ||
} | ||
|
||
for p in protos { | ||
cmd.arg(p); | ||
} | ||
|
||
let output = cmd.output()?; | ||
|
||
if !output.status.success() { | ||
let stderr = String::from_utf8_lossy(&output.stderr); | ||
return Err(Error::new( | ||
ErrorKind::Other, | ||
format!("Failed building gRPC messages: {stderr}"), | ||
))?; | ||
} | ||
|
||
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,12 +1,9 @@ | ||
// Copyright (c) 2023 The MobileCoin Foundation | ||
|
||
#![doc = include_str!("../README.md")] | ||
#![deny(missing_docs, missing_debug_implementations, unsafe_code)] | ||
#![deny(missing_debug_implementations, unsafe_code)] | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() { | ||
assert_eq!(2 + 2, 4); | ||
} | ||
} | ||
include!(concat!( | ||
env!("OUT_DIR"), | ||
"/mobilecoinfoundation.attestation.v1.rs" | ||
)); |
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
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,41 @@ | ||
// Copyright (c) 2023 The MobileCoin Foundation | ||
|
||
//! Generate the tonic code for the gRPC service. | ||
use std::{ | ||
env, | ||
io::{Error, ErrorKind}, | ||
path::PathBuf, | ||
process::Command, | ||
}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR")?); | ||
let protoc = prost_build::protoc_from_env(); | ||
let mut cmd = Command::new(protoc); | ||
cmd.arg(format!("--tonic_out={}", out_dir.display())) | ||
.arg("--tonic_opt=no_include"); | ||
|
||
let protos = &["../v1/services.proto"]; | ||
let includes = &["../../../", "../"]; | ||
|
||
for i in includes { | ||
cmd.arg("-I").arg(i); | ||
} | ||
|
||
for p in protos { | ||
cmd.arg(p); | ||
} | ||
|
||
let output = cmd.output()?; | ||
|
||
if !output.status.success() { | ||
let stderr = String::from_utf8_lossy(&output.stderr); | ||
return Err(Error::new( | ||
ErrorKind::Other, | ||
format!("Failed building tonic gRPC service: {stderr}"), | ||
))?; | ||
} | ||
|
||
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