Skip to content

Commit

Permalink
Use tonic-build compile_fds to build file descriptor set (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Sep 26, 2024
1 parent 2df8867 commit 34c2bc8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

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

8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ Usage with [`tonic-build`](https://crates.io/crates/tonic-build):
```rust
let file_descriptors = protox::compile(["root.proto"], ["."]).unwrap();

let file_descriptor_path = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR not set"))
.join("file_descriptor_set.bin");
fs::write(&file_descriptor_path, file_descriptors.encode_to_vec()).unwrap();

tonic_build::configure()
.build_server(true)
.file_descriptor_set_path(&file_descriptor_path)
.skip_protoc_run()
.compile(&["root.proto"], &["."])
.compile_fds(file_descriptors)
.unwrap();
```

Expand Down
2 changes: 1 addition & 1 deletion protox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ serde_yaml = "0.9.34"
similar-asserts = { version = "1.2.0" }
tempfile = "3.10.1"
serde_json = "1.0.117"
tonic-build = "0.12.0"
tonic-build = "0.12.3"

[package.metadata.release]
tag-name = "{{version}}"
Expand Down
8 changes: 1 addition & 7 deletions protox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@
//!
//! let file_descriptors = protox::compile(["root.proto"], ["."]).unwrap();
//!
//! let file_descriptor_path = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR not set"))
//! .join("file_descriptor_set.bin");
//! fs::write(&file_descriptor_path, file_descriptors.encode_to_vec()).unwrap();
//!
//! tonic_build::configure()
//! .build_server(true)
//! .file_descriptor_set_path(&file_descriptor_path)
//! .skip_protoc_run()
//! .compile(&["root.proto"], &["."])
//! .compile_fds(file_descriptors)
//! .unwrap();
//! ```
//!
Expand Down

0 comments on commit 34c2bc8

Please sign in to comment.