Skip to content

Commit

Permalink
Wrap Rust protoc in Oak utils
Browse files Browse the repository at this point in the history
This change:
- Adds `oak_utils` crate, that runs `protoc`/`protoc_grpc` and checks updated files
- Updates `build.rs` files to use `oak_utils`

Fixes #510
  • Loading branch information
ipetr0v authored Feb 4, 2020
1 parent 22e29ee commit dfb8ff7
Show file tree
Hide file tree
Showing 27 changed files with 488 additions and 22 deletions.
10 changes: 5 additions & 5 deletions docs/programming-oak.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ next section.
### Generated gRPC service code

The Oak SDK includes a `proto_rust_grpc` tool (forked from
https://github.com/stepancheg/rust-protobuf) which takes a
[gRPC service definition](https://grpc.io/docs/guides/concepts/) and
autogenerates Rust code for the corresponding Oak Node that implements that
https://github.com/stepancheg/rust-protobuf and wrapped in the `oak_utils`)
which takes a [gRPC service definition](https://grpc.io/docs/guides/concepts/)
and autogenerates Rust code for the corresponding Oak Node that implements that
service.

Adding a `build.rs` file to the Node that invokes this tool results in a
Expand All @@ -124,10 +124,10 @@ generated file appearing in `src/proto/<service>_grpc.rs`.
[embedmd]:# (../examples/hello_world/module/rust/build.rs Rust /fn main/ /^}/)
```Rust
fn main() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
oak_utils::run_protoc_rust_grpc(protoc_rust_grpc::Args {
out_dir: "src/proto",
input: &["../../proto/hello_world.proto"],
includes: &["../../proto", "../../third_party"],
includes: &["../../proto", "../../../../third_party"],
rust_protobuf: true, // also generate protobuf messages, not just services
..Default::default()
})
Expand Down
29 changes: 27 additions & 2 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ oak_derive = { path = "../sdk/rust/oak_derive" }
oak_log = { path = "../sdk/rust/oak_log" }
oak_runtime = { path = "../oak/server/rust/oak_runtime" }
oak_tests = { path = "../sdk/rust/oak_tests" }
oak_utils = { path = "../sdk/rust/oak_utils" }
1 change: 1 addition & 0 deletions examples/abitest/module_0/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ serde = { version = "*", features = ["derive"] }
serde_json = "*"

[build-dependencies]
oak_utils = "*"
protoc-rust-grpc = { path = "../../../../third_party/grpc-rust/protoc-rust-grpc" }
4 changes: 2 additions & 2 deletions examples/abitest/module_0/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn main() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
oak_utils::run_protoc_rust_grpc(protoc_rust_grpc::Args {
out_dir: "src/proto",
input: &["../../proto/abitest.proto"],
includes: &["../../proto", "../../third_party"],
includes: &["../../proto", "../../../../third_party"],
rust_protobuf: true, // also generate protobuf messages, not just services
..Default::default()
})
Expand Down
1 change: 1 addition & 0 deletions examples/hello_world/module/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ serial_test = "*"
serial_test_derive = "*"

[build-dependencies]
oak_utils = "*"
protoc-rust-grpc = { path = "../../../../third_party/grpc-rust/protoc-rust-grpc" }
4 changes: 2 additions & 2 deletions examples/hello_world/module/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fn main() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
oak_utils::run_protoc_rust_grpc(protoc_rust_grpc::Args {
out_dir: "src/proto",
input: &["../../proto/hello_world.proto"],
includes: &["../../proto", "../../third_party"],
includes: &["../../proto", "../../../../third_party"],
rust_protobuf: true, // also generate protobuf messages, not just services
..Default::default()
})
Expand Down
1 change: 1 addition & 0 deletions examples/private_set_intersection/module/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ oak_derive = "*"
protobuf = "*"

[build-dependencies]
oak_utils = "*"
protoc-rust-grpc = { path = "../../../../third_party/grpc-rust/protoc-rust-grpc" }
2 changes: 1 addition & 1 deletion examples/private_set_intersection/module/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
oak_utils::run_protoc_rust_grpc(protoc_rust_grpc::Args {
out_dir: "src/proto",
input: &["../../proto/private_set_intersection.proto"],
includes: &["../../proto"],
Expand Down
1 change: 1 addition & 0 deletions examples/running_average/module/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ oak_derive = "*"
protobuf = "*"

[build-dependencies]
oak_utils = "*"
protoc-rust-grpc = { path = "../../../../third_party/grpc-rust/protoc-rust-grpc" }
2 changes: 1 addition & 1 deletion examples/running_average/module/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
oak_utils::run_protoc_rust_grpc(protoc_rust_grpc::Args {
out_dir: "src/proto",
input: &["../../proto/running_average.proto"],
includes: &["../../proto"],
Expand Down
1 change: 1 addition & 0 deletions examples/rustfmt/module/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ protobuf = "*"
rustfmt-nightly = "*"

[build-dependencies]
oak_utils = "*"
protoc-rust-grpc = { path = "../../../../third_party/grpc-rust/protoc-rust-grpc" }
2 changes: 1 addition & 1 deletion examples/rustfmt/module/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
protoc_rust_grpc::run(protoc_rust_grpc::Args {
oak_utils::run_protoc_rust_grpc(protoc_rust_grpc::Args {
out_dir: "src/proto",
input: &["../../proto/rustfmt.proto"],
includes: &["../../proto"],
Expand Down
Loading

0 comments on commit dfb8ff7

Please sign in to comment.