diff options
author | Nobuaki Sukegawa <nsuke@apache.org> | 2015-11-14 00:23:40 +0900 |
---|---|---|
committer | Nobuaki Sukegawa <nsuke@apache.org> | 2015-11-23 16:59:10 +0900 |
commit | ca93936e781508e9f9c8e58c26a08809b037cc29 (patch) | |
tree | f032a0ea3ccee31eda1f1ab034dc531978098307 | |
parent | 314fea26fe4d85d17d785d97f1e814fb448b82b9 (diff) | |
download | thrift-ca93936e781508e9f9c8e58c26a08809b037cc29.tar.gz |
THRIFT-3424 Add CMake android build option
Client: Build
Patch: Nobuaki Sukegawa
This closes #696
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | build/cmake/DefineOptions.cmake | 36 | ||||
-rw-r--r-- | build/cmake/FindAnt.cmake | 4 | ||||
-rw-r--r-- | build/cmake/FindGradle.cmake | 30 | ||||
-rw-r--r-- | build/cmake/android-toolchain.cmake | 26 | ||||
-rw-r--r-- | lib/c_glib/test/CMakeLists.txt | 8 | ||||
-rwxr-xr-x | lib/cpp/CMakeLists.txt | 17 | ||||
-rw-r--r-- | lib/cpp/test/CMakeLists.txt | 16 | ||||
-rw-r--r-- | lib/java/CMakeLists.txt | 76 | ||||
-rw-r--r-- | lib/java/android/build.gradle | 50 | ||||
-rw-r--r-- | lib/java/android/settings.gradle | 1 | ||||
-rw-r--r-- | lib/java/android/src/main/AndroidManifest.xml | 4 | ||||
-rwxr-xr-x | test/cpp/CMakeLists.txt | 15 | ||||
-rw-r--r-- | test/hs/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tutorial/cpp/CMakeLists.txt | 2 |
15 files changed, 230 insertions, 71 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f3005f56e..37e89766f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,11 @@ if(BUILD_TESTING) else () message(STATUS "Building without tests") endif () + if(BUILD_COMPILER) + if(NOT EXISTS ${THRIFT_COMPILER}) + set(THRIFT_COMPILER $<TARGET_FILE:thrift-compiler>) + endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp) endif() @@ -75,7 +79,7 @@ if(BUILD_CPP) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp) if(BUILD_TUTORIALS) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tutorial/cpp) - endif(BUILD_TUTORIALS) + endif() if(BUILD_TESTING) if(WITH_LIBEVENT AND WITH_ZLIB AND WITH_OPENSSL) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp) diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake index 0aad240ef..8f7659ece 100644 --- a/build/cmake/DefineOptions.cmake +++ b/build/cmake/DefineOptions.cmake @@ -20,11 +20,17 @@ include(CMakeDependentOption) +set(THRIFT_COMPILER "" CACHE FILEPATH "External Thrift compiler to use during build") + # Additional components option(BUILD_COMPILER "Build Thrift compiler" ON) -option(BUILD_TESTING "Build with unit tests" ON) -option(BUILD_EXAMPLES "Build examples" ON) -option(BUILD_TUTORIALS "Build Thrift tutorials" ON) + +if(BUILD_COMPILER OR EXISTS ${THRIFT_COMPILER}) + set(HAVE_COMPILER ON) +endif() +CMAKE_DEPENDENT_OPTION(BUILD_TESTING "Build with unit tests" ON "HAVE_COMPILER" OFF) +CMAKE_DEPENDENT_OPTION(BUILD_EXAMPLES "Build examples" ON "HAVE_COMPILER" OFF) +CMAKE_DEPENDENT_OPTION(BUILD_TUTORIALS "Build Thrift tutorials" ON "HAVE_COMPILER" OFF) option(BUILD_LIBRARIES "Build Thrift libraries" ON) # Libraries to build @@ -74,10 +80,16 @@ CMAKE_DEPENDENT_OPTION(BUILD_C_GLIB "Build C (GLib) library" ON "BUILD_LIBRARIES;WITH_C_GLIB;GLIB_FOUND" OFF) # Java option(WITH_JAVA "Build Java Thrift library" ON) -find_package(Java QUIET) -find_package(Ant QUIET) -CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java library" ON - "BUILD_LIBRARIES;WITH_JAVA;JAVA_FOUND;ANT_FOUND" OFF) +if(ANDROID) + find_package(Gradle QUIET) + CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java library" ON + "BUILD_LIBRARIES;WITH_JAVA;GRADLE_FOUND" OFF) +else() + find_package(Java REQUIRED) + find_package(Ant QUIET) + CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java library" ON + "BUILD_LIBRARIES;WITH_JAVA;JAVA_FOUND;ANT_FOUND" OFF) +endif() # Python option(WITH_PYTHON "Build Python Thrift library" ON) @@ -120,7 +132,9 @@ message(STATUS "Thrift package version: ${PACKAGE_VERSION}") message(STATUS "Build configuration Summary") message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}") message(STATUS " Build with unit tests: ${BUILD_TESTING}") +MESSAGE_DEP(HAVE_COMPILER "Disabled because BUILD_THRIFT=OFF and no valid THRIFT_COMPILER is given") message(STATUS " Build examples: ${BUILD_EXAMPLES}") +MESSAGE_DEP(HAVE_COMPILER "Disabled because BUILD_THRIFT=OFF and no valid THRIFT_COMPILER is given") message(STATUS " Build Thrift libraries: ${BUILD_LIBRARIES}") message(STATUS " Language libraries:") message(STATUS " Build C++ library: ${BUILD_CPP}") @@ -131,8 +145,12 @@ MESSAGE_DEP(WITH_C_GLIB "Disabled by via WITH_C_GLIB=OFF") MESSAGE_DEP(GLIB_FOUND "GLib missing") message(STATUS " Build Java library: ${BUILD_JAVA}") MESSAGE_DEP(WITH_JAVA "Disabled by via WITH_JAVA=OFF") -MESSAGE_DEP(JAVA_FOUND "Java Runtime missing") -MESSAGE_DEP(ANT_FOUND "Ant missing") +if(ANDROID) + MESSAGE_DEP(GRADLE_FOUND "Gradle missing") +else() + MESSAGE_DEP(JAVA_FOUND "Java Runtime missing") + MESSAGE_DEP(ANT_FOUND "Ant missing") +endif() message(STATUS " Build Python library: ${BUILD_PYTHON}") MESSAGE_DEP(WITH_PYTHON "Disabled by via WITH_PYTHON=OFF") MESSAGE_DEP(PYTHONLIBS_FOUND "Python libraries missing") diff --git a/build/cmake/FindAnt.cmake b/build/cmake/FindAnt.cmake index 16b9afda1..8b0371d91 100644 --- a/build/cmake/FindAnt.cmake +++ b/build/cmake/FindAnt.cmake @@ -18,8 +18,8 @@ # -# Ant_FOUND - system has Ant -# Ant_EXECUTBALE - the Ant executable +# ANT_FOUND - system has Ant +# Ant_EXECUTABLE - the Ant executable # # It will search the environment variable ANT_HOME if it is set diff --git a/build/cmake/FindGradle.cmake b/build/cmake/FindGradle.cmake new file mode 100644 index 000000000..8845d697e --- /dev/null +++ b/build/cmake/FindGradle.cmake @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +# GRADLE_FOUND - system has Gradle +# GRADLE_EXECUTABLE - the Gradle executable +# +# It will search the environment variable ANT_HOME if it is set + +include(FindPackageHandleStandardArgs) + +find_program(GRADLE_EXECUTABLE NAMES gradle PATHS $ENV{GRADLE_HOME}/bin NO_CMAKE_FIND_ROOT_PATH) +find_package_handle_standard_args(Gradle DEFAULT_MSG GRADLE_EXECUTABLE) +mark_as_advanced(GRADLE_EXECUTABLE) diff --git a/build/cmake/android-toolchain.cmake b/build/cmake/android-toolchain.cmake new file mode 100644 index 000000000..15f3d002a --- /dev/null +++ b/build/cmake/android-toolchain.cmake @@ -0,0 +1,26 @@ +set(ANDROID_NDK "/opt/android-ndk" CACHE) +set(ANDROID_PLATFORM "android-15" CACHE) +set(ANDROID_ARCH "arch-arm" CACHE) +set(ANDROID_TOOL_ARCH "android-arm" CACHE) +set(ANDROID_CPU "armeabi-v7a" CACHE) +set(ANDROID_GCC_VERSION 4.9 CACHE) +set(HOST_ARCH linux-x86_64 CACHE) + +set(CMAKE_SYSTEM_NAME Android) +set(ANDROID_SYSROOT "${ANDROID_NDK}/platforms/${ANDROID_PLATFORM}/${ANDROID_ARCH}") +set(ANDROID_TRIPLET arm-linux-androideabi) +set(ANDROID_STL "${ANDROID_NDK}/sources/cxx-stl/gnu-libstd++/${ANDROID_GCC_VERSION}") + +set(_COMPILER_ROOT ${ANDROID_NDK}/prebuilt/${ANDROID_TRIPLET}-${ANDROID_GCC_VERSION}/prebuilt/${HOST_ARCH}) +set(CMAKE_C_COMPILER ${_COMPILER_ROOT}/bin/${ANDROID_TRIPLET}-gcc) +set(CMAKE_CXCX_COMPILER ${_COMPILER_ROOT}/bin/${ANDROID_TRIPLET}-g++) + +include_directories( + ${ANDROID_STL}/include + ${ANDROID_STL}/libs/${ANDROID_CPU}/include) + +set(CMAKE_FIND_ROOT_PATH ${ANDROID_SYSROOT}) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/lib/c_glib/test/CMakeLists.txt b/lib/c_glib/test/CMakeLists.txt index 1b32c4686..bd5d1ee48 100644 --- a/lib/c_glib/test/CMakeLists.txt +++ b/lib/c_glib/test/CMakeLists.txt @@ -138,13 +138,13 @@ add_custom_command(OUTPUT gen-c_glib/t_test_service_for_exception_with_a_map.h gen-c_glib/t_test_srv.c gen-c_glib/t_test_srv.h - COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift + COMMAND ${THRIFT_COMPILER} --gen c_glib ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift ) add_custom_command(OUTPUT gen-c_glib/t_test_optional_required_test_types.c gen-c_glib/t_test_optional_required_test_types.h - COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift + COMMAND ${THRIFT_COMPILER} --gen c_glib ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift ) add_custom_command(OUTPUT @@ -154,7 +154,7 @@ add_custom_command(OUTPUT gen-c_glib/t_test_second_service.h gen-c_glib/t_test_thrift_test.h gen-c_glib/t_test_thrift_test_types.h - COMMAND thrift-compiler --gen c_glib ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen c_glib ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) add_custom_command(OUTPUT @@ -164,7 +164,7 @@ add_custom_command(OUTPUT gen-cpp/ThriftTest.h gen-cpp/ThriftTest_constants.h gen-cpp/ThriftTest_types.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) # TODO: Add memory checks using ctest_memcheck or similar diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index a0b97437c..9404112cc 100755 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -46,7 +46,6 @@ set( thriftcpp_SOURCES src/thrift/protocol/TJSONProtocol.cpp src/thrift/protocol/TMultiplexedProtocol.cpp src/thrift/protocol/TProtocol.cpp - src/thrift/protocol/THeaderProtocol.cpp src/thrift/transport/TTransportException.cpp src/thrift/transport/TFDTransport.cpp src/thrift/transport/TSimpleFileTransport.cpp @@ -58,7 +57,6 @@ set( thriftcpp_SOURCES src/thrift/transport/TServerSocket.cpp src/thrift/transport/TTransportUtils.cpp src/thrift/transport/TBufferTransports.cpp - src/thrift/transport/THeaderTransport.cpp src/thrift/server/TConnectedClient.cpp src/thrift/server/TServerFramework.cpp src/thrift/server/TSimpleServer.cpp @@ -119,7 +117,11 @@ if(WITH_BOOSTTHREADS) ) list(APPEND SYSLIBS "${Boost_LIBRARIES}") elseif(UNIX AND NOT WITH_STDTHREADS) - list(APPEND SYSLIBS pthread) + if(ANDROID) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + else() + list(APPEND SYSLIBS pthread) + endif() set( thriftcpp_threads_SOURCES src/thrift/concurrency/PosixThreadFactory.cpp src/thrift/concurrency/Mutex.cpp @@ -127,8 +129,11 @@ elseif(UNIX AND NOT WITH_STDTHREADS) ) else() if(UNIX) - # need pthread for multi-thread support - list(APPEND SYSLIBS pthread) + if(ANDROID) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") + else() + list(APPEND SYSLIBS pthread) + endif() endif() set( thriftcpp_threads_SOURCES src/thrift/concurrency/StdThreadFactory.cpp @@ -150,6 +155,8 @@ set( thriftcppz_SOURCES src/thrift/transport/TZlibTransport.cpp src/thrift/protocol/THeaderProtocol.cpp src/thrift/transport/THeaderTransport.cpp + src/thrift/protocol/THeaderProtocol.cpp + src/thrift/transport/THeaderTransport.cpp ) # Thrift Qt4 server diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index 033b4d24f..02932cbf8 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -347,33 +347,33 @@ endif() add_custom_command(OUTPUT gen-cpp/DebugProtoTest_types.cpp gen-cpp/DebugProtoTest_types.h gen-cpp/EmptyService.cpp gen-cpp/EmptyService.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift ) add_custom_command(OUTPUT gen-cpp/EnumTest_types.cpp gen-cpp/EnumTest_types.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/EnumTest.thrift ) add_custom_command(OUTPUT gen-cpp/TypedefTest_types.cpp gen-cpp/TypedefTest_types.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/TypedefTest.thrift ) add_custom_command(OUTPUT gen-cpp/OptionalRequiredTest_types.cpp gen-cpp/OptionalRequiredTest_types.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/OptionalRequiredTest.thrift ) add_custom_command(OUTPUT gen-cpp/Recursive_types.cpp gen-cpp/Recursive_types.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/Recursive.thrift ) add_custom_command(OUTPUT gen-cpp/Service.cpp gen-cpp/StressTest_types.cpp - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift ) add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/ThriftTest_constants.cpp gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_types.h - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) add_custom_command(OUTPUT gen-cpp/ChildService.cpp gen-cpp/ChildService.h gen-cpp/ParentService.cpp gen-cpp/ParentService.h gen-cpp/proc_types.cpp gen-cpp/proc_types.h - COMMAND thrift-compiler --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style ${CMAKE_CURRENT_SOURCE_DIR}/processor/proc.thrift ) diff --git a/lib/java/CMakeLists.txt b/lib/java/CMakeLists.txt index ba11f3454..2014f5ccb 100644 --- a/lib/java/CMakeLists.txt +++ b/lib/java/CMakeLists.txt @@ -17,32 +17,50 @@ # under the License. # -if(IS_ABSOLUTE "${LIB_INSTALL_DIR}") - set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java") -else() - set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java") -endif() - -if(IS_ABSOLUTE "${DOC_INSTALL_DIR}") - set(JAVA_DOC_INSTALL_DIR "${DOC_INSTALL_DIR}/java") -else() - set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java") -endif() - -add_custom_target(ant_build ALL - COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} -f build.xml - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Building Java library using Ant" -) - -# Hook the ant install task into CMake install -install(CODE "execute_process( - COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} install - -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} - -Dinstall.path=${JAVA_INSTALL_DIR} -Dinstall.javadoc.path=${JAVA_DOC_INSTALL_DIR} -f build.xml - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -)") - -if(BUILD_TESTING) - #add_subdirectory(test) -endif() +file(GLOB java_sources src/**/*.java) + +if(ANDROID) + set(android_sources + android/build.gradle + android/settings.gradle + android/src/main/AndroidManifest.xml + ) + set(THRIFT_AAR outputs/aar/thrift-debug.aar outputs/aar/thrift-release.aar) + add_custom_command( + OUTPUT ${THRIFT_AAR} + COMMAND ${GRADLE_EXECUTABLE} -p${CMAKE_CURRENT_SOURCE_DIR}/android -PbuildDir=${CMAKE_CURRENT_BINARY_DIR} assemble + DEPENDS ${java_sources} ${android_sources}) + add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR}) + +else(ANDROID) + + if(IS_ABSOLUTE "${LIB_INSTALL_DIR}") + set(JAVA_INSTALL_DIR "${LIB_INSTALL_DIR}/java") + else() + set(JAVA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/java") + endif() + + if(IS_ABSOLUTE "${DOC_INSTALL_DIR}") + set(JAVA_DOC_INSTALL_DIR "${DOC_INSTALL_DIR}/java") + else() + set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java") + endif() + + add_custom_target(ant_build ALL + COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} -f build.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Building Java library using Ant" + ) + + # Hook the ant install task into CMake install + install(CODE "execute_process( + COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} install + -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} + -Dinstall.path=${JAVA_INSTALL_DIR} -Dinstall.javadoc.path=${JAVA_DOC_INSTALL_DIR} -f build.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + )") + + if(BUILD_TESTING) + #add_subdirectory(test) + endif() +endif(ANDROID) diff --git a/lib/java/android/build.gradle b/lib/java/android/build.gradle new file mode 100644 index 000000000..4aa2864ee --- /dev/null +++ b/lib/java/android/build.gradle @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + useLibrary 'org.apache.http.legacy' + sourceSets.main.java { + srcDir '../src' + exclude 'org/apache/thrift/transport/TSaslClientTransport.java' + exclude 'org/apache/thrift/transport/TSaslServerTransport.java' + exclude 'org/apache/thrift/transport/TSaslTransport.java' + } +} + +repositories { + mavenCentral() +} +dependencies { + compile 'org.slf4j:slf4j-api:1.7.13' + compile 'javax.servlet:servlet-api:2.5' + compile 'org.apache.httpcomponents:httpcore:4.4.4' +} + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.5.0' + } +} diff --git a/lib/java/android/settings.gradle b/lib/java/android/settings.gradle new file mode 100644 index 000000000..75e97be41 --- /dev/null +++ b/lib/java/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name='thrift' diff --git a/lib/java/android/src/main/AndroidManifest.xml b/lib/java/android/src/main/AndroidManifest.xml new file mode 100644 index 000000000..43abdb758 --- /dev/null +++ b/lib/java/android/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest package="org.apache.thrift"> + <application /> +</manifest> diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt index 67d9510cf..11db68ee8 100755 --- a/test/cpp/CMakeLists.txt +++ b/test/cpp/CMakeLists.txt @@ -54,24 +54,25 @@ add_library(crossstressgencpp STATIC ${crossstressgencpp_SOURCES}) LINK_AGAINST_THRIFT_LIBRARY(crossstressgencpp thrift) add_executable(TestServer src/TestServer.cpp) -target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB} ${ZLIB_LIBRARIES}) +target_link_libraries(TestServer crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) LINK_AGAINST_THRIFT_LIBRARY(TestServer thrift) LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb) -LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftnb) +LINK_AGAINST_THRIFT_LIBRARY(TestServer thriftz) add_executable(TestClient src/TestClient.cpp) -target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB} ${ZLIB_LIBRARIES}) +target_link_libraries(TestClient crosstestgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) LINK_AGAINST_THRIFT_LIBRARY(TestClient thrift) LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftnb) +LINK_AGAINST_THRIFT_LIBRARY(TestClient thriftz) add_executable(StressTest src/StressTest.cpp) -target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB} ${ZLIB_LIBRARIES}) +target_link_libraries(StressTest crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) LINK_AGAINST_THRIFT_LIBRARY(StressTest thrift) LINK_AGAINST_THRIFT_LIBRARY(StressTest thriftnb) add_test(NAME StressTest COMMAND StressTest) add_executable(StressTestNonBlocking src/StressTestNonBlocking.cpp) -target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB} ${ZLIB_LIBRARIES}) +target_link_libraries(StressTestNonBlocking crossstressgencpp ${Boost_LIBRARIES} ${LIBEVENT_LIB}) LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thrift) LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftnb) LINK_AGAINST_THRIFT_LIBRARY(StressTestNonBlocking thriftz) @@ -82,9 +83,9 @@ add_test(NAME StressTestNonBlocking COMMAND StressTestNonBlocking) # add_custom_command(OUTPUT gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp - COMMAND thrift-compiler --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift ) add_custom_command(OUTPUT gen-cpp/StressTest_types.cpp gen-cpp/StressTest_constants.cpp gen-cpp/Service.cpp - COMMAND thrift-compiler --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp ${PROJECT_SOURCE_DIR}/test/StressTest.thrift ) diff --git a/test/hs/CMakeLists.txt b/test/hs/CMakeLists.txt index d353950cb..a65339da9 100644 --- a/test/hs/CMakeLists.txt +++ b/test/hs/CMakeLists.txt @@ -99,9 +99,9 @@ set(hs_test_gen_sources ${PROJECT_SOURCE_DIR}/test/Include.thrift ) add_custom_command(OUTPUT ${hs_test_gen} - COMMAND thrift-compiler --gen hs ${PROJECT_SOURCE_DIR}/test/ConstantsDemo.thrift - COMMAND thrift-compiler --gen hs ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift - COMMAND thrift-compiler --gen hs ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift - COMMAND thrift-compiler --gen hs ${PROJECT_SOURCE_DIR}/test/Include.thrift - DEPENDS thrift-compiler ${hs_test_gen_sources} + COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/ConstantsDemo.thrift + COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/DebugProtoTest.thrift + COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift + COMMAND ${THRIFT_COMPILER} --gen hs ${PROJECT_SOURCE_DIR}/test/Include.thrift + DEPENDS ${hs_test_gen_sources} ) diff --git a/tutorial/cpp/CMakeLists.txt b/tutorial/cpp/CMakeLists.txt index 42d92ff07..8a3d08551 100644 --- a/tutorial/cpp/CMakeLists.txt +++ b/tutorial/cpp/CMakeLists.txt @@ -39,7 +39,7 @@ add_library(tutorialgencpp STATIC ${tutorialgencpp_SOURCES}) LINK_AGAINST_THRIFT_LIBRARY(tutorialgencpp thrift) add_custom_command(OUTPUT gen-cpp/Calculator.cpp gen-cpp/SharedService.cpp gen-cpp/shared_constants.cpp gen-cpp/shared_types.cpp gen-cpp/tutorial_constants.cpp gen-cpp/tutorial_types.cpp - COMMAND thrift-compiler --gen cpp -r ${PROJECT_SOURCE_DIR}/tutorial/tutorial.thrift + COMMAND ${THRIFT_COMPILER} --gen cpp -r ${PROJECT_SOURCE_DIR}/tutorial/tutorial.thrift ) add_executable(TutorialServer CppServer.cpp) |