You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2017/01/23 13:54:19 UTC

thrift git commit: THRIFT-4034 compiler build fixes for macos sierra and some cmake cleanup for compiler Compiler Patch: Robert Lu

Repository: thrift
Updated Branches:
  refs/heads/master 4194562c6 -> 330b3f814


THRIFT-4034 compiler build fixes for macos sierra and some cmake cleanup for compiler
Compiler
Patch: Robert Lu <ro...@gmail.com>

This closes #1161


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/330b3f81
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/330b3f81
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/330b3f81

Branch: refs/heads/master
Commit: 330b3f814a33ab8a740fca4da29106bd7e219b1d
Parents: 4194562
Author: James E. King, III <jk...@apache.org>
Authored: Mon Jan 23 08:52:04 2017 -0500
Committer: James E. King, III <jk...@apache.org>
Committed: Mon Jan 23 08:52:04 2017 -0500

----------------------------------------------------------------------
 appveyor.yml                       |  3 --
 compiler/cpp/CMakeLists.txt        | 24 +++++++-------
 compiler/cpp/README.md             | 58 +++++++++++++++++++++------------
 compiler/cpp/src/thrift/thrifty.yy |  3 ++
 4 files changed, 53 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/330b3f81/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
index e7ab87d..82ce366 100755
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -42,9 +42,6 @@ install:
 - cmake -G "Visual Studio 14 2015 Win64" .
 - cmake --build . --config release
 - cd ..
-  # OpenSSL
-- C:\Python35-x64\python %APPVEYOR_BUILD_FOLDER%\build\appveyor\download_openssl.py
-- ps: Start-Process "Win64OpenSSL.exe" -ArgumentList "/silent /verysilent /sp- /suppressmsgboxes" -Wait
   # Libevent
 - appveyor DownloadFile https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
 - 7z x libevent-2.0.22-stable.tar.gz -so | 7z x -si -ttar > nul

http://git-wip-us.apache.org/repos/asf/thrift/blob/330b3f81/compiler/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/compiler/cpp/CMakeLists.txt b/compiler/cpp/CMakeLists.txt
index 059c3bf..9f7585d 100644
--- a/compiler/cpp/CMakeLists.txt
+++ b/compiler/cpp/CMakeLists.txt
@@ -16,6 +16,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+cmake_minimum_required(VERSION 2.8.12)
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/thrift/version.h)
 if(MSVC)
@@ -30,24 +31,21 @@ endif()
 find_package(FLEX REQUIRED)
 find_package(BISON REQUIRED)
 
+# create directory for thrifty and thriftl
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thrift/)
+
 # Create flex and bison files and build the lib parse static library
 BISON_TARGET(thrifty ${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/thrifty.yy ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc)
 FLEX_TARGET(thriftl ${CMAKE_CURRENT_SOURCE_DIR}/src/thrift/thriftl.ll ${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc)
 ADD_FLEX_BISON_DEPENDENCY(thriftl thrifty)
 
-# HACK: Work around the fact that bison crates a .hh file but we need a .h file
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.h
-                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.h
-                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh
-                   )
-
-set(libparse_SOURCES
+set(parse_SOURCES
     ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc
     ${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc
-    ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.h
+    ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh
 )
 
-add_library(libparse STATIC ${libparse_SOURCES})
+add_library(parse STATIC ${parse_SOURCES})
 
 # Create the thrift compiler
 set(compiler_core
@@ -112,6 +110,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} src)
 if(NOT ${WITH_PLUGIN})
     list(APPEND thrift-compiler_SOURCES ${compiler_core})
 endif()
+
 add_executable(thrift-compiler ${thrift-compiler_SOURCES})
 
 if(${WITH_PLUGIN})
@@ -120,7 +119,7 @@ if(${WITH_PLUGIN})
         src/thrift/audit/t_audit.cpp
         src/thrift/generate/t_cpp_generator.cc
     )
-    target_link_libraries(thrift-bootstrap libparse)
+    target_link_libraries(thrift-bootstrap parse)
 
     set(PLUGIN_GEN_SOURCES
         ${CMAKE_CURRENT_BINARY_DIR}/thrift/plugin/plugin_types.h
@@ -153,11 +152,12 @@ if(${WITH_PLUGIN})
     LINK_AGAINST_THRIFT_LIBRARY(thrift-compiler thriftc)
 endif()
 
+set_target_properties(thrift-compiler PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin/)
 set_target_properties(thrift-compiler PROPERTIES OUTPUT_NAME thrift)
 
-target_link_libraries(thrift-compiler libparse)
+target_link_libraries(thrift-compiler parse)
 
-install(TARGETS thrift-compiler DESTINATION "${BIN_INSTALL_DIR}")
+install(TARGETS thrift-compiler DESTINATION bin)
 
 if(${WITH_PLUGIN})
   # Install the headers

http://git-wip-us.apache.org/repos/asf/thrift/blob/330b3f81/compiler/cpp/README.md
----------------------------------------------------------------------
diff --git a/compiler/cpp/README.md b/compiler/cpp/README.md
index 90300ac..77cb234 100644
--- a/compiler/cpp/README.md
+++ b/compiler/cpp/README.md
@@ -1,35 +1,47 @@
 # Build compiler using CMake
 
-Use the following steps to build using cmake:
+## build on Unix-like System
+
+### build using cmake
 
-    mkdir cmake-build
-    cd cmake-build
-    cmake ..
-    make
+Use the following steps to build using cmake:
 
+```
+mkdir cmake-build
+cd cmake-build
+cmake ..
+make
+```
 
 ### Create an eclipse project
 
-    mkdir cmake-ec && cd cmake-ec
-    cmake -G "Eclipse CDT4 - Unix Makefiles" ..
-    make
+```
+mkdir cmake-ec && cd cmake-ec
+cmake -G "Eclipse CDT4 - Unix Makefiles" ..
+make
+```
 
 Now open the folder cmake-ec using eclipse.
 
 
-### Cross compile using mingw32 and generate a Windows Installer with CPack
+## 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 -DBUILD_EXAMPLES=OFF ..
-    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 -DBUILD_EXAMPLES=OFF ..
+cpack
+```
 
-## Build on windows
+# Build on windows
 
 ### using Git Bash
+
 Git Bash provides flex and bison, so you just need to do this:
 
-    mkdir cmake-vs && cd cmake-vs
-    cmake -DWITH_SHARED_LIB=off ..
+```
+mkdir cmake-vs && cd cmake-vs
+cmake -DWITH_SHARED_LIB=off ..
+```
 
 ### using Win flex-bison
 
@@ -65,17 +77,23 @@ 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 -osrc\thrift\thriftl.cc src\thrift\thriftl.ll
+```
+cd thrift/compiler/cpp
+flex -osrc\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 -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
+```
+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).

http://git-wip-us.apache.org/repos/asf/thrift/blob/330b3f81/compiler/cpp/src/thrift/thrifty.yy
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thrift/thrifty.yy b/compiler/cpp/src/thrift/thrifty.yy
index fcbc877..e4cae0c 100644
--- a/compiler/cpp/src/thrift/thrifty.yy
+++ b/compiler/cpp/src/thrift/thrifty.yy
@@ -1,3 +1,6 @@
+%code requires {
+#include "thrift/parse/t_program.h"
+}
 %{
 /*
  * Licensed to the Apache Software Foundation (ASF) under one