• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/11-Mar-2024-77,42558,791

test/11-Mar-2024-643495

tests/11-Mar-2024-13,02710,135

CMakeLists.txtD11-Mar-20246.2 KiB147124

Makefile.amD11-Mar-20245.3 KiB13294

README.mdD11-Mar-20245.2 KiB177125

coding_standards.mdD11-Mar-2024194 43

compiler.slnD11-Mar-2024862 2119

compiler.vcxprojD11-Mar-202413.2 KiB252251

compiler.vcxproj.filtersD11-Mar-20246.8 KiB203202

README.md

1# Build Thrift IDL compiler using CMake
2
3<!-- TOC -->
4
5- [Build Thrift IDL compiler using CMake](#build-thrift-idl-compiler-using-cmake)
6    - [Build on Unix-like System](#build-on-unix-like-system)
7        - [Prerequisites](#prerequisites)
8        - [Build using CMake](#build-using-cmake)
9            - [Build with Eclipse IDE](#build-with-eclipse-ide)
10            - [Build with XCode IDE in MacOS](#build-with-xcode-ide-in-macos)
11            - [Usage of other IDEs](#usage-of-other-ides)
12    - [Build on Windows](#build-on-windows)
13        - [Prerequisites](#prerequisites-1)
14        - [Build using Git Bash](#build-using-git-bash)
15        - [Using Visual Studio and Win flex-bison](#using-visual-studio-and-win-flex-bison)
16        - [Cross compile using mingw32 and generate a Windows Installer with CPack](#cross-compile-using-mingw32-and-generate-a-windows-installer-with-cpack)
17- [Other cases](#other-cases)
18    - [Building the Thrift IDL compiler in Windows without CMake](#building-the-thrift-idl-compiler-in-windows-without-cmake)
19- [Unit tests for compiler](#unit-tests-for-compiler)
20    - [Using boost test](#using-boost-test)
21    - [Using Catch C++ test library](#using-catch-c-test-library)
22- [Have a Happy free time and holidays](#have-a-happy-free-time-and-holidays)
23
24<!-- /TOC -->
25
26## Build on Unix-like System
27
28### Prerequisites
29- Install CMake
30- Install flex and bison
31
32### Build using CMake
33
34- Go to **thrift\compiler\cpp**
35- Use the following steps to build using cmake:
36
37```
38mkdir cmake-build && cd cmake-build
39cmake ..
40make
41```
42
43#### Build with Eclipse IDE
44
45- Go to **thrift\compiler\cpp**
46- Use the following steps to build using cmake:
47
48```
49mkdir cmake-ec && cd cmake-ec
50cmake -G "Eclipse CDT4 - Unix Makefiles" ..
51make
52```
53
54Now open the folder cmake-ec using eclipse.
55
56#### Build with XCode IDE in MacOS
57
58- Install/update flex, bison and cmake with brew
59
60```
61brew install flex
62brew install bison
63brew install cmake
64```
65
66- Go to **thrift\compiler\cpp**
67- Run commands in command line:
68
69```
70mkdir cmake-build && cd cmake-build
71cmake -G "Xcode" ..
72cmake --build .
73```
74
75#### Usage of other IDEs
76
77Please check list of supported IDE
78
79```
80cmake --help
81```
82
83## Build on Windows
84
85### Prerequisites
86- Install CMake - https://cmake.org/download/
87- In case if you want to build without Git Bash - install winflexbison - https://sourceforge.net/projects/winflexbison/
88- In case if you want to build with Visual Studio - install Visual Studio
89  - Better to use the latest stable Visual Studio Community Edition - https://www.visualstudio.com/vs/whatsnew/ (ensure that you installed workload "Desktop Development with C++" for VS2017) - Microsoft added some support for CMake and improving it in Visual Studio
90
91### Build using Git Bash
92
93Git Bash provides flex and bison
94
95- Go to **thrift\compiler\cpp**
96- Use the following steps to build using cmake:
97
98```
99mkdir cmake-vs && cd cmake-vs
100cmake -DWITH_SHARED_LIB=off ..
101cmake --build .
102```
103
104### Using Visual Studio and Win flex-bison
105
106- Generate a Visual Studio project for version of Visual Studio which you have (**cmake --help** can show list of supportable VS versions):
107- Run commands in command line:
108```
109mkdir cmake-vs
110cd cmake-vs
111cmake -G "Visual Studio 15 2017" ..
112```
113- Now open the folder cmake-vs using Visual Studio.
114
115### Cross compile using mingw32 and generate a Windows Installer with CPack
116
117```
118mkdir cmake-mingw32 && cd cmake-mingw32
119cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF ..
120cpack
121```
122
123# Other cases
124
125## Building the Thrift IDL compiler in Windows without CMake
126
127If you don't want to use CMake you can use the already available Visual Studio 2010 solution.
128
129The 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.
130
131These depend on bison, flex and their dependencies to work properly.
132
133Download flex & bison as described above.
134
135Place these binaries somewhere in the path and rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
136
137If this doesn't work on a system, try these manual pre-build steps.
138
139Open compiler.sln and remove the Pre-build commands under the project's: Properties -> Build Events -> Pre-Build Events.
140
141From a command prompt:
142```
143cd thrift/compiler/cpp
144flex -o src\thrift\thriftl.cc src\thrift\thriftl.ll
145```
146In the generated thriftl.cc, comment out #include <unistd.h>
147
148Place a copy of bison.simple in thrift/compiler/cpp
149```
150bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
151move src\thrift\thrifty.cc.hh  src\thrift\thrifty.hh
152```
153
154Bison 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".
155
156```
157move src\thrift\version.h.in src\thrift\version.h
158```
159
160Download inttypes.h from the interwebs and place it in an include path
161location (e.g. thrift/compiler/cpp/src).
162
163Build the compiler in Visual Studio.
164
165# Unit tests for compiler
166
167## Using boost test
168- pls check **test** folder
169
170## Using Catch C++ test library
171
172Added generic way to cover code by tests for many languages (you just need to make a correct header file for generator for your language - example in **netstd** implementation)
173
174- pls check **tests** folder
175
176# Have a Happy free time and holidays
177