blob: 90300ac03bb68e00426e32ab268be9f3cae523f6 [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 Meier880a2b32015-05-16 22:40:17 +02005 mkdir cmake-build
6 cd cmake-build
Roger Meier746952e2014-06-14 21:59:24 +02007 cmake ..
8 make
Pascal Bach6eb015a2014-04-17 16:19:07 +02009
henrique55087a42014-06-17 12:36:39 +020010
11### Create an eclipse project
12
Roger Meier880a2b32015-05-16 22:40:17 +020013 mkdir cmake-ec && cd cmake-ec
henrique55087a42014-06-17 12:36:39 +020014 cmake -G "Eclipse CDT4 - Unix Makefiles" ..
15 make
16
Roger Meier880a2b32015-05-16 22:40:17 +020017Now open the folder cmake-ec using eclipse.
henrique55087a42014-06-17 12:36:39 +020018
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
Roger Meier880a2b32015-05-16 22:40:17 +020022 mkdir cmake-mingw32 && cd cmake-mingw32
23 cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
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
Roger Meier880a2b32015-05-16 22:40:17 +020031 mkdir cmake-vs && cd cmake-vs
Roger Meier86fded22015-05-15 12:01:38 +020032 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```
Roger Meier880a2b32015-05-16 22:40:17 +020045mkdir cmake-vs && cd cmake-vs
Roger Meier86fded22015-05-15 12:01:38 +020046cmake -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
Nobuaki Sukegawad8c6a842016-10-02 14:21:55 +090057work properly.
58Download flex & bison as described above.
59Place these binaries somewhere in the path and
60rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
61
62If this doesn't work on a system, try these manual pre-build steps.
Roger Meier746952e2014-06-14 21:59:24 +020063
64Open compiler.sln and remove the Pre-build commands under the project's
65 Properties -> Build Events -> Pre-Build Events.
66
Roger Meier746952e2014-06-14 21:59:24 +020067From a command prompt:
68> cd thrift/compiler/cpp
Nobuaki Sukegawad8c6a842016-10-02 14:21:55 +090069> flex -osrc\thrift\thriftl.cc src\thrift\thriftl.ll
Roger Meier746952e2014-06-14 21:59:24 +020070In the generated thriftl.cc, comment out #include <unistd.h>
71
72Place a copy of bison.simple in thrift/compiler/cpp
Nobuaki Sukegawad8c6a842016-10-02 14:21:55 +090073> bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
74> move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
Roger Meier746952e2014-06-14 21:59:24 +020075
76Bison 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".
77
Nobuaki Sukegawad8c6a842016-10-02 14:21:55 +090078> move src\thrift\version.h.in src\thrift\version.h
Roger Meier746952e2014-06-14 21:59:24 +020079
80Download inttypes.h from the interwebs and place it in an include path
81location (e.g. thrift/compiler/cpp/src).
82
83Build the compiler in Visual Studio.