From 915cba584db8c83c891ab97fe3be71a3540bfec7 Mon Sep 17 00:00:00 2001 From: Lai Yingchun <405403881@qq.com> Date: Fri, 13 Jul 2018 14:12:33 +0800 Subject: [PATCH] modify s2 library dependence (#129) * modify dependent s2geometry library source code from git to zip --- .../dsn/utility/absl/base/internal/invoke.h | 3 + include/dsn/utility/absl/utility/utility.h | 6 +- include/dsn/utility/apply.h | 2 +- thirdparty/build-thirdparty.sh | 2 +- thirdparty/download-thirdparty.sh | 35 +++++++--- thirdparty/fix_s2_for_pegasus.patch | 67 +++++++++++++++++++ 6 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 thirdparty/fix_s2_for_pegasus.patch diff --git a/include/dsn/utility/absl/base/internal/invoke.h b/include/dsn/utility/absl/base/internal/invoke.h index e483946809..b05724ac58 100644 --- a/include/dsn/utility/absl/base/internal/invoke.h +++ b/include/dsn/utility/absl/base/internal/invoke.h @@ -42,6 +42,8 @@ // The following code is internal implementation detail. See the comment at the // top of this file for the API documentation. +// make namespace absl internal of dsn to solve redefine error with absl in s2geometry +namespace dsn { namespace absl { namespace base_internal { @@ -211,5 +213,6 @@ InvokeT Invoke(F &&f, Args &&... args) } } // namespace base_internal } // namespace absl +} // namespace dsn #endif // ABSL_BASE_INTERNAL_INVOKE_H_ diff --git a/include/dsn/utility/absl/utility/utility.h b/include/dsn/utility/absl/utility/utility.h index 9bcca590ef..f3c515799a 100644 --- a/include/dsn/utility/absl/utility/utility.h +++ b/include/dsn/utility/absl/utility/utility.h @@ -46,6 +46,8 @@ #include +// make namespace absl internal of dsn to solve redefine error with absl in s2geometry +namespace dsn { namespace absl { // integer_sequence @@ -200,5 +202,7 @@ auto apply(Functor &&functor, Tuple &&t) -> decltype(utility_internal::apply_hel std::tuple_size::type>::value>{}); } } // namespace absl +} // namespace dsn + +#endif // ABSL_UTILITY_UTILITY_H_ -#endif // ABSL_UTILITY_UTILITY_H_ \ No newline at end of file diff --git a/include/dsn/utility/apply.h b/include/dsn/utility/apply.h index b349166791..41b6f64e7c 100644 --- a/include/dsn/utility/apply.h +++ b/include/dsn/utility/apply.h @@ -30,6 +30,6 @@ namespace dsn { -using ::absl::apply; +using absl::apply; } // namespace dsn diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh index b367f55005..2d705a4f05 100755 --- a/thirdparty/build-thirdparty.sh +++ b/thirdparty/build-thirdparty.sh @@ -265,7 +265,7 @@ fi # build s2geometry if [ ! -d $TP_OUTPUT/include/s2 ]; then - cd $TP_SRC/s2geometry + cd $TP_SRC/s2geometry-master mkdir -p build && cd build cmake .. -DGTEST_INCLUDE=$TP_OUTPUT/include -DCMAKE_INSTALL_PREFIX=$TP_OUTPUT make -j8 && make install diff --git a/thirdparty/download-thirdparty.sh b/thirdparty/download-thirdparty.sh index fc5461719e..77f6e06571 100755 --- a/thirdparty/download-thirdparty.sh +++ b/thirdparty/download-thirdparty.sh @@ -57,7 +57,14 @@ function check_and_download() function extract_package() { package_name=$1 - tar xf $package_name + is_tar_gz=$(echo $package_name | grep ".tar.gz") + if [[ $is_tar_gz != "" ]]; then + tar xf $package_name + fi + is_zip=$(echo $package_name | grep ".zip") + if [[ $is_zip != "" ]]; then + unzip -oq $package_name + fi local ret_code=$? if [ $ret_code -ne 0 ]; then rm -f $package_name @@ -135,14 +142,14 @@ check_and_download "thrift-0.9.3.tar.gz"\ "thrift-0.9.3" ret_code=$? if [ $ret_code -eq 2 ]; then - exit -1 + exit 2 elif [ $ret_code -eq 0 ]; then echo "make patch to thrift" cd thrift-0.9.3 patch -p1 < ../../fix_thrift_for_cpp11.patch if [ $? != 0 ]; then echo "ERROR: patch fix_thrift_for_cpp11.patch for thrift failed" - exit -1 + exit 2 fi cd .. fi @@ -173,7 +180,7 @@ if [ ! -d $TP_SRC/fds ]; then git clone https://github.com/XiaoMi/galaxy-fds-sdk-cpp.git if [ $? != 0 ]; then echo "ERROR: download fds wrong" - exit -1 + exit 2 fi echo "mv galaxy-fds-sdk-cpp fds" mv galaxy-fds-sdk-cpp fds @@ -189,14 +196,22 @@ check_and_download "fmt-4.0.0.tar.gz"\ exit_if_fail $? # s2geometry -if [ ! -d $TP_SRC/s2geometry ]; then - git clone -b pegasus https://github.com/acelyc111/s2geometry.git +check_and_download "s2geometry-master.zip"\ + "https://github.com/google/s2geometry/archive/master.zip"\ + "afda53fb79131248d414e10f5246f4ed"\ + "s2geometry-master" +ret_code=$? +if [ $ret_code -eq 2 ]; then + exit 2 +elif [ $ret_code -eq 0 ]; then + echo "make patch to s2geometry" + cd s2geometry-master + patch -p1 < ../../fix_s2_for_pegasus.patch if [ $? != 0 ]; then - echo "ERROR: download s2geometry wrong" - exit -1 + echo "ERROR: patch fix_s2_for_pegasus.patch for s2geometry failed" + exit 2 fi -else - echo "s2geometry has already downloaded, skip it" + cd .. fi cd $TP_DIR diff --git a/thirdparty/fix_s2_for_pegasus.patch b/thirdparty/fix_s2_for_pegasus.patch new file mode 100644 index 0000000000..afea915e82 --- /dev/null +++ b/thirdparty/fix_s2_for_pegasus.patch @@ -0,0 +1,67 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c6b40ee..cd20718 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.1) ++cmake_minimum_required(VERSION 2.8.12) + project(s2-geometry) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + include(CMakeDependentOption) +@@ -17,11 +17,12 @@ cmake_dependent_option(WITH_GLOG "Use glog for logging." ON + "WITH_GFLAGS" OFF) + add_feature_info(GLOG WITH_GLOG "provides logging configurability.") + +-option(BUILD_SHARED_LIBS "Build shared libraries instead of static." ON) ++option(BUILD_SHARED_LIBS "Build shared libraries instead of static." OFF) + add_feature_info(SHARED_LIBS BUILD_SHARED_LIBS + "builds shared libraries instead of static.") + +-option(BUILD_EXAMPLES "Build s2 documentation examples." ON) ++option(BUILD_EXAMPLES "Build s2 documentation examples." OFF) ++option(BUILD_PYTHON "Build python interfaces." OFF) + + feature_summary(WHAT ALL) + +@@ -58,7 +59,12 @@ if (APPLE) + set(CMAKE_MACOSX_RPATH TRUE) + endif() + +-set(CMAKE_CXX_STANDARD 11) ++if (CMAKE_VERSION VERSION_LESS "3.1") ++ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") ++else() ++ set (CMAKE_CXX_STANDARD 11) ++endif() ++ + set(CMAKE_CXX_STANDARD_REQUIRED ON) + # No compiler-specific extensions, i.e. -std=c++11, not -std=gnu++11. + set(CMAKE_CXX_EXTENSIONS OFF) +@@ -85,6 +91,11 @@ endif() + include_directories( + ${GFLAGS_INCLUDE_DIRS} ${GLOG_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS}) ++message("GTEST_INCLUDE: ${GTEST_INCLUDE}") ++if (GTEST_INCLUDE) ++ include_directories(${GTEST_INCLUDE}) ++endif() ++ + include_directories(src) + + add_library(s2 +@@ -404,6 +415,7 @@ install(FILES src/s2/util/units/length-units.h + src/s2/util/units/physical-units.h + DESTINATION include/s2/util/units) + install(TARGETS s2 DESTINATION lib) ++install(TARGETS s2testing DESTINATION lib) + + message("GTEST_ROOT: ${GTEST_ROOT}") + if (GTEST_ROOT) +@@ -526,6 +538,6 @@ if (BUILD_EXAMPLES) + add_subdirectory("doc/examples" examples) + endif() + +-if (${SWIG_FOUND} AND ${PYTHONLIBS_FOUND}) ++if (BUILD_PYTHON AND ${SWIG_FOUND} AND ${PYTHONLIBS_FOUND}) + add_subdirectory("src/python" python) + endif()