Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Auto-detect WIN32_LIBS in Makefile, remove shell quoting entirely

Martin Vogel0f83f08653d3
diff --git a/.github/workflows/dry-run.yml b/.github/workflows/dry-run.yml
index aa47912ab..fc0c08ed9 100644
--- a/.github/workflows/dry-run.yml
+++ b/.github/workflows/dry-run.yml
@@ -106,8 +106,6 @@ jobs:
- name: Test
shell: msys2 {0}
- env:
- WIN32_LIBS: -lws2_32 -lpsapi -Wl,--allow-multiple-definition
run: scripts/test.sh CC=clang CXX=clang++
# ── Step 3: Build binaries (standard + UI, all OS) ──────────
@@ -190,8 +188,6 @@ jobs:
- name: Build standard binary
shell: msys2 {0}
- env:
- WIN32_LIBS: -lws2_32 -lpsapi -Wl,--allow-multiple-definition
run: scripts/build.sh CC=clang CXX=clang++
- name: Archive standard binary
@@ -202,8 +198,6 @@ jobs:
- name: Build UI binary
shell: msys2 {0}
- env:
- WIN32_LIBS: -lws2_32 -lpsapi -Wl,--allow-multiple-definition
run: scripts/build.sh --with-ui CC=clang CXX=clang++
- name: Archive UI binary
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 42b528e4f..240e6caa7 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -112,8 +112,6 @@ jobs:
- name: Test
shell: msys2 {0}
- env:
- WIN32_LIBS: -lws2_32 -lpsapi -Wl,--allow-multiple-definition
run: scripts/test.sh CC=clang CXX=clang++
# ── Step 3: Build binaries (standard + UI, all OS) ──────────
@@ -196,8 +194,6 @@ jobs:
- name: Build standard binary
shell: msys2 {0}
- env:
- WIN32_LIBS: -lws2_32 -lpsapi -Wl,--allow-multiple-definition
run: scripts/build.sh --version ${{ inputs.version }} CC=clang CXX=clang++
- name: Archive standard binary
@@ -208,8 +204,6 @@ jobs:
- name: Build UI binary
shell: msys2 {0}
- env:
- WIN32_LIBS: -lws2_32 -lpsapi -Wl,--allow-multiple-definition
run: scripts/build.sh --with-ui --version ${{ inputs.version }} CC=clang CXX=clang++
- name: Archive UI binary
diff --git a/Makefile.cbm b/Makefile.cbm
index a41129cff..20e74fda2 100644
--- a/Makefile.cbm
+++ b/Makefile.cbm
@@ -74,8 +74,12 @@ CXXFLAGS_TSAN = $(CXXFLAGS_COMMON) -g -O1 \
# Windows needs ws2_32 (Winsock), psapi (GetProcessMemoryInfo), and
# --allow-multiple-definition (MinGW CRT symbol clashes).
-# Pass WIN32_LIBS on command line for Windows builds.
-WIN32_LIBS ?=
+# Auto-detected via compiler; no manual override needed.
+IS_MINGW := $(shell echo | $(CC) -dM -E - 2>/dev/null | grep -q 'define _WIN32 ' && echo yes || echo no)
+WIN32_LIBS :=
+ifeq ($(IS_MINGW),yes)
+WIN32_LIBS := -lws2_32 -lpsapi -Wl,--allow-multiple-definition
+endif
LDFLAGS = -lm -lstdc++ -lpthread -lz $(LIBGIT2_LIBS) $(WIN32_LIBS)
LDFLAGS_TEST = -lm -lstdc++ -lpthread -lz $(SANITIZE) $(LIBGIT2_LIBS) $(WIN32_LIBS)
diff --git a/scripts/build.sh b/scripts/build.sh
index 94bf149ec..a8c59e736 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -87,11 +87,6 @@ verify_compiler "$CC"
# Step 1: Clean C build artifacts only (not node_modules — npm ci handles that)
rm -rf "$ROOT/build/c"
-# Forward WIN32_LIBS from environment (set by CI env: block)
-if [[ -n "${WIN32_LIBS:-}" ]]; then
- EXTRA_MAKE_ARGS+=("WIN32_LIBS=$WIN32_LIBS")
-fi
-
# Step 2: Build (with arch prefix on macOS)
if $WITH_UI; then
$ARCH_PREFIX make -j"$NPROC" -f Makefile.cbm cbm-with-ui \
diff --git a/scripts/test.sh b/scripts/test.sh
index 8dca85026..918033a9a 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -48,10 +48,6 @@ for arg in "$@"; do
*=*) MAKE_ARGS="$MAKE_ARGS $arg" ;; # forward any VAR=VAL to make
esac
done
-# Also forward WIN32_LIBS from environment (set by CI env: block)
-if [[ -n "${WIN32_LIBS:-}" ]]; then
- MAKE_ARGS="$MAKE_ARGS WIN32_LIBS=$WIN32_LIBS"
-fi
print_env "test.sh"