Kun Zhang | 86d6412 | 2018-01-05 16:40:20 -0800 | [diff] [blame] | 1 | set PROTOBUF_VER=3.5.1 |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 2 | set CMAKE_NAME=cmake-3.3.2-win32-x86 |
| 3 | |
Eric Anderson | 2467d61 | 2015-10-22 18:11:44 -0700 | [diff] [blame] | 4 | if not exist "protobuf-%PROTOBUF_VER%\cmake\build\Release\" ( |
Eric Anderson | 4bd4cf4 | 2018-02-23 10:17:15 -0800 | [diff] [blame] | 5 | call :installProto || exit /b 1 |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 6 | ) |
Eric Anderson | a99e977 | 2015-10-01 11:38:49 -0700 | [diff] [blame] | 7 | |
| 8 | echo Compile gRPC-Java with something like: |
| 9 | echo -PtargetArch=x86_32 -PvcProtobufLibs=%cd%\protobuf-%PROTOBUF_VER%\cmake\build\Release -PvcProtobufInclude=%cd%\protobuf-%PROTOBUF_VER%\cmake\build\include |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 10 | goto :eof |
| 11 | |
| 12 | |
| 13 | :installProto |
| 14 | |
Eric Anderson | f48a509 | 2018-02-05 11:13:50 -0800 | [diff] [blame] | 15 | where /q cmake |
| 16 | if not ERRORLEVEL 1 goto :hasCmake |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 17 | if not exist "%CMAKE_NAME%" ( |
Eric Anderson | 4bd4cf4 | 2018-02-23 10:17:15 -0800 | [diff] [blame] | 18 | call :installCmake || exit /b 1 |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 19 | ) |
| 20 | set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin |
Eric Anderson | f48a509 | 2018-02-05 11:13:50 -0800 | [diff] [blame] | 21 | :hasCmake |
Eric Anderson | 9f677a9 | 2018-02-23 13:06:29 -0800 | [diff] [blame] | 22 | @rem GitHub requires TLSv1.2, and for whatever reason our powershell doesn't have it enabled |
Eric Anderson | ab92ff0 | 2018-02-23 11:30:27 -0800 | [diff] [blame] | 23 | powershell -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 |
| 24 | powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('protobuf.zip', '.') }" || exit /b 1 |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 25 | del protobuf.zip |
Eric Anderson | b1d72e5 | 2016-09-27 17:15:12 -0700 | [diff] [blame] | 26 | pushd protobuf-%PROTOBUF_VER%\cmake |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 27 | mkdir build |
| 28 | cd build |
zpencer | 19a64cc | 2018-03-22 17:56:59 -0700 | [diff] [blame] | 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 |
| 32 | if "%PLATFORM%" == "X64" ( |
| 33 | @rem Note the space |
| 34 | SET CMAKE_VSARCH= Win64 |
| 35 | ) else ( |
| 36 | SET CMAKE_VSARCH= |
| 37 | ) |
| 38 | cmake -Dprotobuf_BUILD_TESTS=OFF -G "Visual Studio %VisualStudioVersion:~0,2%%CMAKE_VSARCH%" .. || exit /b 1 |
Eric Anderson | 4bd4cf4 | 2018-02-23 10:17:15 -0800 | [diff] [blame] | 39 | msbuild /maxcpucount /p:Configuration=Release libprotoc.vcxproj || exit /b 1 |
| 40 | call extract_includes.bat || exit /b 1 |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 41 | popd |
| 42 | goto :eof |
| 43 | |
| 44 | |
| 45 | :installCmake |
| 46 | |
Eric Anderson | ab92ff0 | 2018-02-23 11:30:27 -0800 | [diff] [blame] | 47 | powershell -command "$ErrorActionPreference = 'stop'; & { iwr https://cmake.org/files/v3.3/%CMAKE_NAME%.zip -OutFile cmake.zip }" || exit /b 1 |
| 48 | powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1 |
Eric Anderson | d04994f | 2015-09-24 15:27:26 -0700 | [diff] [blame] | 49 | del cmake.zip |
| 50 | goto :eof |