blob: 3c40809ca311b0b3c9db462542c15915a91faac7 [file] [log] [blame] [view]
Pascal Bach6eb015a2014-04-17 16:19:07 +02001# Build compiler using CMake
2
henrique55087a42014-06-17 12:36:39 +02003Use the following steps to build using cmake:
Pascal Bach6eb015a2014-04-17 16:19:07 +02004
Roger Meier746952e2014-06-14 21:59:24 +02005 mkdir build
6 cd build
7 cmake ..
8 make
Pascal Bach6eb015a2014-04-17 16:19:07 +02009
henrique55087a42014-06-17 12:36:39 +020010
11### Create an eclipse project
12
13 mkdir build_ec && cd build_ec
14 cmake -G "Eclipse CDT4 - Unix Makefiles" ..
15 make
16
17Now open the folder build_ec using eclipse.
18
19
20### Cross compile using mingw32
21
22 mkdir build_mingw32 && cd build_mingw32
23 cmake -DCMAKE_TOOLCHAIN_FILE=../../../contrib/mingw32-toolchain.cmake ..
24 make
25
Roger Meier87202602014-08-15 22:16:02 +020026### Generate a Windows Installer Package of the Apache Thrift Compiler
henrique55087a42014-06-17 12:36:39 +020027
Roger Meier87202602014-08-15 22:16:02 +020028 cmake -DCMAKE_TOOLCHAIN_FILE=../../../contrib/mingw32-toolchain.cmake -DTHRIFT_COMPILER_HS=OFF ..
29 cpack
30
31Haskell uses C++ features not supported by mingw32 such as auto or nullptr, that's why we disable it.
henrique55087a42014-06-17 12:36:39 +020032
Pascal Bach6eb015a2014-04-17 16:19:07 +020033## Build on windows
34
henrique55087a42014-06-17 12:36:39 +020035In order to build on windows a few additional steps are necessary:
Pascal Bach6eb015a2014-04-17 16:19:07 +020036
371. Download winflexbison from http://sourceforge.net/projects/winflexbison/
382. Extract the winflex bison files to for e.g. C:\winflexbison
393. Make the CMake variables point to the correct binaries.
40 * FLEX_EXECUTBALE = C:/winbuild/win_flex.exe
41 * BISON_EXECUTBALE = C:/winbuild/win_bison.exe
42
henrique55087a42014-06-17 12:36:39 +020043
44### Create a Visual Studio project
45
46 mkdir build_vs && cd build_vs
47 cmake -G "Visual Studio 12" ..
48
49Now open the folder build_vs using Visual Studio 2013.
50
51
52
53
Roger Meier746952e2014-06-14 21:59:24 +020054# Building the Thrift IDL compiler in Windows
55
henrique55087a42014-06-17 12:36:39 +020056If you don't want to use CMake you can use the already available Visual Studio
572010 solution.
Roger Meier746952e2014-06-14 21:59:24 +020058The Visual Studio project contains pre-build commands to generate the
59thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build
60the compiler. These depend on bison, flex and their dependencies to
61work properly. If this doesn't work on a system, try these manual
62pre-build steps.
63
64Open compiler.sln and remove the Pre-build commands under the project's
65 Properties -> Build Events -> Pre-Build Events.
66
67Download flex & bison from http://jaisantonyk.wordpress.com/2008/03/16/lex-and-yaccbison-in-windows/
68Download bison.simple in addition to bison.exe . This build of bison is easier to use
69than the one on sourceforge which has a myriad of dependencies.
70Place these binaries somewhere in the path.
71
72From a command prompt:
73> cd thrift/compiler/cpp
74> flex -osrc\thriftl.cc src\thriftl.ll
75In the generated thriftl.cc, comment out #include <unistd.h>
76
77Place a copy of bison.simple in thrift/compiler/cpp
78> bison -y -o "src/thrifty.cc" --defines src/thrifty.yy
79> move src\thrifty.cc.hh src\thrifty.hh
80
81Bison might generate the yacc header file "thrifty.cc.h" with just one h ".h" extension; in this case you'll have to rename to "thrifty.h".
82
83> move src\windows\version.h.in src\windows\version.h
84
85Download inttypes.h from the interwebs and place it in an include path
86location (e.g. thrift/compiler/cpp/src).
87
88Build the compiler in Visual Studio.