Subject: [PATCH bazel-zig-cc v2] fix Windows host support with relative paths

From: Fabian Hahn <[email-masked]>
Date: Wed, 28 Sep 2022 19:58:17 +0100

---
Fixed the Windows scripts to support changing working directories.
Apologies for missing this, it didn't come up in my testing so I wasn't
sure if would be needed and skipped it. It's a bit more complicated now
than just adding a single line, but should still be fine.

Best,
Fabian

 toolchain/defs.bzl | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl
index 0aba0fb..284d2fe 100644
--- a/toolchain/defs.bzl
+++ b/toolchain/defs.bzl
@@ -93,15 +93,25 @@ _ZIG_TOOLS = [
     "wasm-ld",  # WebAssembly
 ]
 
-# TODO: ZIG_LIB_DIR equivalent in powershell?
 _ZIG_TOOL_WRAPPER_WINDOWS_CACHE_KNOWN = """@echo off
+if exist "external\\zig_sdk\\lib\\*" goto :have_external_zig_sdk_lib
+set ZIG_LIB_DIR=%~dp0\\..\\lib
+goto :set_zig_lib_dir
+:have_external_zig_sdk_lib
+set ZIG_LIB_DIR=external\\zig_sdk\\lib
+:set_zig_lib_dir
 set ZIG_LOCAL_CACHE_DIR={cache_prefix}\\bazel-zig-cc
 set ZIG_GLOBAL_CACHE_DIR=%ZIG_LOCAL_CACHE_DIR%
 "{zig}" "{zig_tool}" %*
 """
 
-# TODO: ZIG_LIB_DIR equivalent in powershell?
 _ZIG_TOOL_WRAPPER_WINDOWS_CACHE_GUESS = """@echo off
+if exist "external\\zig_sdk\\lib\\*" goto :have_external_zig_sdk_lib
+set ZIG_LIB_DIR=%~dp0\\..\\lib
+goto :set_zig_lib_dir
+:have_external_zig_sdk_lib
+set ZIG_LIB_DIR=external\\zig_sdk\\lib
+:set_zig_lib_dir
 if exist "%TMP%\\*" goto :usertmp
 set ZIG_LOCAL_CACHE_DIR=C:\\Temp\\bazel-zig-cc
 goto zig
-- 
2.25.1

---

From: "builds.sr.ht" <[email-masked]>
Date: Wed, 28 Sep 2022 19:45:40 +0000

bazel-zig-cc/patches/.build.yml: SUCCESS in 47m9s

[fix Windows host support with relative paths][0] v2 from [Fabian Hahn][1]

[0]: https://lists.sr.ht/~motiejus/bazel-zig-cc/patches/35674
[1]: mailto:[email-masked]

✓ #852447 SUCCESS bazel-zig-cc/patches/.build.yml https://builds.sr.ht/~motiejus/job/852447

---

From: Motiejus Jakštys <[email-masked]>
Date: Thu, 29 Sep 2022 11:33:28 +0300

> than just adding a single line, but should still be fine.

Thanks! Applied and tagged v1.0.0-rc2.

Motiejus