]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/compiler/cpp/README.md
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / thrift / compiler / cpp / 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 ```
38 mkdir cmake-build && cd cmake-build
39 cmake ..
40 make
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 ```
49 mkdir cmake-ec && cd cmake-ec
50 cmake -G "Eclipse CDT4 - Unix Makefiles" ..
51 make
52 ```
53
54 Now 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 ```
61 brew install cmake
62 brew install bison
63 ```
64
65 - Go to **thrift\compiler\cpp**
66 - Run commands in command line:
67
68 ```
69 mkdir cmake-build && cd cmake-build
70 cmake -G "Xcode" ..
71 cmake --build .
72 ```
73
74 #### Usage of other IDEs
75
76 Please check list of supported IDE
77
78 ```
79 cmake --help
80 ```
81
82 ## Build on Windows
83
84 ### Prerequisites
85 - Install CMake - https://cmake.org/download/
86 - In case if you want to build without Git Bash - install winflexbison - https://sourceforge.net/projects/winflexbison/
87 - In case if you want to build with Visual Studio - install Visual Studio
88 - 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
89
90 ### Build using Git Bash
91
92 Git Bash provides flex and bison
93
94 - Go to **thrift\compiler\cpp**
95 - Use the following steps to build using cmake:
96
97 ```
98 mkdir cmake-vs && cd cmake-vs
99 cmake -DWITH_SHARED_LIB=off ..
100 cmake --build .
101 ```
102
103 ### Using Visual Studio and Win flex-bison
104
105 - Generate a Visual Studio project for version of Visual Studio which you have (**cmake --help** can show list of supportable VS versions):
106 - Run commands in command line:
107 ```
108 mkdir cmake-vs
109 cd cmake-vs
110 cmake -G "Visual Studio 15 2017" ..
111 ```
112 - Now open the folder cmake-vs using Visual Studio.
113
114 ### Cross compile using mingw32 and generate a Windows Installer with CPack
115
116 ```
117 mkdir cmake-mingw32 && cd cmake-mingw32
118 cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF ..
119 cpack
120 ```
121
122 # Other cases
123
124 ## Building the Thrift IDL compiler in Windows without CMake
125
126 If you don't want to use CMake you can use the already available Visual Studio 2010 solution.
127
128 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.
129
130 These depend on bison, flex and their dependencies to work properly.
131
132 Download flex & bison as described above.
133
134 Place these binaries somewhere in the path and rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.
135
136 If this doesn't work on a system, try these manual pre-build steps.
137
138 Open compiler.sln and remove the Pre-build commands under the project's: Properties -> Build Events -> Pre-Build Events.
139
140 From a command prompt:
141 ```
142 cd thrift/compiler/cpp
143 flex -o src\thrift\thriftl.cc src\thrift\thriftl.ll
144 ```
145 In the generated thriftl.cc, comment out #include <unistd.h>
146
147 Place a copy of bison.simple in thrift/compiler/cpp
148 ```
149 bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
150 move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh
151 ```
152
153 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".
154
155 ```
156 move src\thrift\version.h.in src\thrift\version.h
157 ```
158
159 Download inttypes.h from the interwebs and place it in an include path
160 location (e.g. thrift/compiler/cpp/src).
161
162 Build the compiler in Visual Studio.
163
164 # Unit tests for compiler
165
166 ## Using boost test
167 - pls check **test** folder
168
169 ## Using Catch C++ test library
170
171 Added 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 **netcore** implementation)
172
173 - pls check **tests** folder
174
175 # Have a Happy free time and holidays