1+ echo on
12@ rem set PROTOBUF_VER=21.7
3+ choco install -y gradle git curl pkgconfiglite
4+ choco install -y openjdk --version=22.0.2
5+ set PATH = %PATH% ;" c:\Program Files\OpenJDK\jdk-22.0.2\bin"
6+ set JAVA_HOME =
27set PROTOBUF_VER = 22.5
38set ABSL_VERSION = 20230125.4
4- set CMAKE_NAME = cmake-3.26.3-windows-x86_64
59
610if not exist " protobuf-%PROTOBUF_VER% \build\Release\" (
711 call :installProto || exit /b 1
812)
913
1014echo Compile gRPC-Java with something like:
11- echo -PtargetArch=x86_32 -PvcProtobufLibs =%cd% \protobuf-%PROTOBUF_VER% \build\Release -PvcProtobufInclude=%cd% \protobuf-%PROTOBUF_VER% \build\include
15+ echo -PtargetArch=x86_32 -PvcProtobufLibPath =%cd% \protobuf-%PROTOBUF_VER% \build\protobuf- %PROTOBUF_VER% \lib -PvcProtobufInclude=%cd% \protobuf-%PROTOBUF_VER% \build\protobuf- %PROTOBUF_VER% \ include -PvcProtobufLibs=insert-list-of-libs-from-pkg-config-output-here
1216goto :eof
1317
1418
1519:installProto
1620
1721where /q cmake
1822if not ERRORLEVEL 1 goto :hasCmake
23+ set CMAKE_NAME = cmake-3.26.3-windows-x86_64
1924if not exist " %CMAKE_NAME% " (
2025 call :installCmake || exit /b 1
2126)
@@ -29,23 +34,26 @@ powershell -command "$ErrorActionPreference = 'stop'; & { [Net.ServicePointManag
2934powershell -command " $ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('absl.zip', '.') }" || exit /b 1
3035del absl.zip
3136rmdir protobuf-%PROTOBUF_VER% \third_party\abseil-cpp
32- rename abseil-cpp-%ABSL_VERSION% protobuf-%PROTOBUF_VER% \third_party\abseil-cpp
37+ move abseil-cpp-%ABSL_VERSION% protobuf-%PROTOBUF_VER% \third_party\abseil-cpp
3338mkdir protobuf-%PROTOBUF_VER% \build
3439pushd protobuf-%PROTOBUF_VER% \build
3540
36- @ rem Workaround https://github.com/protocolbuffers/protobuf/issues/10174
37- powershell -command " (Get-Content ..\cmake\extract_includes.bat.in) -replace '\.\.\\', '' | Out-File -encoding ascii ..\cmake\extract_includes.bat.in"
3841@ rem cmake does not detect x86_64 from the vcvars64.bat variables.
3942@ rem If vcvars64.bat has set PLATFORM to X64, then inform cmake to use the Win64 version of VS
40- if " %PLATFORM% " == " X64 " (
43+ if " %PLATFORM% " == " x64 " (
4144 @ rem Note the space
42- SET CMAKE_VSARCH = Win64
45+ SET CMAKE_VSARCH = -A x64
4346) else (
4447 SET CMAKE_VSARCH =
4548)
46- cmake -Dprotobuf_BUILD_TESTS=OFF -G " Visual Studio %VisualStudioVersion:~0 ,2 %%CMAKE_VSARCH% " .. || exit /b 1
47- msbuild /maxcpucount /p:Configuration=Release /verbosity:minimal libprotoc.vcxproj || exit /b 1
48- call extract_includes.bat || exit /b 1
49+ for /f " tokens=4 delims=\" %%a in (" %VCINSTALLDIR% " ) do (
50+ SET VC_YEAR = %%a
51+ )
52+ for /f " tokens=1 delims=." %%a in (" %VisualStudioVersion% " ) do (
53+ SET visual_studio_major_version = %%a
54+ )
55+ cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%cd% \protobuf-%PROTOBUF_VER% -DCMAKE_PREFIX_PATH=%cd% \protobuf-%PROTOBUF_VER% -G " Visual Studio %visual_studio_major_version% %VC_YEAR% " %CMAKE_VSARCH% ..
56+ cmake --build . --config Release --target install
4957popd
5058goto :eof
5159
@@ -56,3 +64,4 @@ powershell -command "$ErrorActionPreference = 'stop'; & { iwr https://cmake.org/
5664powershell -command " $ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1
5765del cmake.zip
5866goto :eof
67+
0 commit comments