| 1 |
@rem Copyright 2016 gRPC authors. |
| 2 |
@rem |
| 3 |
@rem Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
@rem you may not use this file except in compliance with the License. |
| 5 |
@rem You may obtain a copy of the License at |
| 6 |
@rem |
| 7 |
@rem http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
@rem |
| 9 |
@rem Unless required by applicable law or agreed to in writing, software |
| 10 |
@rem distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
@rem See the License for the specific language governing permissions and |
| 13 |
@rem limitations under the License. |
| 14 |
|
| 15 |
@rem enter this directory |
| 16 |
cd /d %~dp0\..\..\.. |
| 17 |
|
| 18 |
@rem TODO(jtattermusch): Kokoro has pre-installed protoc.exe in C:\Program Files\ProtoC and that directory |
| 19 |
@rem is on PATH. To avoid picking up the older version protoc.exe, we change the path to something non-existent. |
| 20 |
set PATH=%PATH:ProtoC=DontPickupProtoC% |
| 21 |
|
| 22 |
@rem Install into ./testinstall, but use absolute path and foward slashes |
| 23 |
set INSTALL_DIR=%cd:\=/%/testinstall |
| 24 |
|
| 25 |
@rem Download OpenSSL-Win32 originally installed from https://slproweb.com/products/Win32OpenSSL.html |
| 26 |
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/grpc-testing.appspot.com/OpenSSL-Win32-1_1_0g.zip', 'OpenSSL-Win32.zip')" |
| 27 |
powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('OpenSSL-Win32.zip', '.');" |
| 28 |
|
| 29 |
@rem set absolute path to OpenSSL with forward slashes |
| 30 |
set OPENSSL_DIR=%cd:\=/%/OpenSSL-Win32 |
| 31 |
|
| 32 |
@rem TODO(jtattermusch): add support for GRPC_CPP_DISTRIBTEST_BUILD_COMPILER_JOBS env variable |
| 33 |
|
| 34 |
@rem Install absl |
| 35 |
mkdir third_party\abseil-cpp\cmake\build |
| 36 |
pushd third_party\abseil-cpp\cmake\build |
| 37 |
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\.. |
| 38 |
cmake --build . --config Release --target install || goto :error |
| 39 |
popd |
| 40 |
|
| 41 |
@rem Install c-ares |
| 42 |
mkdir third_party\cares\cares\cmake\build |
| 43 |
pushd third_party\cares\cares\cmake\build |
| 44 |
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\.. |
| 45 |
cmake --build . --config Release --target install || goto :error |
| 46 |
popd |
| 47 |
|
| 48 |
@rem Install protobuf |
| 49 |
mkdir third_party\protobuf\cmake\build |
| 50 |
pushd third_party\protobuf\cmake\build |
| 51 |
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DZLIB_ROOT=%INSTALL_DIR% -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_TESTS=OFF .. |
| 52 |
cmake --build . --config Release --target install || goto :error |
| 53 |
popd |
| 54 |
|
| 55 |
@rem Install re2 |
| 56 |
mkdir third_party\re2\cmake\build |
| 57 |
pushd third_party\re2\cmake\build |
| 58 |
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\.. |
| 59 |
cmake --build . --config Release --target install || goto :error |
| 60 |
popd |
| 61 |
|
| 62 |
@rem Install zlib |
| 63 |
mkdir third_party\zlib\cmake\build |
| 64 |
pushd third_party\zlib\cmake\build |
| 65 |
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ..\.. |
| 66 |
cmake --build . --config Release --target install || goto :error |
| 67 |
popd |
| 68 |
|
| 69 |
@rem Just before installing gRPC, wipe out contents of all the submodules to simulate |
| 70 |
@rem a standalone build from an archive |
| 71 |
@rem NOTE(lidiz) We used to use "git submodule deinit", but it leaves an empty |
| 72 |
@rem folder for deinit-ed submodules, blocking the CMake download. For users |
| 73 |
@rem downloaded gRPC code as an archive, they won't have submodule residual |
| 74 |
@rem folders, like the following command trying to imitate. |
| 75 |
git submodule foreach bash -c "cd $toplevel; rm -rf $name" |
| 76 |
|
| 77 |
@rem Install gRPC |
| 78 |
mkdir cmake\build |
| 79 |
pushd cmake\build |
| 80 |
cmake ^ |
| 81 |
-DCMAKE_BUILD_TYPE=Release ^ |
| 82 |
-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^ |
| 83 |
-DOPENSSL_ROOT_DIR=%OPENSSL_DIR% ^ |
| 84 |
-DZLIB_ROOT=%INSTALL_DIR% ^ |
| 85 |
-DgRPC_INSTALL=ON ^ |
| 86 |
-DgRPC_BUILD_TESTS=OFF ^ |
| 87 |
-DgRPC_BUILD_MSVC_MP_COUNT=-1 ^ |
| 88 |
-DgRPC_ABSL_PROVIDER=package ^ |
| 89 |
-DgRPC_CARES_PROVIDER=package ^ |
| 90 |
-DgRPC_PROTOBUF_PROVIDER=package ^ |
| 91 |
-DgRPC_RE2_PROVIDER=package ^ |
| 92 |
-DgRPC_SSL_PROVIDER=package ^ |
| 93 |
-DgRPC_ZLIB_PROVIDER=package ^ |
| 94 |
../.. || goto :error |
| 95 |
cmake --build . --config Release --target install || goto :error |
| 96 |
popd |
| 97 |
|
| 98 |
@rem Build helloworld example using cmake |
| 99 |
mkdir examples\cpp\helloworld\cmake\build |
| 100 |
pushd examples\cpp\helloworld\cmake\build |
| 101 |
cmake -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DOPENSSL_ROOT_DIR=%OPENSSL_DIR% -DZLIB_ROOT=%INSTALL_DIR% ../.. || goto :error |
| 102 |
cmake --build . --config Release || goto :error |
| 103 |
popd |
| 104 |
|
| 105 |
goto :EOF |
| 106 |
|
| 107 |
:error |
| 108 |
echo Failed! |
| 109 |
exit /b %errorlevel% |