| Pascal Bach | 6eb015a | 2014-04-17 16:19:07 +0200 | [diff] [blame] | 1 | # Build compiler using CMake |
| 2 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 3 | ## build on Unix-like System |
| 4 | |
| 5 | ### build using cmake |
| 6 | |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 7 | Use the following steps to build using cmake: |
| Pascal Bach | 6eb015a | 2014-04-17 16:19:07 +0200 | [diff] [blame] | 8 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 9 | ``` |
| 10 | mkdir cmake-build |
| 11 | cd cmake-build |
| 12 | cmake .. |
| 13 | make |
| 14 | ``` |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 15 | |
| 16 | ### Create an eclipse project |
| 17 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 18 | ``` |
| 19 | mkdir cmake-ec && cd cmake-ec |
| 20 | cmake -G "Eclipse CDT4 - Unix Makefiles" .. |
| 21 | make |
| 22 | ``` |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 23 | |
| Roger Meier | 880a2b3 | 2015-05-16 22:40:17 +0200 | [diff] [blame] | 24 | Now open the folder cmake-ec using eclipse. |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 25 | |
| 26 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 27 | ## Cross compile using mingw32 and generate a Windows Installer with CPack |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 28 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 29 | ``` |
| 30 | mkdir cmake-mingw32 && cd cmake-mingw32 |
| 31 | cmake -DCMAKE_TOOLCHAIN_FILE=../build/cmake/mingw32-toolchain.cmake -DBUILD_COMPILER=ON -DBUILD_LIBRARIES=OFF -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF .. |
| 32 | cpack |
| 33 | ``` |
| Roger Meier | 8720260 | 2014-08-15 22:16:02 +0200 | [diff] [blame] | 34 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 35 | # Build on windows |
| Pascal Bach | 6eb015a | 2014-04-17 16:19:07 +0200 | [diff] [blame] | 36 | |
| Roger Meier | 86fded2 | 2015-05-15 12:01:38 +0200 | [diff] [blame] | 37 | ### using Git Bash |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 38 | |
| Roger Meier | 86fded2 | 2015-05-15 12:01:38 +0200 | [diff] [blame] | 39 | Git Bash provides flex and bison, so you just need to do this: |
| 40 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 41 | ``` |
| 42 | mkdir cmake-vs && cd cmake-vs |
| 43 | cmake -DWITH_SHARED_LIB=off .. |
| 44 | ``` |
| Roger Meier | 86fded2 | 2015-05-15 12:01:38 +0200 | [diff] [blame] | 45 | |
| 46 | ### using Win flex-bison |
| 47 | |
| 48 | In order to build on windows with winflexbison a few additional steps are necessary: |
| Pascal Bach | 6eb015a | 2014-04-17 16:19:07 +0200 | [diff] [blame] | 49 | |
| 50 | 1. Download winflexbison from http://sourceforge.net/projects/winflexbison/ |
| 51 | 2. Extract the winflex bison files to for e.g. C:\winflexbison |
| 52 | 3. Make the CMake variables point to the correct binaries. |
| Jens Geyer | 176c926 | 2015-01-29 00:30:08 +0100 | [diff] [blame] | 53 | * FLEX_EXECUTABLE = C:/winbuild/win_flex.exe |
| 54 | * BISON_EXECUTABLE = C:/winbuild/win_bison.exe |
| Roger Meier | 86fded2 | 2015-05-15 12:01:38 +0200 | [diff] [blame] | 55 | 4. Generate a Visual Studio project: |
| 56 | ``` |
| Roger Meier | 880a2b3 | 2015-05-16 22:40:17 +0200 | [diff] [blame] | 57 | mkdir cmake-vs && cd cmake-vs |
| Roger Meier | 86fded2 | 2015-05-15 12:01:38 +0200 | [diff] [blame] | 58 | cmake -G "Visual Studio 12" -DWITH_SHARED_LIB=off .. |
| 59 | ``` |
| 60 | 5. Now open the folder build_vs using Visual Studio 2013. |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 61 | |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 62 | # Building the Thrift IDL compiler in Windows |
| 63 | |
| henrique | 55087a4 | 2014-06-17 12:36:39 +0200 | [diff] [blame] | 64 | If you don't want to use CMake you can use the already available Visual Studio |
| 65 | 2010 solution. |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 66 | The Visual Studio project contains pre-build commands to generate the |
| 67 | thriftl.cc, thrifty.cc and thrifty.hh files which are necessary to build |
| 68 | the compiler. These depend on bison, flex and their dependencies to |
| Nobuaki Sukegawa | d8c6a84 | 2016-10-02 14:21:55 +0900 | [diff] [blame] | 69 | work properly. |
| 70 | Download flex & bison as described above. |
| 71 | Place these binaries somewhere in the path and |
| 72 | rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively. |
| 73 | |
| 74 | If this doesn't work on a system, try these manual pre-build steps. |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 75 | |
| 76 | Open compiler.sln and remove the Pre-build commands under the project's |
| 77 | Properties -> Build Events -> Pre-Build Events. |
| 78 | |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 79 | From a command prompt: |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 80 | ``` |
| 81 | cd thrift/compiler/cpp |
| 82 | flex -osrc\thrift\thriftl.cc src\thrift\thriftl.ll |
| 83 | ``` |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 84 | In the generated thriftl.cc, comment out #include <unistd.h> |
| 85 | |
| 86 | Place a copy of bison.simple in thrift/compiler/cpp |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 87 | ``` |
| 88 | bison -y -o "src/thrift/thrifty.cc" --defines src/thrift/thrifty.yy |
| 89 | move src\thrift\thrifty.cc.hh src\thrift\thrifty.hh |
| 90 | ``` |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 91 | |
| 92 | 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". |
| 93 | |
| James E. King, III | 330b3f8 | 2017-01-23 08:52:04 -0500 | [diff] [blame] | 94 | ``` |
| 95 | move src\thrift\version.h.in src\thrift\version.h |
| 96 | ``` |
| Roger Meier | 746952e | 2014-06-14 21:59:24 +0200 | [diff] [blame] | 97 | |
| 98 | Download inttypes.h from the interwebs and place it in an include path |
| 99 | location (e.g. thrift/compiler/cpp/src). |
| 100 | |
| 101 | Build the compiler in Visual Studio. |