Skip to content

Commit 36e97e8

Browse files
feat(protobuf-src): windows support
1 parent ddc3711 commit 36e97e8

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

protobuf-src/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::error::Error;
1717

1818
fn main() -> Result<(), Box<dyn Error>> {
1919
let install_dir = cmake::Config::new("protobuf")
20+
.define("BUILD_SHARED_LIBS", "ON")
2021
.define("ABSL_PROPAGATE_CXX_STD", "ON")
2122
.define("protobuf_BUILD_TESTS", "OFF")
2223
.define("protobuf_DEBUG_POSTFIX", "")

protobuf-src/src/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,22 @@
5151
5252
use std::path::PathBuf;
5353

54+
/// Installation directory.
55+
const INSTALL_DIR: &str = env!("INSTALL_DIR");
56+
57+
/// *protoc* binary.
58+
#[cfg(target_os = "windows")]
59+
const PROTOC_BIN: &str = "protoc.exe";
60+
/// *protoc* binary.
61+
#[cfg(not(target_os = "windows"))]
62+
const PROTOC_BIN: &str = "protoc";
63+
5464
/// Returns the path to the vendored protoc binary.
5565
pub fn protoc() -> PathBuf {
56-
PathBuf::from(env!("INSTALL_DIR"))
57-
.join("bin")
58-
.join("protoc")
66+
PathBuf::from(INSTALL_DIR).join("bin").join(PROTOC_BIN)
5967
}
6068

6169
/// Returns the path to the vendored include directory.
6270
pub fn include() -> PathBuf {
63-
PathBuf::from(env!("INSTALL_DIR")).join("include")
71+
PathBuf::from(INSTALL_DIR).join("include")
6472
}

0 commit comments

Comments
 (0)