If you are not using volo-cli, you can use volo-build to compile Thrift and Protobuf IDL files into Rust code at compile-time. This requires adding volo-build as a build dependency, configuring a build.rs file, and defining your IDLs in a volo.yml file.
1. Add dependency
Add volo-build to your Cargo.toml under [build-dependencies]. Ensure the version is compatible with your volo version.
2. Configure build.rs
Create a build.rs file in your project root with the following content:
3. Configure volo.yml
Create a volo.yml file in the same directory as build.rs to specify the source of your IDLs (local files, specific paths in a proto directory, or remote git repositories).
[build-dependencies]
volo-build = "*" # make sure you use a compatible version with `volo`
fn main() {
volo_build::Builder::default().write().unwrap();
}
---
idls:
- source: local
path: path/to/your/idl.thrift
- source: local
path: path/to/your/protobuf/idl.proto
includes:
- path/to/your/protobuf/
- source: git
repo: git@github.com:cloudwego/volo.git
ref: main
path: path/in/repo/idl.thrift