Skip to content

Commit

Permalink
modify s2 library dependence (#129)
Browse files Browse the repository at this point in the history
* modify dependent s2geometry library source code from git to zip
  • Loading branch information
acelyc111 committed Jul 13, 2018
1 parent 2ad8cf6 commit 915cba5
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 13 deletions.
3 changes: 3 additions & 0 deletions include/dsn/utility/absl/base/internal/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -211,5 +213,6 @@ InvokeT<F, Args...> Invoke(F &&f, Args &&... args)
}
} // namespace base_internal
} // namespace absl
} // namespace dsn

#endif // ABSL_BASE_INTERNAL_INVOKE_H_
6 changes: 5 additions & 1 deletion include/dsn/utility/absl/utility/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

#include <dsn/utility/absl/base/internal/invoke.h>

// make namespace absl internal of dsn to solve redefine error with absl in s2geometry
namespace dsn {
namespace absl {

// integer_sequence
Expand Down Expand Up @@ -200,5 +202,7 @@ auto apply(Functor &&functor, Tuple &&t) -> decltype(utility_internal::apply_hel
std::tuple_size<typename std::remove_reference<Tuple>::type>::value>{});
}
} // namespace absl
} // namespace dsn

#endif // ABSL_UTILITY_UTILITY_H_

#endif // ABSL_UTILITY_UTILITY_H_
2 changes: 1 addition & 1 deletion include/dsn/utility/apply.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@

namespace dsn {

using ::absl::apply;
using absl::apply;

} // namespace dsn
2 changes: 1 addition & 1 deletion thirdparty/build-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 25 additions & 10 deletions thirdparty/download-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
67 changes: 67 additions & 0 deletions thirdparty/fix_s2_for_pegasus.patch
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 915cba5

Please sign in to comment.