grpc / grpc/grpc-rust

Offer optional support for protox in tonic-build

Open
#1,489 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Feature Request

If I understand correctly, using https://github.com/andrewhickman/protox should make it possible to avoid the use of protoc binaries. It would be great if tonic-build offered built-in API (using a Cargo feature) to leverage protox for schema compilation.

### Crates

tonic-build

### Motivation

Avoid the need for installing protoc on developer systems and in build containers.

I'd be willing to implement this if there is a reasonable expectation that it would be accepted.

### Alternatives

It is possible today to use protox directly, as documented in its README:

```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::Config::new()
.file_descriptor_set_path(&file_descriptor_path)
.skip_protoc_run()
.compile_protos(["root.proto"], ["."])
.unwrap();
```

Having this built-in seems like it would be a good deal more easy to use, and maybe eventually could become the default?

@andrewhickman any potential blockers from your side?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.