blob: ba3e47675e277c8beae64f1701bd6e21a0d7f88c [file] [log] [blame]
James E. King, III4d651ab2017-02-19 22:19:55 -05001::
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:: Generates a Visual Studio solution for thrift and then builds it.
17:: Assumes third party libraries have been built or placed already.
18::
19:: Open a Visual Studio Command Prompt of your choosing and then
20:: run this script.
21::
22:: Normally the script will run cmake to generate a solution, then
23:: perform a build, then run tests on the complete thrift library
24:: in release mode.
25::
26:: Flags you can use to change this behavior:
27::
28:: /DEBUG - debug instead of release
29:: /IDE - launch Visual Studio with a path set
30:: up correctly to run tests instead of
31:: performing any other actions, i.e.
32:: implies setting the next three flags
33:: /NOGENERATE - skip cmake generation - useful if you
34:: have already generated a solution and just
35:: want to build
36:: /NOBUILD - skip cmake build - useful if you just
37:: want to generate a solution
38:: /NOTEST - skip ctest execution
39::
40
41@ECHO OFF
42SETLOCAL EnableDelayedExpansion
43
44:: Sets variables for third party versions used in build
45CALL scripts\tpversions.bat || EXIT /B
46
47IF NOT DEFINED PACKAGE_NAME SET PACKAGE_NAME=thrift
48IF NOT DEFINED PACKAGE_VERSION SET PACKAGE_VERSION=dev
49IF NOT DEFINED SOURCE_DIR SET SOURCEDIR=%~dp0%PACKAGE_NAME%
50IF NOT DEFINED WIN3P_ROOT SET WIN3P_ROOT=%~dp0thirdparty
51
52:: Set COMPILER to (vc100 - vc140) depending on the current environment
53CALL scripts\cl_setcompiler.bat || EXIT /B
54
55:: Set ARCH to either win32 or x64 depending on the current environment
56CALL scripts\cl_setarch.bat || EXIT /B
57
58:: Set GENERATOR for CMake depending on the current environment
59CALL scripts\cl_setgenerator.bat || EXIT /B
60
61:: Defaults
62
63IF NOT DEFINED BUILDTYPE SET BUILDTYPE=Release
64SET OPT_IDE=0
65SET OPT_BUILD=1
66SET OPT_GENERATE=1
67SET OPT_TEST=1
68
69:: Apply Flags
70
71IF /I "%1" == "/DEBUG" SET BUILDTYPE=Debug
72IF /I "%2" == "/DEBUG" SET BUILDTYPE=Debug
73IF /I "%3" == "/DEBUG" SET BUILDTYPE=Debug
74IF /I "%1" == "/IDE" SET OPT_IDE=1
75IF /I "%2" == "/IDE" SET OPT_IDE=1
76IF /I "%3" == "/IDE" SET OPT_IDE=1
77IF /I "%1" == "/NOBUILD" SET OPT_BUILD=0
78IF /I "%2" == "/NOBUILD" SET OPT_BUILD=0
79IF /I "%3" == "/NOBUILD" SET OPT_BUILD=0
80IF /I "%1" == "/NOGENERATE" SET OPT_GENERATE=0
81IF /I "%2" == "/NOGENERATE" SET OPT_GENERATE=0
82IF /I "%3" == "/NOGENERATE" SET OPT_GENERATE=0
83IF /I "%1" == "/NOTEST" SET OPT_TEST=0
84IF /I "%2" == "/NOTEST" SET OPT_TEST=0
85IF /I "%3" == "/NOTEST" SET OPT_TEST=0
86
87IF %OPT_IDE% == 1 (
88 SET OPT_GENERATE=0
89 SET OPT_BUILD=0
90 SET OPT_TEST=0
91)
92
93 SET BUILDDIR=%~dp0build\%PACKAGE_NAME%\%PACKAGE_VERSION%\%COMPILER%\%ARCH%\
94 SET OUTDIR=%~dp0dist\%PACKAGE_NAME%-%PACKAGE_VERSION%\%COMPILER%\%ARCH%\%BUILDTYPE%\
95 SET BOOST_LIBDIR=lib%ARCH:~-2,2%-msvc-%COMPILER:~-3,2%.0
96 IF "%BUILDTYPE%" == "Debug" (SET ZLIB_STATIC_SUFFIX=d)
97
98 ECHO/
99 ECHO =========================================================================
100 ECHO Configuration: %PACKAGE_NAME% %PACKAGE_VERSION% %COMPILER%:%ARCH%:%BUILDTYPE% "%GENERATOR%"
101IF DEFINED COMPILERONLY (
102 ECHO COMPILER ONLY
103)
104 ECHO Build Directory: %BUILDDIR%
105 ECHO Install Directory: %OUTDIR%
106 ECHO Source Directory: %SOURCEDIR%
107 ECHO =========================================================================
108 ECHO/
109
110IF %OPT_IDE% == 1 (
111
112 CALL :SETRUNPATH || EXIT /B
113 CALL DEVENV "!BUILDDIR!Apache Thrift.sln" || EXIT /B
114 EXIT /B
115
116)
117
118 MKDIR "%BUILDDIR%"
119 CD "%BUILDDIR%" || EXIT /B
120
121IF %OPT_GENERATE% == 1 (
122
123 CMAKE.EXE %~dp0thrift ^
124 -G"%GENERATOR%" ^
125 -DBISON_EXECUTABLE=%WIN3P_ROOT%\dist\winflexbison\win_bison.exe ^
126 -DBOOST_ROOT=%WIN3P_ROOT%\dist\boost_%TP_BOOST_VERSION% ^
127 -DBOOST_LIBRARYDIR=%WIN3P_ROOT%\dist\boost_%TP_BOOST_VERSION%\%BOOST_LIBDIR% ^
128 -DCMAKE_INSTALL_PREFIX=%OUTDIR% ^
129 -DCMAKE_BUILD_TYPE=%BUILDTYPE% ^
130 -DFLEX_EXECUTABLE=%WIN3P_ROOT%\dist\winflexbison\win_flex.exe ^
131 -DINTTYPES_ROOT=%WIN3P_ROOT%\dist\msinttypes ^
132 -DLIBEVENT_ROOT=%WIN3P_ROOT%\dist\libevent-%TP_LIBEVENT_VERSION%\%COMPILER%\%ARCH%\%BUILDTYPE% ^
133 -DOPENSSL_ROOT_DIR=%WIN3P_ROOT%\dist\openssl-%TP_OPENSSL_VERSION%\%COMPILER%\%ARCH%\%BUILDTYPE%\dynamic ^
134 -DOPENSSL_USE_STATIC_LIBS=OFF ^
135 -DZLIB_LIBRARY=%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH%\lib\zlib%ZLIB_LIB_SUFFIX%.lib ^
136 -DZLIB_ROOT=%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH% ^
137 -DWITH_BOOSTTHREADS=ON ^
138 -DWITH_SHARED_LIB=OFF ^
139 -DWITH_STATIC_LIB=ON || EXIT /B
140
141)
142
143IF %OPT_BUILD% == 1 (
144
145 CD %BUILDDIR%
146 CMAKE.EXE --build . --config %BUILDTYPE% --target INSTALL || EXIT /B
147
148)
149
150IF %OPT_TEST% == 1 (
151
152 CALL :SETRUNPATH || EXIT /B
153 CMAKE.EXE --build . --config %BUILDTYPE% --target RUN_TESTS || EXIT /B
154
155)
156
157:SETRUNPATH
158 SET PATH=!PATH!;%WIN3P_ROOT%\dist\boost_%TP_BOOST_VERSION%\%BOOST_LIBDIR%
159 SET PATH=!PATH!;%WIN3P_ROOT%\dist\openssl-%TP_OPENSSL_VERSION%\%COMPILER%\%ARCH%\%BUILDTYPE%\dynamic\bin
160 SET PATH=!PATH!;%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH%\bin
161 EXIT /B
162
163ENDLOCAL
164EXIT /B