blob: 77cb23421ec8e9e6497c7fe40d479bae3e83d959 [file] [log] [blame] [view]
Pascal Bach6eb015a2014-04-17 16:19:07 +02001# Build compiler using CMake
2
James E. King, III330b3f82017-01-23 08:52:04 -05003## build on Unix-like System
4
5### build using cmake
6
henrique55087a42014-06-17 12:36:39 +02007Use the following steps to build using cmake:
Pascal Bach6eb015a2014-04-17 16:19:07 +02008
James E. King, III330b3f82017-01-23 08:52:04 -05009```
10mkdir cmake-build
11cd cmake-build
12cmake ..
13make
14```
henrique55087a42014-06-17 12:36:39 +020015
16### Create an eclipse project
17
James E. King, III330b3f82017-01-23 08:52:04 -050018```
19mkdir cmake-ec && cd cmake-ec
20cmake -G "Eclipse CDT4 - Unix Makefiles" ..
21make
22```
henrique55087a42014-06-17 12:36:39 +020023
Roger Meier880a2b32015-05-16 22:40:17 +020024Now open the folder cmake-ec using eclipse.
henrique55087a42014-06-17 12:36:39 +020025
26
James E. King, III330b3f82017-01-23 08:52:04 -050027## Cross compile using mingw32 and generate a Windows Installer with CPack
henrique55087a42014-06-17 12:36:39 +020028
James E. King, III330b3f82017-01-23 08:52:04 -050029```
30mkdir cmake-mingw32 && cd cmake-mingw32
31cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
32cpack
33```
Roger Meier87202602014-08-15 22:16:02 +020034
James E. King, III330b3f82017-01-23 08:52:04 -050035# Build on windows
Pascal Bach6eb015a2014-04-17 16:19:07 +020036
Roger Meier86fded22015-05-15 12:01:38 +020037### using Git Bash
James E. King, III330b3f82017-01-23 08:52:04 -050038
Roger Meier86fded22015-05-15 12:01:38 +020039Git Bash provides flex and bison, so you just need to do this:
40
James E. King, III330b3f82017-01-23 08:52:04 -050041```
42mkdir cmake-vs && cd cmake-vs
43cmake -DWITH_SHARED_LIB=off ..
44```
Roger Meier86fded22015-05-15 12:01:38 +020045
46### using Win flex-bison
47
48In order to build on windows with winflexbison a few additional steps are necessary:
Pascal Bach6eb015a2014-04-17 16:19:07 +020049
501. Download winflexbison from http://sourceforge.net/projects/winflexbison/
512. Extract the winflex bison files to for e.g. C:\winflexbison
523. Make the CMake variables point to the correct binaries.
Jens Geyer176c9262015-01-29 00:30:08 +010053 * FLEX_EXECUTABLE = C:/winbuild/win_flex.exe
54 * BISON_EXECUTABLE = C:/winbuild/win_bison.exe
Roger Meier86fded22015-05-15 12:01:38 +0200554. Generate a Visual Studio project:
56```
Roger Meier880a2b32015-05-16 22:40:17 +020057mkdir cmake-vs && cd cmake-vs
Roger Meier86fded22015-05-15 12:01:38 +020058cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off ..
59```
605. Now open the folder build_vs using Visual Studio 2013.
henrique55087a42014-06-17 12:36:39 +020061
Roger Meier746952e2014-06-14 21:59:24 +020062# Building the Thrift IDL compiler in Windows
63
henrique55087a42014-06-17 12:36:39 +020064If you don't want to use CMake you can use the already available Visual Studio
652010 solution.
Roger Meier746952e2014-06-14 21:59:24 +020066The Visual Studio project contains pre-build commands to generate the
67thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build
68the compiler. These depend on bison, flex and their dependencies to
Nobuaki Sukegawad8c6a842016-10-02 14:21:55 +090069work properly.
70Download flex & bison as described above.
71Place these binaries somewhere in the path and
72rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
73
74If this doesn't work on a system, try these manual pre-build steps.
Roger Meier746952e2014-06-14 21:59:24 +020075
76Open compiler.sln and remove the Pre-build commands under the project's
77 Properties -> Build Events -> Pre-Build Events.
78
Roger Meier746952e2014-06-14 21:59:24 +020079From a command prompt:
James E. King, III330b3f82017-01-23 08:52:04 -050080```
81cd thrift/compiler/cpp
82flex -osrc\thrift\thriftl.cc src\thrift\thriftl.ll
83```
Roger Meier746952e2014-06-14 21:59:24 +020084In the generated thriftl.cc, comment out #include <unistd.h>
85
86Place a copy of bison.simple in thrift/compiler/cpp
James E. King, III330b3f82017-01-23 08:52:04 -050087```
88bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
89move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
90```
Roger Meier746952e2014-06-14 21:59:24 +020091
92Bison 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".
93
James E. King, III330b3f82017-01-23 08:52:04 -050094```
95move src\thrift\version.h.in src\thrift\version.h
96```
Roger Meier746952e2014-06-14 21:59:24 +020097
98Download inttypes.h from the interwebs and place it in an include path
99location (e.g. thrift/compiler/cpp/src).
100
101Build the compiler in Visual Studio.