From af4f0d7a0d0557484ea663c198f1182e6ec95957 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Thu, 28 May 2026 10:00:06 -0700 Subject: [PATCH] Fix antlr4-cpp-runtime VERSION filename collision on Windows On case-insensitive filesystems (Windows), antlr4-cpp-runtime's VERSION file collides with C++ standard library header, causing build failures. Adding powershell-based patch_win_cmds to correctly rename it inside Windows Kokoro builds. Also, fix syntax errors introduced in the previous commit. PiperOrigin-RevId: 922833202 --- MODULE.bazel | 3 +-- release/kokoro/presubmit_windows.bat | 10 ++++++---- release/kokoro/release_windows.bat | 16 +++++++--------- release/kokoro/set_env_windows.bat | 6 +----- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index a3fb307..43c90b6 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -51,8 +51,7 @@ bazel_dep(name = "rules_python", version = "1.9.0") single_version_override( module_name = "antlr4-cpp-runtime", patch_cmds = [ - "mv VERSION VERSION.txt || true", - "mv version version.txt || true", + "python3 -c \"import os; [os.rename(f, f + '.txt') for f in ['VERSION', 'version'] if os.path.exists(f)]\" || python -c \"import os; [os.rename(f, f + '.txt') for f in ['VERSION', 'version'] if os.path.exists(f)]\"", ], ) diff --git a/release/kokoro/presubmit_windows.bat b/release/kokoro/presubmit_windows.bat index bc4f5c2..30136f1 100644 --- a/release/kokoro/presubmit_windows.bat +++ b/release/kokoro/presubmit_windows.bat @@ -19,6 +19,8 @@ setlocal enabledelayedexpansion set "IN_PRESUBMIT=1" set "PRESUBMIT_STATUS=0" +set "FETCH_RETRIES=10" +set "FETCH_RETRY_DELAY_S=10" if "%PYTHON_VERSIONS%" == "" ( set "PYTHON_VERSIONS=3.11" ) @@ -53,18 +55,18 @@ for %%V in (%PYTHON_VERSIONS%) do ( set ATTEMPTS=0 :fetch_loop set /a ATTEMPTS+=1 - echo Fetch attempt !ATTEMPTS! of %FETCH_RETRIES%... + echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!... bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1 set FETCH_STATUS=!ERRORLEVEL! type fetch.log if !FETCH_STATUS! NEQ 0 ( findstr /i "timeout timed" fetch.log >nul if !ERRORLEVEL! EQU 0 ( - if !ATTEMPTS! LSS %FETCH_RETRIES% ( - echo Fetch failed with timeout. Retrying in %FETCH_RETRY_DELAY_S% seconds... + if !ATTEMPTS! LSS !FETCH_RETRIES! ( + echo Fetch failed with timeout. Retrying in !FETCH_RETRY_DELAY_S! seconds... :: Use ping instead of timeout because timeout command fails in non-interactive Kokoro environments :: with "ERROR: Input redirection is not supported, exiting the process immediately." - set /a PINGS=%FETCH_RETRY_DELAY_S%+1 + set /a PINGS=!FETCH_RETRY_DELAY_S!+1 ping -n !PINGS! 127.0.0.1 >nul goto fetch_loop ) diff --git a/release/kokoro/release_windows.bat b/release/kokoro/release_windows.bat index 0138110..9f95c7e 100644 --- a/release/kokoro/release_windows.bat +++ b/release/kokoro/release_windows.bat @@ -13,8 +13,9 @@ :: limitations under the License. :: setlocal enabledelayedexpansion -:: release_windows.bat -:: Kokoro entrypoint for Windows Release builds. +set "RELEASE_STATUS=0" +set "FETCH_RETRIES=10" +set "FETCH_RETRY_DELAY_S=10" echo === Loading Environment Configuration === call "%~dp0set_env_windows.bat" @@ -22,9 +23,6 @@ if !ERRORLEVEL! NEQ 0 ( echo Failed to configure build environment! exit /b 1 ) - -set "RELEASE_STATUS=0" - :: If running locally (not on Kokoro), authenticate with gcloud. if "%KOKORO_BUILD_ID%" == "" ( gcloud auth application-default print-access-token --quiet >nul 2>&1 @@ -126,18 +124,18 @@ echo --- Pre-fetching Dependencies --- set ATTEMPTS=0 :fetch_loop set /a ATTEMPTS+=1 -echo Fetch attempt !ATTEMPTS! of %FETCH_RETRIES%... +echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!... bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1 set FETCH_STATUS=!ERRORLEVEL! type fetch.log if !FETCH_STATUS! NEQ 0 ( findstr /i "timeout timed" fetch.log >nul if !ERRORLEVEL! EQU 0 ( - if !ATTEMPTS! LSS %FETCH_RETRIES% ( - echo Fetch failed with timeout. Retrying in %FETCH_RETRY_DELAY_S% seconds... + if !ATTEMPTS! LSS !FETCH_RETRIES! ( + echo Fetch failed with timeout. Retrying in !FETCH_RETRY_DELAY_S! seconds... :: Use ping instead of timeout because timeout command fails in non-interactive Kokoro environments :: with "ERROR: Input redirection is not supported, exiting the process immediately." - set /a PINGS=%FETCH_RETRY_DELAY_S%+1 + set /a PINGS=!FETCH_RETRY_DELAY_S!+1 ping -n !PINGS! 127.0.0.1 >nul goto fetch_loop ) diff --git a/release/kokoro/set_env_windows.bat b/release/kokoro/set_env_windows.bat index 175d6fb..0091ebf 100644 --- a/release/kokoro/set_env_windows.bat +++ b/release/kokoro/set_env_windows.bat @@ -34,10 +34,6 @@ echo BAZEL_SH set to %BAZEL_SH% :: Configure a very short Bazel output user root to completely bypass the Windows 260-character path length limit (MAX_PATH) set "STARTUP_FLAGS=--output_user_root=C:/tmp" -:: Configure retry parameters for Bazel fetch to absorb transient download timeouts -set "FETCH_RETRIES=10" -set "FETCH_RETRY_DELAY_S=10" - echo --- Bazel Version --- bazel %STARTUP_FLAGS% version @@ -53,7 +49,7 @@ echo Python Version Selected: %PYTHON_VERSION% :: Detect Python executable first (needed for downloading BCR assets dynamically) set PYTHON_EXE=python where python%PYTHON_VERSION% >nul 2>&1 -if !ERRORLEVEL! EQU 0 ( +if %ERRORLEVEL% EQU 0 ( set PYTHON_EXE=python%PYTHON_VERSION% ) else if exist C:\Python%PY_VER_NO_DOT%\python.exe ( set PYTHON_EXE=C:\Python%PY_VER_NO_DOT%\python.exe