2014-04-17 14:19:07 +00:00
|
|
|
# Build compiler using CMake
|
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
## build on Unix-like System
|
|
|
|
|
|
|
|
### build using cmake
|
2014-04-17 14:19:07 +00:00
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
Use the following steps to build using cmake:
|
2014-04-17 14:19:07 +00:00
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
mkdir cmake-build
|
|
|
|
cd cmake-build
|
|
|
|
cmake ..
|
|
|
|
make
|
|
|
|
```
|
2014-06-17 10:36:39 +00:00
|
|
|
|
|
|
|
### Create an eclipse project
|
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
mkdir cmake-ec && cd cmake-ec
|
|
|
|
cmake -G "Eclipse CDT4 - Unix Makefiles" ..
|
|
|
|
make
|
|
|
|
```
|
2014-06-17 10:36:39 +00:00
|
|
|
|
2015-05-16 20:40:17 +00:00
|
|
|
Now open the folder cmake-ec using eclipse.
|
2014-06-17 10:36:39 +00:00
|
|
|
|
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
## Cross compile using mingw32 and generate a Windows Installer with CPack
|
2014-06-17 10:36:39 +00:00
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
mkdir cmake-mingw32 && cd cmake-mingw32
|
|
|
|
cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF ..
|
|
|
|
cpack
|
|
|
|
```
|
2014-08-15 20:16:02 +00:00
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
# Build on windows
|
2014-04-17 14:19:07 +00:00
|
|
|
|
2015-05-15 10:01:38 +00:00
|
|
|
### using Git Bash
|
2017-01-23 13:52:04 +00:00
|
|
|
|
2015-05-15 10:01:38 +00:00
|
|
|
Git Bash provides flex and bison, so you just need to do this:
|
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
mkdir cmake-vs && cd cmake-vs
|
|
|
|
cmake -DWITH_SHARED_LIB=off ..
|
|
|
|
```
|
2015-05-15 10:01:38 +00:00
|
|
|
|
|
|
|
### using Win flex-bison
|
|
|
|
|
|
|
|
In order to build on windows with winflexbison a few additional steps are necessary:
|
2014-04-17 14:19:07 +00:00
|
|
|
|
|
|
|
1. Download winflexbison from http://sourceforge.net/projects/winflexbison/
|
|
|
|
2. Extract the winflex bison files to for e.g. C:\winflexbison
|
|
|
|
3. Make the CMake variables point to the correct binaries.
|
2015-01-28 23:30:08 +00:00
|
|
|
* FLEX_EXECUTABLE = C:/winbuild/win_flex.exe
|
|
|
|
* BISON_EXECUTABLE = C:/winbuild/win_bison.exe
|
2015-05-15 10:01:38 +00:00
|
|
|
4. Generate a Visual Studio project:
|
|
|
|
```
|
2015-05-16 20:40:17 +00:00
|
|
|
mkdir cmake-vs && cd cmake-vs
|
2015-05-15 10:01:38 +00:00
|
|
|
cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off ..
|
|
|
|
```
|
|
|
|
5. Now open the folder build_vs using Visual Studio 2013.
|
2014-06-17 10:36:39 +00:00
|
|
|
|
2014-06-14 19:59:24 +00:00
|
|
|
# Building the Thrift IDL compiler in Windows
|
|
|
|
|
2014-06-17 10:36:39 +00:00
|
|
|
If you don't want to use CMake you can use the already available Visual Studio
|
|
|
|
2010 solution.
|
2014-06-14 19:59:24 +00:00
|
|
|
The Visual Studio project contains pre-build commands to generate the
|
|
|
|
thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build
|
|
|
|
the compiler. These depend on bison, flex and their dependencies to
|
2016-10-02 05:21:55 +00:00
|
|
|
work properly.
|
|
|
|
Download flex & bison as described above.
|
|
|
|
Place these binaries somewhere in the path and
|
|
|
|
rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
|
|
|
|
|
|
|
|
If this doesn't work on a system, try these manual pre-build steps.
|
2014-06-14 19:59:24 +00:00
|
|
|
|
|
|
|
Open compiler.sln and remove the Pre-build commands under the project's
|
|
|
|
Properties -> Build Events -> Pre-Build Events.
|
|
|
|
|
|
|
|
From a command prompt:
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
cd thrift/compiler/cpp
|
|
|
|
flex -osrc\thrift\thriftl.cc src\thrift\thriftl.ll
|
|
|
|
```
|
2014-06-14 19:59:24 +00:00
|
|
|
In the generated thriftl.cc, comment out #include <unistd.h>
|
|
|
|
|
|
|
|
Place a copy of bison.simple in thrift/compiler/cpp
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
|
|
|
|
move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
|
|
|
|
```
|
2014-06-14 19:59:24 +00:00
|
|
|
|
|
|
|
Bison 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".
|
|
|
|
|
2017-01-23 13:52:04 +00:00
|
|
|
```
|
|
|
|
move src\thrift\version.h.in src\thrift\version.h
|
|
|
|
```
|
2014-06-14 19:59:24 +00:00
|
|
|
|
|
|
|
Download inttypes.h from the interwebs and place it in an include path
|
|
|
|
location (e.g. thrift/compiler/cpp/src).
|
|
|
|
|
|
|
|
Build the compiler in Visual Studio.
|