Skip to content

Commit ea5b8de

Browse files
committed
Fix macOS scenario prep reliability and VSCode spdlog compatibility
1 parent a190ef7 commit ea5b8de

10 files changed

Lines changed: 162 additions & 31 deletions

File tree

scenarios/macos/mac_foundrylocal/mac_foundrylocal_resources/mac_foundrylocal_setup.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,16 @@ export PATH="$HOME/bin:$PATH"
5151
# ============================================================================
5252
log "Step 1: Starting Foundry service..."
5353

54-
log "Running: foundry service start (in background)"
55-
foundry service start &
54+
# Spawn the foundry service fully detached: redirect its stdio away from the
55+
# inherited RPC pipes and disown it so the parent shell's exit isn't blocked
56+
# on the daemon and the RPC layer (SimpleRemote) gets EOF on stdout/stderr
57+
# immediately when this script returns. A bare `foundry service start &`
58+
# leaves the daemon owning the script's stdout fd; SimpleRemote then waits
59+
# for EOF and times out at 30 minutes even though setup completed.
60+
FOUNDRY_SERVICE_LOG="$LOG_DIR/mac_foundrylocal_foundry_service.log"
61+
log "Running: foundry service start (background, logs -> $FOUNDRY_SERVICE_LOG)"
62+
nohup foundry service start </dev/null >>"$FOUNDRY_SERVICE_LOG" 2>&1 &
63+
disown 2>/dev/null || true
5664

5765
# Wait for service to be ready
5866
log "Waiting for Foundry service to be ready..."

