blob: b6b42a8d76f80c897aa9869c5b7e4622e2558333 [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:: Produces a production thrift compiler suitable for redistribution.
17:: The compiler is linked to runtime statically for maximum portability.
18:: Assumes the thirdparty files for "winflexbison" have been placed
19:: according to the README.md instructions.
20::
21:: Open a Visual Studio Command Prompt of your choosing and then
22:: run this script.
23
24@ECHO OFF
25SETLOCAL EnableDelayedExpansion
26
27IF NOT DEFINED PACKAGE_NAME SET PACKAGE_NAME=thrift
28IF NOT DEFINED PACKAGE_VERSION SET PACKAGE_VERSION=dev
29IF NOT DEFINED SOURCE_DIR SET SOURCEDIR=%~dp0%PACKAGE_NAME%
30IF NOT DEFINED WIN3P_ROOT SET WIN3P_ROOT=%~dp0thirdparty
31
32:: Set COMPILER to (vc100 - vc140) depending on the current environment
33CALL scripts\cl_setcompiler.bat || EXIT /B
34
35:: Set ARCH to either win32 or x64 depending on the current environment
36CALL scripts\cl_setarch.bat || EXIT /B
37
38:: Set GENERATOR for CMake depending on the current environment
39CALL scripts\cl_setgenerator.bat || EXIT /B
40
41IF NOT DEFINED BUILDTYPE (
42 SET BUILDTYPE=Release
43)
44
45 SET BUILDDIR=%~dp0build\%PACKAGE_NAME%-compiler\%PACKAGE_VERSION%\%COMPILER%\
46 SET OUTDIR=%~dp0dist\%PACKAGE_NAME%-compiler-%PACKAGE_VERSION%\%COMPILER%\%ARCH%\%BUILDTYPE%\
47 SET BOOST_LIBDIR=lib%ARCH:~-2,2%-msvc-%COMPILER:~-3,2%.0
48 IF "%BUILDTYPE%" == "Debug" (SET ZLIB_STATIC_SUFFIX=d)
49
50 ECHO/
51 ECHO =========================================================================
52 ECHO Configuration: %PACKAGE_NAME% %PACKAGE_VERSION% %COMPILER%:%ARCH%:%BUILDTYPE% "%GENERATOR%"
53IF DEFINED COMPILERONLY (
54 ECHO COMPILER ONLY
55)
56 ECHO Build Directory: %BUILDDIR%
57 ECHO Install Directory: %OUTDIR%
58 ECHO Source Directory: %SOURCEDIR%
59 ECHO =========================================================================
60 ECHO/
61
62 MKDIR "%BUILDDIR%"
63 CD "%BUILDDIR%" || EXIT /B
64
65 CMAKE.EXE %~dp0thrift ^
66 -G"%GENERATOR%" ^
67 -DBISON_EXECUTABLE=%WIN3P_ROOT%\dist\winflexbison\win_bison.exe ^
68 -DCMAKE_BUILD_TYPE=%BUILDTYPE% ^
69 -DFLEX_EXECUTABLE=%WIN3P_ROOT%\dist\winflexbison\win_flex.exe ^
70 -DWITH_MT=ON ^
71 -DWITH_SHARED_LIB=OFF || EXIT /B
72
73 CD %BUILDDIR%
74
75 CMAKE.EXE --build . --config %BUILDTYPE% --target thrift-compiler || EXIT /B
76 XCOPY /F /Y %BUILDDIR%\bin\%BUILDTYPE%\thrift.exe %OUTDIR%
77
78ENDLOCAL
79EXIT /B