thrift/compiler/cpp
Jens Geyer 5cf71b2bee THRIFT-5749 Option to enable RTTI info (2nd attempt)
Client: Delphi
Patch: Jens Geyer
2023-12-18 22:23:34 +01:00
..
src THRIFT-5749 Option to enable RTTI info (2nd attempt) 2023-12-18 22:23:34 +01:00
test * THRIFT-4655 Parser fails on the word "from" 2022-10-16 11:41:33 +02:00
tests THRIFT-5208: fix OCaml struct and exn raising/handling codegen 2022-09-11 22:19:29 +02:00
CMakeLists.txt THRIFT-5423: IDL parameter validation for Go 2022-09-11 08:25:32 -07:00
coding_standards.md THRIFT-2724 - Coding standards template added all over project 2015-02-05 12:15:19 +01:00
compiler.sln THRIFT-1031 Patch to compile Thrift for vc++ 9.0 and 10.0 2011-09-23 14:25:22 +00:00
compiler.vcxproj Revert "THRIFT-5501 Remove Common Lisp support" 2022-08-30 23:58:57 +02:00
compiler.vcxproj.filters THRIFT-5548: add kotlin code gen 2022-04-20 23:49:33 +02:00
Makefile.am THRIFT-5423: IDL parameter validation for Go 2022-09-11 08:25:32 -07:00
README.md Add missing javadoc 2021-08-10 07:14:05 +01:00

Build Thrift IDL compiler using CMake

Build on Unix-like System

Prerequisites

  • Install CMake
  • Install flex and bison

Build using CMake

  • Go to thrift\compiler\cpp
  • Use the following steps to build using cmake:
mkdir cmake-build && cd cmake-build
cmake ..
make

Build with Eclipse IDE

  • Go to thrift\compiler\cpp
  • Use the following steps to build using cmake:
mkdir cmake-ec && cd cmake-ec
cmake -G "Eclipse CDT4 - Unix Makefiles" ..
make

Now open the folder cmake-ec using eclipse.

Build with XCode IDE in MacOS

  • Install/update flex, bison and cmake with brew
brew install flex
brew install bison
brew install cmake
  • Go to thrift\compiler\cpp
  • Run commands in command line:
mkdir cmake-build && cd cmake-build
cmake -G "Xcode" ..
cmake --build .

Usage of other IDEs

Please check list of supported IDE

cmake --help

Build on Windows

Prerequisites

Build using Git Bash

Git Bash provides flex and bison

  • Go to thrift\compiler\cpp
  • Use the following steps to build using cmake:
mkdir cmake-vs && cd cmake-vs
cmake -DWITH_SHARED_LIB=off ..
cmake --build .

Using Visual Studio and Win flex-bison

  • Generate a Visual Studio project for version of Visual Studio which you have (cmake --help can show list of supportable VS versions):
  • Run commands in command line:
mkdir cmake-vs
cd cmake-vs
cmake -G "Visual Studio 15 2017" ..
  • Now open the folder cmake-vs using Visual Studio.

Cross compile using mingw32 and generate a Windows Installer with CPack

mkdir cmake-mingw32 && cd cmake-mingw32
cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF ..
cpack

Other cases

Building the Thrift IDL compiler in Windows without CMake

If you don't want to use CMake you can use the already available Visual Studio 2010 solution.

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 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.

Open compiler.sln and remove the Pre-build commands under the project's: Properties -> Build Events -> Pre-Build Events.

From a command prompt:

cd thrift/compiler/cpp
flex -o src\thrift\thriftl.cc src\thrift\thriftl.ll

In the generated thriftl.cc, comment out #include <unistd.h>

Place a copy of bison.simple in thrift/compiler/cpp

bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy
move src\thrift\thrifty.cc.hh  src\thrift\thrifty.hh

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".

move src\thrift\version.h.in src\thrift\version.h

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.

Unit tests for compiler

Using boost test

  • pls check test folder

Using Catch C++ test library

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 netstd implementation)

  • pls check tests folder

Have a Happy free time and holidays