blob: b4a159f1e181b7b64a45951f438b4c3631b7c6fb [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
Roger Meier311f7152014-08-17 22:24:30 +020020### Cross compile using mingw32 and generate a Windows Installer with CPack
henrique55087a42014-06-17 12:36:39 +020021
22 mkdir build_mingw32 && cd build_mingw32
Konrad Grochowski99b9e1d2014-10-01 00:14:14 +020023 cmake -DCMAKE_TOOLCHAIN_FILE=../../../contrib/mingw32-toolchain.cmake ..
Roger Meier87202602014-08-15 22:16:02 +020024 cpack
25
Pascal Bach6eb015a2014-04-17 16:19:07 +020026## Build on windows
27
Roger Meier86fded22015-05-15 12:01:38 +020028### using Git Bash
29Git Bash provides flex and bison, so you just need to do this:
30
31 mkdir build_vs && cd build_vs
32 cmake -DWITH_SHARED_LIB=off ..
33
34### using Win flex-bison
35
36In order to build on windows with winflexbison a few additional steps are necessary:
Pascal Bach6eb015a2014-04-17 16:19:07 +020037
381. Download winflexbison from http://sourceforge.net/projects/winflexbison/
392. Extract the winflex bison files to for e.g. C:\winflexbison
403. Make the CMake variables point to the correct binaries.
Jens Geyer176c9262015-01-29 00:30:08 +010041 * FLEX_EXECUTABLE = C:/winbuild/win_flex.exe
42 * BISON_EXECUTABLE = C:/winbuild/win_bison.exe
Roger Meier86fded22015-05-15 12:01:38 +0200434. Generate a Visual Studio project:
44```
45mkdir build_vs && cd build_vs
46cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off ..
47```
485. Now open the folder build_vs using Visual Studio 2013.
henrique55087a42014-06-17 12:36:39 +020049
Roger Meier746952e2014-06-14 21:59:24 +020050# Building the Thrift IDL compiler in Windows
51
henrique55087a42014-06-17 12:36:39 +020052If you don't want to use CMake you can use the already available Visual Studio
532010 solution.
Roger Meier746952e2014-06-14 21:59:24 +020054The Visual Studio project contains pre-build commands to generate the
55thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build
56the compiler. These depend on bison, flex and their dependencies to
57work properly. If this doesn't work on a system, try these manual
58pre-build steps.
59
60Open compiler.sln and remove the Pre-build commands under the project's
61 Properties -> Build Events -> Pre-Build Events.
62
63Download flex & bison from http://jaisantonyk.wordpress.com/2008/03/16/lex-and-yaccbison-in-windows/
64Download bison.simple in addition to bison.exe . This build of bison is easier to use
65than the one on sourceforge which has a myriad of dependencies.
66Place these binaries somewhere in the path.
67
68From a command prompt:
69> cd thrift/compiler/cpp
70> flex -osrc\thriftl.cc src\thriftl.ll
71In the generated thriftl.cc, comment out #include <unistd.h>
72
73Place a copy of bison.simple in thrift/compiler/cpp
74> bison -y -o "src/thrifty.cc" --defines src/thrifty.yy
75> move src\thrifty.cc.hh src\thrifty.hh
76
77Bison 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".
78
79> move src\windows\version.h.in src\windows\version.h
80
81Download inttypes.h from the interwebs and place it in an include path
82location (e.g. thrift/compiler/cpp/src).
83
84Build the compiler in Visual Studio.