1set PROTOBUF_VER=3.5.1 2set CMAKE_NAME=cmake-3.3.2-win32-x86 3 4if not exist "protobuf-%PROTOBUF_VER%\cmake\build\Release\" ( 5 call :installProto || exit /b 1 6) 7 8echo Compile gRPC-Java with something like: 9echo -PtargetArch=x86_32 -PvcProtobufLibs=%cd%\protobuf-%PROTOBUF_VER%\cmake\build\Release -PvcProtobufInclude=%cd%\protobuf-%PROTOBUF_VER%\cmake\build\include 10goto :eof 11 12 13:installProto 14 15where /q cmake 16if not ERRORLEVEL 1 goto :hasCmake 17if not exist "%CMAKE_NAME%" ( 18 call :installCmake || exit /b 1 19) 20set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin 21:hasCmake 22@rem GitHub requires TLSv1.2, and for whatever reason our powershell doesn't have it enabled 23powershell -command "$ErrorActionPreference = 'stop'; & { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/google/protobuf/archive/v%PROTOBUF_VER%.zip -OutFile protobuf.zip }" || exit /b 1 24powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('protobuf.zip', '.') }" || exit /b 1 25del protobuf.zip 26pushd protobuf-%PROTOBUF_VER%\cmake 27mkdir build 28cd build 29 30@rem cmake does not detect x86_64 from the vcvars64.bat variables. 31@rem If vcvars64.bat has set PLATFORM to X64, then inform cmake to use the Win64 version of VS 32if "%PLATFORM%" == "X64" ( 33 @rem Note the space 34 SET CMAKE_VSARCH= Win64 35) else ( 36 SET CMAKE_VSARCH= 37) 38cmake -Dprotobuf_BUILD_TESTS=OFF -G "Visual Studio %VisualStudioVersion:~0,2%%CMAKE_VSARCH%" .. || exit /b 1 39msbuild /maxcpucount /p:Configuration=Release /verbosity:minimal libprotoc.vcxproj || exit /b 1 40call extract_includes.bat || exit /b 1 41popd 42goto :eof 43 44 45:installCmake 46 47powershell -command "$ErrorActionPreference = 'stop'; & { iwr https://cmake.org/files/v3.3/%CMAKE_NAME%.zip -OutFile cmake.zip }" || exit /b 1 48powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1 49del cmake.zip 50goto :eof 51