Explicitly evaluate symlink on Windows (#2135)

This commit is contained in:
RumovZ 2022-10-19 12:08:58 +02:00 committed by GitHub
parent fb9c934ef2
commit b8c294bf4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,14 +137,17 @@ fn maybe_add_protobuf_to_path() {
if which::which("protoc").is_ok() {
return;
}
let path = if cfg!(target_os = "windows") {
let base = std::fs::read_link("../.bazel/out").unwrap();
base.join("../external/protoc_bin_windows/bin/protoc.exe")
} else {
let base = Path::new("../.bazel/out/../external");
let subpath = if cfg!(target_os = "windows") {
"protoc_bin_windows/bin/protoc.exe"
} else if cfg!(target_os = "macos") {
let subpath = if cfg!(target_os = "macos") {
"protoc_bin_macos/bin/protoc"
} else {
"protoc_bin_linux_x86_64/bin/protoc"
};
let path = base.join(subpath);
base.join(subpath)
};
std::env::set_var("PROTOC", path.to_str().unwrap());
}