Skip to content

Commit 95ade09

Browse files
authored
feat: support building protoc from source (#1)
1 parent 5cbb0ff commit 95ade09

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

Cargo.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ heck = "0.5.0"
1919
prost = "0.14.1"
2020
prost-build = "0.14.1"
2121
prost-types = "0.14.1"
22+
protobuf-src = { version = "2.1.1", optional = true }
23+
2224

2325
[features]
24-
default = []
26+
default = []
27+
build-protoc = ["protobuf-src"] # Build `protoc` from source instead of relying on a system installation

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ const PROTOS: &[&str] = &[
7373
];
7474

7575
fn main() -> Result<()> {
76+
#[cfg(feature = "build-protoc")]
77+
{
78+
println!("build-protoc feature is enabled");
79+
env::set_var("PROTOC", protobuf_src::protoc());
80+
}
7681
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set"));
7782
println!("cargo:rerun-if-changed=proto");
7883

0 commit comments

Comments
 (0)