blob: 5ec28793e51915efbb6491fb922f4d9ef1c98608 [file] [log] [blame]
Shaoyu Zhang3adaf0d2026-02-20 13:28:16 -08001::
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
24IF 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
31IF 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
38IF NOT EXIST C:\build (MKDIR C:\build)
39cd c:\build
40
41:: Generate the out-of-tree build files
42cmake^
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
54cmake --build . --config Release || EXIT /B
55
56:: Test
57ctest -C Release || EXIT /B
58
59:: Install (needed before netstd scripts so thrift.exe is in C:\install\bin)
60cmake --install . || EXIT /B
61
62:: Build and test .NET (netstd) library if dotnet CLI is available
63IF /I "%THRIFT_BUILD_DOTNET%"=="OFF" GOTO SKIP_DOTNET
64IF EXIST "C:\Program Files (x86)\dotnet\dotnet.exe" SET PATH=C:\Program Files (x86)\dotnet;%PATH%
65IF EXIST "C:\Program Files\dotnet\dotnet.exe" SET PATH=C:\Program Files\dotnet;%PATH%
66where dotnet >NUL 2>NUL
67IF ERRORLEVEL 1 (
68 ECHO dotnet CLI not found, skipping netstd build/test
69 GOTO SKIP_DOTNET
70)
71SET HAS_DOTNET_SDK=
72FOR /F "delims=" %%I IN ('dotnet --list-sdks 2^>NUL') DO SET HAS_DOTNET_SDK=1
73IF NOT DEFINED HAS_DOTNET_SDK (
74 ECHO dotnet SDK not found, skipping netstd build/test
75 GOTO SKIP_DOTNET
76)
77
78PUSHD C:\thrift\lib\netstd
79IF EXIST C:\install\bin\thrift.exe SET PATH=C:\install\bin;%PATH%
80IF EXIST C:\build\bin\Release\thrift.exe SET PATH=C:\build\bin\Release;%PATH%
81IF EXIST C:\build\compiler\cpp\Release\thrift.exe SET PATH=C:\build\compiler\cpp\Release;%PATH%
82IF EXIST C:\build\compiler\cpp\thrift.exe SET PATH=C:\build\compiler\cpp;%PATH%
83where thrift >NUL 2>NUL
84IF ERRORLEVEL 1 (
85 ECHO thrift compiler not found on PATH, skipping netstd build/test
86 POPD
87 GOTO SKIP_DOTNET
88)
89call build.cmd || EXIT /B
90IF /I NOT "%THRIFT_TEST_DOTNET%"=="OFF" (
91 call runtests.cmd || EXIT /B
92)
93POPD
94
95:SKIP_DOTNET