Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 0 additions & 105 deletions release/kokoro/build_windows.bat

This file was deleted.

76 changes: 74 additions & 2 deletions release/kokoro/presubmit_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,80 @@ if "%PYTHON_VERSIONS%" == "" (
echo === Launching Windows Build Workflow ===
for %%V in (%PYTHON_VERSIONS%) do (
echo --- Building Python %%V ---
call "%~dp0build_windows.bat" %%V

echo === Loading Environment Configuration ===
call "%~dp0set_env_windows.bat" %%V
if !ERRORLEVEL! NEQ 0 (
echo Failed to configure build environment!
set "PRESUBMIT_STATUS=1"
goto cleanup
)

set "BUILD_STATUS=0"

echo --- Backing up MODULE.bazel ---
copy MODULE.bazel MODULE.bazel.bak >nul

echo --- Dynamically Adjusting Python Version in MODULE.bazel ---
!PYTHON_EXE! -c "import sys; path='MODULE.bazel'; content=open(path).read(); open(path,'w').write(content.replace('python_version = \"3.11\"', 'python_version = \"!PYTHON_VERSION!\"'))"
if !ERRORLEVEL! NEQ 0 (
echo Failed to modify MODULE.bazel!
set "PRESUBMIT_STATUS=1"
goto cleanup
)

:: Fetch dependencies. We perform multiple attempts to absorb transient flaky network connections.
echo --- Fetching Dependencies ---
set ATTEMPTS=0
:fetch_loop
set /a ATTEMPTS+=1
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...
:: 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
ping -n !PINGS! 127.0.0.1 >nul
goto fetch_loop
)
)
echo Fetch failed permanently or max attempts reached.
set "PRESUBMIT_STATUS=1"
goto cleanup
)
if exist fetch.log del fetch.log

echo --- Getting Output Base ---
for /f "tokens=*" %%i in ('bazel %STARTUP_FLAGS% info output_base') do set "OUTPUT_BASE=%%i"
set "OUTPUT_BASE=!OUTPUT_BASE:/=\!"
echo Output Base: !OUTPUT_BASE!

echo --- Resolving Hermetic Python Toolchain ---
for /f "tokens=*" %%A in ('dir /b /ad "!OUTPUT_BASE!\external\*python_!PY_VER_UNDERSCORE!_host" 2^>nul') do set "PY_HOST_DIR=%%A"
echo Hermetic Python Directory: !PY_HOST_DIR!

if not "!PY_HOST_DIR!" == "" (
echo --- Copying Hermetic Python import library to space-free directory ---
if not exist C:\tmp\python_libs mkdir C:\tmp\python_libs
copy "!OUTPUT_BASE!\external\!PY_HOST_DIR!\libs\python*.lib" C:\tmp\python_libs\
echo --- Copying Hermetic Python DLL to space-free directory ---
copy "!OUTPUT_BASE!\external\!PY_HOST_DIR!\python*.dll" C:\tmp\python_libs\
set "LINK_FLAGS=--linkopt=/LIBPATH:C:\tmp\python_libs --action_env=PATH"
set "PATH=C:\tmp\python_libs;!PATH!"
) else (
echo Warning: Hermetic Python directory not found! Skipping import library copy.
)

echo --- Bazel Build ---
bazel %STARTUP_FLAGS% build %LINK_FLAGS% //...
if !ERRORLEVEL! NEQ 0 (
echo Windows Presubmit Build FAILED for Python %%V!
echo Build failed!
set "PRESUBMIT_STATUS=1"
goto cleanup
)
Expand All @@ -50,6 +121,7 @@ for %%V in (%PYTHON_VERSIONS%) do (
echo Windows Presubmit Build and Tests PASSED!

:cleanup
if exist fetch.log del fetch.log
if exist MODULE.bazel.bak (
echo --- Restoring MODULE.bazel ---
move /y MODULE.bazel.bak MODULE.bazel >nul
Expand Down
File renamed without changes.
Loading