| Shaoyu Zhang | 3adaf0d | 2026-02-20 13:28:16 -0800 | [diff] [blame] | 1 | :: |
| 2 | :: Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | :: you may not use this file except in compliance with the License. |
| 4 | :: You may obtain a copy of the License at |
| 5 | :: |
| 6 | :: http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | :: |
| 8 | :: Unless required by applicable law or agreed to in writing, software |
| 9 | :: distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | :: See the License for the specific language governing permissions and |
| 12 | :: limitations under the License. |
| 13 | :: |
| 14 | |
| 15 | :: |
| 16 | :: Build script example for inside the windows docker container |
| 17 | :: |
| 18 | :: C:\build is the out-of-tree build directory |
| 19 | :: C:\install is the location where artifacts are placed |
| 20 | :: C:\thrift is where the sources are |
| 21 | :: |
| 22 | |
| 23 | |
| 24 | IF EXIST "C:\Program Files\dotnet\dotnet.exe" ( |
| 25 | FOR /F "tokens=1" %%I IN ('"C:\Program Files\dotnet\dotnet.exe" --list-sdks 2^>NUL') DO ( |
| 26 | SET DOTNET_SDK_VERSION=%%I |
| 27 | GOTO GOT_DOTNET_SDK |
| 28 | ) |
| 29 | ) |
| 30 | :GOT_DOTNET_SDK |
| 31 | IF DEFINED DOTNET_SDK_VERSION ( |
| 32 | IF EXIST "C:\Program Files\dotnet\sdk\%DOTNET_SDK_VERSION%\Sdks" ( |
| 33 | SET MSBuildSDKsPath=C:\Program Files\dotnet\sdk\%DOTNET_SDK_VERSION%\Sdks |
| 34 | ) |
| 35 | ) |
| 36 | |
| 37 | :: Make and go into the out-of-tree directory |
| 38 | IF NOT EXIST C:\build (MKDIR C:\build) |
| 39 | cd c:\build |
| 40 | |
| 41 | :: Generate the out-of-tree build files |
| 42 | cmake^ |
| 43 | -DCMAKE_GENERATOR_PLATFORM=x64^ |
| 44 | -DBOOST_ROOT=%BOOST_ROOT%^ |
| 45 | -DFLEX_HOME=%FLEX_HOME%^ |
| 46 | -DLIBEVENT_ROOT=%LIBEVENT_ROOT%^ |
| 47 | -DZLIB_ROOT=%ZLIB_ROOT%^ |
| 48 | -DCMAKE_BUILD_TYPE=Release^ |
| 49 | -DBUILD_SHARED_LIBS=OFF^ |
| 50 | -DCMAKE_INSTALL_PREFIX=C:\install^ |
| 51 | c:\thrift || EXIT /B |
| 52 | |
| 53 | :: Build |
| 54 | cmake --build . --config Release || EXIT /B |
| 55 | |
| 56 | :: Test |
| 57 | ctest -C Release || EXIT /B |
| 58 | |
| 59 | :: Install (needed before netstd scripts so thrift.exe is in C:\install\bin) |
| 60 | cmake --install . || EXIT /B |
| 61 | |
| 62 | :: Build and test .NET (netstd) library if dotnet CLI is available |
| 63 | IF /I "%THRIFT_BUILD_DOTNET%"=="OFF" GOTO SKIP_DOTNET |
| 64 | IF EXIST "C:\Program Files (x86)\dotnet\dotnet.exe" SET PATH=C:\Program Files (x86)\dotnet;%PATH% |
| 65 | IF EXIST "C:\Program Files\dotnet\dotnet.exe" SET PATH=C:\Program Files\dotnet;%PATH% |
| 66 | where dotnet >NUL 2>NUL |
| 67 | IF ERRORLEVEL 1 ( |
| 68 | ECHO dotnet CLI not found, skipping netstd build/test |
| 69 | GOTO SKIP_DOTNET |
| 70 | ) |
| 71 | SET HAS_DOTNET_SDK= |
| 72 | FOR /F "delims=" %%I IN ('dotnet --list-sdks 2^>NUL') DO SET HAS_DOTNET_SDK=1 |
| 73 | IF NOT DEFINED HAS_DOTNET_SDK ( |
| 74 | ECHO dotnet SDK not found, skipping netstd build/test |
| 75 | GOTO SKIP_DOTNET |
| 76 | ) |
| 77 | |
| 78 | PUSHD C:\thrift\lib\netstd |
| 79 | IF EXIST C:\install\bin\thrift.exe SET PATH=C:\install\bin;%PATH% |
| 80 | IF EXIST C:\build\bin\Release\thrift.exe SET PATH=C:\build\bin\Release;%PATH% |
| 81 | IF EXIST C:\build\compiler\cpp\Release\thrift.exe SET PATH=C:\build\compiler\cpp\Release;%PATH% |
| 82 | IF EXIST C:\build\compiler\cpp\thrift.exe SET PATH=C:\build\compiler\cpp;%PATH% |
| 83 | where thrift >NUL 2>NUL |
| 84 | IF ERRORLEVEL 1 ( |
| 85 | ECHO thrift compiler not found on PATH, skipping netstd build/test |
| 86 | POPD |
| 87 | GOTO SKIP_DOTNET |
| 88 | ) |
| 89 | call build.cmd || EXIT /B |
| 90 | IF /I NOT "%THRIFT_TEST_DOTNET%"=="OFF" ( |
| 91 | call runtests.cmd || EXIT /B |
| 92 | ) |
| 93 | POPD |
| 94 | |
| 95 | :SKIP_DOTNET |