From b8c294bf4d1e3f0ac1de3abeb7cf4b54c02011a2 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Wed, 19 Oct 2022 12:08:58 +0200 Subject: [PATCH] Explicitly evaluate symlink on Windows (#2135) --- rslib/build/protobuf.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rslib/build/protobuf.rs b/rslib/build/protobuf.rs index a51dfd097..c8f85b131 100644 --- a/rslib/build/protobuf.rs +++ b/rslib/build/protobuf.rs @@ -137,14 +137,17 @@ fn maybe_add_protobuf_to_path() { if which::which("protoc").is_ok() { return; } - 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") { - "protoc_bin_macos/bin/protoc" + 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 { - "protoc_bin_linux_x86_64/bin/protoc" + let base = Path::new("../.bazel/out/../external"); + let subpath = if cfg!(target_os = "macos") { + "protoc_bin_macos/bin/protoc" + } else { + "protoc_bin_linux_x86_64/bin/protoc" + }; + base.join(subpath) }; - let path = base.join(subpath); std::env::set_var("PROTOC", path.to_str().unwrap()); }