Skip to content

Commit af4f0d7

Browse files
dmitriplotnikovcopybara-github
authored andcommitted
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 <version> 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
1 parent 78b2d31 commit af4f0d7

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ bazel_dep(name = "rules_python", version = "1.9.0")
5151
single_version_override(
5252
module_name = "antlr4-cpp-runtime",
5353
patch_cmds = [
54-
"mv VERSION VERSION.txt || true",
55-
"mv version version.txt || true",
54+
"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)]\"",
5655
],
5756
)
5857

release/kokoro/presubmit_windows.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ setlocal enabledelayedexpansion
1919

2020
set "IN_PRESUBMIT=1"
2121
set "PRESUBMIT_STATUS=0"
22+
set "FETCH_RETRIES=10"
23+
set "FETCH_RETRY_DELAY_S=10"
2224
if "%PYTHON_VERSIONS%" == "" (
2325
set "PYTHON_VERSIONS=3.11"
2426
)
@@ -53,18 +55,18 @@ for %%V in (%PYTHON_VERSIONS%) do (
5355
set ATTEMPTS=0
5456
:fetch_loop
5557
set /a ATTEMPTS+=1
56-
echo Fetch attempt !ATTEMPTS! of %FETCH_RETRIES%...
58+
echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!...
5759
bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1
5860
set FETCH_STATUS=!ERRORLEVEL!
5961
type fetch.log
6062
if !FETCH_STATUS! NEQ 0 (
6163
findstr /i "timeout timed" fetch.log >nul
6264
if !ERRORLEVEL! EQU 0 (
63-
if !ATTEMPTS! LSS %FETCH_RETRIES% (
64-
echo Fetch failed with timeout. Retrying in %FETCH_RETRY_DELAY_S% seconds...
65+
if !ATTEMPTS! LSS !FETCH_RETRIES! (
66+
echo Fetch failed with timeout. Retrying in !FETCH_RETRY_DELAY_S! seconds...
6567
:: Use ping instead of timeout because timeout command fails in non-interactive Kokoro environments
6668
:: with "ERROR: Input redirection is not supported, exiting the process immediately."
67-
set /a PINGS=%FETCH_RETRY_DELAY_S%+1
69+
set /a PINGS=!FETCH_RETRY_DELAY_S!+1
6870
ping -n !PINGS! 127.0.0.1 >nul
6971
goto fetch_loop
7072
)

release/kokoro/release_windows.bat

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
:: limitations under the License.
1414
::
1515
setlocal enabledelayedexpansion
16-
:: release_windows.bat
17-
:: Kokoro entrypoint for Windows Release builds.
16+
set "RELEASE_STATUS=0"
17+
set "FETCH_RETRIES=10"
18+
set "FETCH_RETRY_DELAY_S=10"
1819

1920
echo === Loading Environment Configuration ===
2021
call "%~dp0set_env_windows.bat"
2122
if !ERRORLEVEL! NEQ 0 (
2223
echo Failed to configure build environment!
2324
exit /b 1
2425
)
25-
26-
set "RELEASE_STATUS=0"
27-
2826
:: If running locally (not on Kokoro), authenticate with gcloud.
2927
if "%KOKORO_BUILD_ID%" == "" (
3028
gcloud auth application-default print-access-token --quiet >nul 2>&1
@@ -126,18 +124,18 @@ echo --- Pre-fetching Dependencies ---
126124
set ATTEMPTS=0
127125
:fetch_loop
128126
set /a ATTEMPTS+=1
129-
echo Fetch attempt !ATTEMPTS! of %FETCH_RETRIES%...
127+
echo Fetch attempt !ATTEMPTS! of !FETCH_RETRIES!...
130128
bazel %STARTUP_FLAGS% fetch //... > fetch.log 2>&1
131129
set FETCH_STATUS=!ERRORLEVEL!
132130
type fetch.log
133131
if !FETCH_STATUS! NEQ 0 (
134132
findstr /i "timeout timed" fetch.log >nul
135133
if !ERRORLEVEL! EQU 0 (
136-
if !ATTEMPTS! LSS %FETCH_RETRIES% (
137-
echo Fetch failed with timeout. Retrying in %FETCH_RETRY_DELAY_S% seconds...
134+
if !ATTEMPTS! LSS !FETCH_RETRIES! (
135+
echo Fetch failed with timeout. Retrying in !FETCH_RETRY_DELAY_S! seconds...
138136
:: Use ping instead of timeout because timeout command fails in non-interactive Kokoro environments
139137
:: with "ERROR: Input redirection is not supported, exiting the process immediately."
140-
set /a PINGS=%FETCH_RETRY_DELAY_S%+1
138+
set /a PINGS=!FETCH_RETRY_DELAY_S!+1
141139
ping -n !PINGS! 127.0.0.1 >nul
142140
goto fetch_loop
143141
)

release/kokoro/set_env_windows.bat

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ echo BAZEL_SH set to %BAZEL_SH%
3434
:: Configure a very short Bazel output user root to completely bypass the Windows 260-character path length limit (MAX_PATH)
3535
set "STARTUP_FLAGS=--output_user_root=C:/tmp"
3636

37-
:: Configure retry parameters for Bazel fetch to absorb transient download timeouts
38-
set "FETCH_RETRIES=10"
39-
set "FETCH_RETRY_DELAY_S=10"
40-
4137
echo --- Bazel Version ---
4238
bazel %STARTUP_FLAGS% version
4339

@@ -53,7 +49,7 @@ echo Python Version Selected: %PYTHON_VERSION%
5349
:: Detect Python executable first (needed for downloading BCR assets dynamically)
5450
set PYTHON_EXE=python
5551
where python%PYTHON_VERSION% >nul 2>&1
56-
if !ERRORLEVEL! EQU 0 (
52+
if %ERRORLEVEL% EQU 0 (
5753
set PYTHON_EXE=python%PYTHON_VERSION%
5854
) else if exist C:\Python%PY_VER_NO_DOT%\python.exe (
5955
set PYTHON_EXE=C:\Python%PY_VER_NO_DOT%\python.exe

0 commit comments

Comments
 (0)