Files
openide/build/protobuf/getprotoc.bat
Dmitry.Neverov bd652e4024 Update protobuf version after change in versioning scheme
Like it was done for bash script in f02dae0232aa0ac6d79d1bc1bc2d9ee418d4c241

GitOrigin-RevId: 490dbc26799529152c5fd81ed6d05a89d36fff31
2024-02-16 18:37:21 +00:00

58 lines
1.8 KiB
Batchfile

:: Usage:
:: @echo off
:: for /f %%i in ('git.exe rev-parse --show-toplevel') do set "toplevel=%%~fi"
:: call "%toplevel%\build\protobuf\getprotoc.bat"
:: @echo on
@echo off
if not defined PROTOC_VERSION set PROTOC_VERSION=24.2
if not defined PROTOC_BIN_DIR (
for /f %%i in ('git.exe rev-parse --show-toplevel') do set "toplevel=%%~fi"
set "PROTOC_BIN_DIR=%toplevel%\build\protobuf\bin"
)
if not exist "%PROTOC_BIN_DIR%" mkdir "%PROTOC_BIN_DIR%"
if not defined PROTOC_CACHE_DIR (
set "PROTOC_CACHE_DIR=%PROTOC_BIN_DIR%\..\cache"
)
if not exist "%PROTOC_CACHE_DIR%" mkdir "%PROTOC_CACHE_DIR%"
call:getprotoc || goto :exit
set PATH=%PROTOC_BIN_DIR%;%PATH%
:exit
exit /b %errorlevel%
:getprotoc
if "%~1" == "" (
set "_protoc_version=%PROTOC_VERSION%"
) else (
set "_protoc_version=%~1"
)
set "_protoc_zip_name=protoc-%_protoc_version%-win32.zip"
if not exist "%PROTOC_CACHE_DIR%\%_protoc_zip_name%" (
curl.exe -L --output "%PROTOC_CACHE_DIR%\%_protoc_zip_name%" ^
"https://github.com/protocolbuffers/protobuf/releases/download/v%_protoc_version%/%_protoc_zip_name%" || goto :exit
)
set "_protoc_exe=%PROTOC_BIN_DIR%\protoc.exe"
if exist "%_protoc_exe%.tmp" del "%_protoc_exe%.tmp"
if exist "%_protoc_exe%" move /y "%_protoc_exe%" "%_protoc_exe%.tmp" >nul
tar.exe --strip-components 1 -xf "%PROTOC_CACHE_DIR%\%_protoc_zip_name%" -C "%PROTOC_BIN_DIR%" bin/protoc.exe || (
if exist "%_protoc_exe%.tmp" move /y "%_protoc_exe%.tmp" "%_protoc_exe%" >nul
del "%PROTOC_CACHE_DIR%\%_protoc_zip_name%"
goto :exit
)
if "%~1" == "" (
if exist "%_protoc_exe%.tmp" del "%_protoc_exe%.tmp"
) else (
if exist "%_protoc_exe%" move /y "%_protoc_exe%" "%PROTOC_BIN_DIR%\protoc-%_protoc_version%.exe" >nul
if exist "%_protoc_exe%.tmp" move /y "%_protoc_exe%.tmp" "%_protoc_exe%" >nul
)
goto :eof