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