scenarios/macos/mac_net_aspire/mac_net_aspire.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class MacNetAspire(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "9"
17+
prep_version = "10"
1818
resources = module + "_resources"
1919

2020

scenarios/macos/mac_net_aspire/mac_net_aspire_resources/mac_net_aspire_prep.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,22 @@ log "✓ Python version confirmed: $PYTHON_VERSION"
180180
# iterations (which use plain --build) pass cleanly.
181181
log "-- Regenerating ConfigurationSchema.json files"
182182
cd $BIN_DIR/aspire
183-
./build.sh --restore --build /p:UpdateConfigurationSchema=true
184-
check_status "ConfigurationSchema regeneration"
183+
# Capture build output so a failure is diagnosable. Without this the entire
184+
# MSBuild/dotnet error was swallowed and the prep log only said
185+
# "ConfigurationSchema regeneration failed" with no further clues.
186+
ASPIRE_BUILD_LOG="$LOG_DIR/mac_net_aspire_build.log"
187+
log " build output -> $ASPIRE_BUILD_LOG"
188+
./build.sh --restore --build /p:UpdateConfigurationSchema=true >>"$ASPIRE_BUILD_LOG" 2>&1
189+
ASPIRE_BUILD_RC=$?
190+
if [ $ASPIRE_BUILD_RC -ne 0 ]; then
191+
log " ERROR - ConfigurationSchema regeneration failed (rc=$ASPIRE_BUILD_RC)."
192+
log " ERROR - See $ASPIRE_BUILD_LOG for full build output. Last 40 lines:"
193+
tail -n 40 "$ASPIRE_BUILD_LOG" 2>/dev/null | while IFS= read -r line; do
194+
log " | $line"
195+
done
196+
exit 1
197+
fi
198+
log "✓ ConfigurationSchema regeneration successful"
185199

186200
log ""
187201
log "✓ All checks passed"

scenarios/macos/mac_opencv_build/mac_opencv_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class MacOpencvBuild(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "5"
17+
prep_version = "6"
1818
resources = module + "_resources"
1919

2020

scenarios/macos/mac_opencv_build/mac_opencv_build_resources/mac_opencv_build_prep.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,30 @@ if [ "$PYTHON_VERSION" != "3.12.10" ]; then
157157
fi
158158
log "✓ Python version confirmed: $PYTHON_VERSION"
159159

160-
log "-- Installing CMake"
161-
brew install cmake
162-
check_status "CMake installation"
160+
log "-- Installing CMake and FFmpeg 6"
161+
brew install cmake ffmpeg@6
162+
check_status "CMake and FFmpeg 6 installation"
163163
check_command "cmake" || exit 1
164164

165+
# OpenCV 4.10.0 is compatible with the FFmpeg 6 API surface. Windows uses the
166+
# FFmpeg revision pinned by OpenCV's 4.10 packaging; on macOS Homebrew's rolling
167+
# `ffmpeg` formula can advance to 7.x, which breaks OpenCV 4.10 videoio compile
168+
# with removed APIs like `avcodec_close`. Prefer the keg-only ffmpeg@6 formula
169+
# explicitly so mac stays aligned with the Windows workload.
170+
FFMPEG6_PREFIX="$(/opt/homebrew/bin/brew --prefix ffmpeg@6 2>/dev/null)"
171+
if [ -z "$FFMPEG6_PREFIX" ] || [ ! -d "$FFMPEG6_PREFIX" ]; then
172+
log " ERROR - ffmpeg@6 prefix could not be resolved"
173+
exit 1
174+
fi
175+
export PKG_CONFIG_PATH="$FFMPEG6_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
176+
log "✓ Using ffmpeg@6 from: $FFMPEG6_PREFIX"
177+
FFMPEG_VERSION=$(PKG_CONFIG_PATH="$PKG_CONFIG_PATH" pkg-config --modversion libavcodec 2>/dev/null)
178+
if [ -z "$FFMPEG_VERSION" ]; then
179+
log " ERROR - pkg-config could not resolve libavcodec from ffmpeg@6"
180+
exit 1
181+
fi
182+
log "✓ libavcodec version resolved via pkg-config: $FFMPEG_VERSION"
183+
165184
log "-- Creating build directory"
166185
mkdir -p $BIN_DIR/build_opencv
167186
cd $BIN_DIR/build_opencv || {

scenarios/macos/mac_pytorch_inf/mac_pytorch_inf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class MacPytorchInf(core.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "7"
17+
prep_version = "8"
1818
resources = module + "_resources"
1919

2020

scenarios/macos/mac_pytorch_inf/mac_pytorch_inf_resources/mac_pytorch_inf_prep.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,16 @@ check_command() {
3434

3535
# Always copy resources to pick up script/config changes
3636
log "-- Copying resources to $BIN_DIR/mac_pytorch_inf_resources"
37-
mkdir -p "$BIN_DIR/mac_pytorch_inf_resources"
38-
cp -r "$(dirname "$0")"/* "$BIN_DIR/mac_pytorch_inf_resources/"
37+
SRC_RES_DIR="$(cd "$(dirname "$0")" && pwd)"
38+
DST_RES_DIR="$BIN_DIR/mac_pytorch_inf_resources"
39+
mkdir -p "$DST_RES_DIR"
40+
check_status "resource directory creation"
41+
if [ "$SRC_RES_DIR" = "$DST_RES_DIR" ]; then
42+
log "✓ Resource copy skipped (already running from $DST_RES_DIR)"
43+
else
44+
cp -r "$SRC_RES_DIR"/* "$DST_RES_DIR/"
45+
check_status "resource copy"
46+
fi
3947

4048
echo "-- mac_pytorch_inf_prep.sh started $(date)" > "$LOG_FILE"
4149
log "-- pytorch_inf prep started"

scenarios/macos/mac_vscode/mac_vscode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class MacVscode(scenarios.app_scenario.Scenario):
1515

1616
module = __module__.split('.')[-1]
17-
prep_version = "8"
17+
prep_version = "16"
1818
resources = module + "_resources"
1919

2020

scenarios/macos/mac_vscode/mac_vscode_resources/mac_vscode_prep.sh

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ if [ ! -d "$BIN_DIR" ]; then
5050
exit 1
5151
fi
5252

53+
# Always copy resources to pick up script/config/patch changes.
54+
# This keeps prep resilient when invoked from different working directories
55+
# while still expecting files under $BIN_DIR/mac_vscode_resources.
56+
log "-- Copying resources to $BIN_DIR/mac_vscode_resources"
57+
SRC_RES_DIR="$(cd "$(dirname "$0")" && pwd)"
58+
DST_RES_DIR="$BIN_DIR/mac_vscode_resources"
59+
mkdir -p "$DST_RES_DIR"
60+
check_status "resource directory creation"
61+
if [ "$SRC_RES_DIR" = "$DST_RES_DIR" ]; then
62+
log "✓ Resource copy skipped (already running from $DST_RES_DIR)"
63+
else
64+
cp -r "$SRC_RES_DIR"/* "$DST_RES_DIR/"
65+
check_status "resource copy"
66+
fi
67+
5368
cd $BIN_DIR || { log " ERROR - Failed to change to $BIN_DIR"; exit 1; }
5469

5570
# 1. Ensure Xcode command-line tools are installed
@@ -160,29 +175,83 @@ check_status "VS Code checkout v1.106.2"
160175

161176
# 7. Install npm dependencies
162177
log "-- Installing npm dependencies (this may take 10-20 minutes)..."
163-
# First attempt - this will fail on @vscode/spdlog due to Apple Clang consteval issue on Darwin 25.4+
164-
npm install --loglevel=error 2>/dev/null
165-
166-
# Patch bundled fmt in @vscode/spdlog to work around Apple Clang consteval issue
167-
SPDLOG_FMT_DIR="node_modules/@vscode/spdlog/deps/spdlog/include/spdlog/fmt/bundled"
168-
if [ -d "$SPDLOG_FMT_DIR" ]; then
169-
log "-- Patching spdlog fmt headers (consteval -> constexpr)"
170-
sed -i '' 's/consteval/constexpr/g' "$SPDLOG_FMT_DIR/format.h"
171-
sed -i '' 's/consteval/constexpr/g' "$SPDLOG_FMT_DIR/core.h"
172-
check_status "spdlog fmt patch"
173-
174-
# Rebuild just spdlog with the patched source (npm uses its bundled node-gyp)
175-
log "-- Rebuilding @vscode/spdlog..."
176-
npm rebuild @vscode/spdlog
177-
check_status "spdlog rebuild"
178+
# Install deps without lifecycle scripts first so @vscode/spdlog headers are
179+
# guaranteed to exist for patching before node-gyp build kicks in.
180+
NPM_FIRST_LOG="$LOG_DIR/mac_vscode_npm_install_first.log"
181+
log " phase-1 npm install (--ignore-scripts) output -> $NPM_FIRST_LOG"
182+
npm install --ignore-scripts --loglevel=error >>"$NPM_FIRST_LOG" 2>&1
183+
NPM_FIRST_RC=$?
184+
if [ $NPM_FIRST_RC -ne 0 ]; then
185+
log " ERROR - First npm install phase failed (rc=$NPM_FIRST_RC)."
186+
log " ERROR - See $NPM_FIRST_LOG for the underlying error."
187+
exit 1
188+
fi
189+
log "✓ phase-1 npm install completed"
190+
191+
# Apply a checked-in patch (durable and auditable) instead of ad-hoc string
192+
# replacement in the script. This keeps the workaround deterministic for the
193+
# pinned VS Code tag.
194+
# TODO: Revisit/remove this patch when we move off VS Code 1.106.2 or when
195+
# upstream @vscode/spdlog/fmt builds cleanly on Darwin 25+ with Node 22.
196+
PATCH_FILE="$BIN_DIR/mac_vscode_resources/spdlog_fmt_darwin25.patch"
197+
if [ ! -f "$PATCH_FILE" ]; then
198+
log " ERROR - Required patch file not found: $PATCH_FILE"
199+
exit 1
200+
fi
201+
202+
CORE_H="node_modules/@vscode/spdlog/deps/spdlog/include/spdlog/fmt/bundled/core.h"
203+
if [ ! -f "$CORE_H" ]; then
204+
log " ERROR - Expected spdlog header not found: $CORE_H"
205+
exit 1
206+
fi
207+
208+
# Fast-path: if this package build already carries the Apple-compatible
209+
# constexpr form, skip patching entirely.
210+
if grep -Eq '^#[[:space:]]*define[[:space:]]+FMT_CONSTEVAL[[:space:]]+constexpr$' "$CORE_H"; then
211+
log "✓ spdlog/fmt already in compatible state (FMT_CONSTEVAL constexpr)"
178212
else
179-
log "-- No spdlog fmt patch needed"
213+
log "-- Applying spdlog/fmt compatibility patch: $PATCH_FILE"
214+
if git apply --check "$PATCH_FILE" >/dev/null 2>&1; then
215+
git apply "$PATCH_FILE"
216+
check_status "spdlog/fmt patch apply"
217+
elif git apply --reverse --check "$PATCH_FILE" >/dev/null 2>&1; then
218+
log "✓ spdlog/fmt patch already applied"
219+
else
220+
# Fallback for minor upstream drift where patch hunk context changed
221+
# but the required token replacement is still well-defined.
222+
if grep -Eq '^#[[:space:]]*define[[:space:]]+FMT_CONSTEVAL[[:space:]]+consteval$' "$CORE_H"; then
223+
log "-- Patch did not apply cleanly; applying tolerant fallback edit in $CORE_H"
224+
sed -E -i '' 's@^#[[:space:]]*define[[:space:]]+FMT_CONSTEVAL[[:space:]]+consteval$@# define FMT_CONSTEVAL constexpr@' "$CORE_H"
225+
check_status "spdlog/fmt fallback edit"
226+
if grep -Eq '^#[[:space:]]*define[[:space:]]+FMT_CONSTEVAL[[:space:]]+constexpr$' "$CORE_H"; then
227+
log "✓ spdlog/fmt fallback edit applied"
228+
else
229+
log " ERROR - spdlog/fmt fallback edit failed to verify"
230+
exit 1
231+
fi
232+
else
233+
log " ERROR - spdlog/fmt patch does not apply cleanly and FMT_CONSTEVAL token was not found in core.h"
234+
exit 1
235+
fi
236+
fi
180237
fi
181238

239+
# Rebuild just spdlog with the patched source (npm uses its bundled node-gyp)
240+
log "-- Rebuilding @vscode/spdlog..."
241+
npm rebuild @vscode/spdlog
242+
check_status "spdlog rebuild"
243+
182244
# Re-run npm install to complete any remaining steps (postinstall, etc.)
183245
log "-- Completing npm install..."
184-
npm install --loglevel=error
185-
check_status "npm install"
246+
NPM_FINAL_LOG="$LOG_DIR/mac_vscode_npm_install_final.log"
247+
log " phase-2 npm install output -> $NPM_FINAL_LOG"
248+
npm install --loglevel=error >>"$NPM_FINAL_LOG" 2>&1
249+
if [ $? -ne 0 ]; then
250+
log " ERROR - Final npm install failed."
251+
log " ERROR - See $NPM_FINAL_LOG for details."
252+
exit 1
253+
fi
254+
log "✓ npm install successful"
186255

187256
log ""
188257
log "✓ All checks passed"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/@vscode/spdlog/deps/spdlog/include/spdlog/fmt/bundled/core.h b/node_modules/@vscode/spdlog/deps/spdlog/include/spdlog/fmt/bundled/core.h
2+
index 8f1a6f1..b7a5f0c 100644
3+
--- a/node_modules/@vscode/spdlog/deps/spdlog/include/spdlog/fmt/bundled/core.h
4+
+++ b/node_modules/@vscode/spdlog/deps/spdlog/include/spdlog/fmt/bundled/core.h
5+
@@ -263,7 +263,7 @@
6+
# define FMT_USE_CONSTEVAL 0
7+
#endif
8+
#if FMT_USE_CONSTEVAL
9+
-# define FMT_CONSTEVAL consteval
10+
+# define FMT_CONSTEVAL constexpr
11+
# define FMT_CONSTEXPR20 consteval
12+
#else
13+
# define FMT_CONSTEVAL

0 commit comments

Comments
 (0)