Skip to content

Commit

Permalink
refactor(s2): Bump s2geometry to 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Nov 24, 2023
1 parent 1409d09 commit d88923d
Show file tree
Hide file tree
Showing 35 changed files with 78 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ header:
- 'thirdparty/fix_libevent_for_macos.patch'
- 'thirdparty/fix_prometheus-cpp_limits.patch'
- 'thirdparty/fix_rocksdb-cmake-PORTABLE-option.patch'
- 'thirdparty/fix_s2_build_with_cxx17.patch'
- 'thirdparty/fix_s2_build_with_absl_and_gtest.patch'
- 'thirdparty/fix_thrift_for_cpp11.patch'
# TODO(yingchun): shell/* files are import from thirdparties, we can move them to thirdparty later.
# Copyright (c) 2016, Adi Shavit
Expand Down
3 changes: 3 additions & 0 deletions cmake_modules/BaseFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ function(dsn_setup_thirdparty_libs)
link_libraries(${OPENSSL_CRYPTO_LIBRARY})
link_libraries(${OPENSSL_SSL_LIBRARY})

# abseil
find_package(absl REQUIRED)

link_directories(${THIRDPARTY_INSTALL_DIR}/lib)
if (NOT APPLE)
link_directories(${THIRDPARTY_INSTALL_DIR}/lib64)
Expand Down
2 changes: 2 additions & 0 deletions src/geo/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS
absl::flat_hash_set
absl::strings
pegasus_geo_lib
s2testing
s2
Expand Down
1 change: 0 additions & 1 deletion src/geo/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <s2/s2latlng.h>
#include <s2/s2latlng_rect.h>
#include <s2/s2testing.h>
#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <atomic>
#include <iostream>
Expand Down
1 change: 0 additions & 1 deletion src/geo/lib/geo_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#pragma once

#include <pegasus/client.h>
#include <s2/third_party/absl/base/port.h>
#include <functional>
#include <list>
#include <memory>
Expand Down
1 change: 0 additions & 1 deletion src/geo/lib/latlng_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <string>
#include <vector>
Expand Down
2 changes: 2 additions & 0 deletions src/geo/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS
absl::flat_hash_set
absl::strings
pegasus_geo_lib
s2testing
s2
Expand Down
1 change: 0 additions & 1 deletion src/geo/test/geo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <s2/s2earth.h>
#include <s2/s2latlng.h>
#include <s2/s2testing.h>
#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <list>
#include <memory>
Expand Down
1 change: 0 additions & 1 deletion src/geo/test/latlng_codec_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <s2/s1angle.h>
#include <s2/s2latlng.h>
#include <s2/third_party/absl/base/port.h>
#include <string>

#include "geo/lib/latlng_codec.h"
Expand Down
2 changes: 2 additions & 0 deletions src/redis_protocol/proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_LIBS pegasus.rproxylib
absl::flat_hash_set
absl::strings
pegasus_geo_lib
pegasus_reporter
event
Expand Down
1 change: 0 additions & 1 deletion src/redis_protocol/proxy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

#include <pegasus/version.h>
#include <s2/third_party/absl/base/port.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
Expand Down
1 change: 0 additions & 1 deletion src/redis_protocol/proxy_lib/redis_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <s2/third_party/absl/base/port.h>
#include <stddef.h>
#include <stdint.h>
#include <atomic>
Expand Down
2 changes: 2 additions & 0 deletions src/redis_protocol/proxy_ut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_PROJ_LIBS pegasus.rproxylib
pegasus_base
absl::flat_hash_set
absl::strings
pegasus_geo_lib
s2
pegasus_client_static
Expand Down
1 change: 0 additions & 1 deletion src/redis_protocol/proxy_ut/redis_proxy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
// IWYU pragma: no_include <boost/asio/socket_base.hpp>
#include <boost/system/error_code.hpp>
#include <gtest/gtest_prod.h>
#include <s2/third_party/absl/base/port.h>
#include <string.h>
#include <chrono>
#include <memory>
Expand Down
4 changes: 2 additions & 2 deletions src/server/hotspot_partition_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void hotspot_partition_calculator::init_perf_counter(int partition_count)
{
for (int data_type = 0; data_type <= 1; data_type++) {
for (int i = 0; i < partition_count; i++) {
string partition_desc =
std::string partition_desc =
_app_name + '.' +
(data_type == partition_qps_type::WRITE_HOTSPOT_DATA ? "write." : "read.") +
std::to_string(i);
Expand All @@ -95,7 +95,7 @@ void hotspot_partition_calculator::init_perf_counter(int partition_count)
"app.pegasus", counter_name.c_str(), COUNTER_TYPE_NUMBER, counter_desc.c_str());
}

string total_desc =
std::string total_desc =
_app_name + '.' +
(data_type == partition_qps_type::WRITE_HOTSPOT_DATA ? "write.total" : "read.total");
std::string counter_name = fmt::format("app.stat.hotspots.{}", total_desc);
Expand Down
1 change: 0 additions & 1 deletion src/server/hotspot_partition_calculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#pragma once

#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <array>
#include <list>
Expand Down
3 changes: 1 addition & 2 deletions src/server/info_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <stdlib.h>
// IWYU pragma: no_include <bits/std_abs.h>
Expand Down Expand Up @@ -233,7 +232,7 @@ class info_collector
::dsn::task_ptr _storage_size_stat_timer_task;
::dsn::utils::ex_lock_nr _capacity_unit_update_info_lock;
// mapping 'node address' --> 'last updated timestamp'
std::map<std::string, string> _capacity_unit_update_info;
std::map<std::string, std::string> _capacity_unit_update_info;
// _hotspot_calculator_store is to save hotspot_partition_calculator for each table, a
// hotspot_partition_calculator saves historical hotspot data and alert perf_counters of
// corresponding table
Expand Down
1 change: 0 additions & 1 deletion src/server/info_collector_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#pragma once

#include <s2/third_party/absl/base/port.h>
#include <string>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion src/server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <pegasus/git_commit.h>
#include <pegasus/version.h>
#include <s2/third_party/absl/base/port.h>
#include <unistd.h>
#include <cstdio>
#include <memory>
Expand Down
2 changes: 2 additions & 0 deletions src/shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ set(MY_PROJ_LIBS
PocoXML
pegasus_geo_lib
RocksDB::rocksdb
absl::flat_hash_set
absl::strings
s2
hdfs
)
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/bulk_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// IWYU pragma: no_include <ext/alloc_traits.h>
#include <fmt/core.h>
#include <getopt.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <algorithm>
#include <cstdint>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/cold_backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <boost/lexical_cast.hpp>
#include <getopt.h>
#include <inttypes.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/data_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <limits.h>
#include <pegasus/error.h>
#include <rocksdb/statistics.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <algorithm>
#include <atomic>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <rocksdb/sst_dump_tool.h>
#include <rocksdb/status.h>
#include <rocksdb/utilities/ldb_cmd.h>
#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <stdio.h>
#include <ctime>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/detect_hotkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// under the License.

#include <fmt/core.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <memory>
#include <set>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/duplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

#include <fmt/core.h>
#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <stdio.h>
#include <iostream>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/global_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <string>

Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/node_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

// IWYU pragma: no_include <bits/getopt_core.h>
#include <getopt.h>
#include <s2/third_party/absl/base/port.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/rebalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

// IWYU pragma: no_include <bits/getopt_core.h>
#include <getopt.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// IWYU pragma: no_include <bits/getopt_core.h>
#include <boost/algorithm/string/trim.hpp>
#include <getopt.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
Expand Down
1 change: 0 additions & 1 deletion src/shell/commands/table_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// IWYU pragma: no_include <bits/std_abs.h>
#include <fmt/core.h>
#include <getopt.h>
#include <s2/third_party/absl/base/port.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
Expand Down
1 change: 0 additions & 1 deletion src/shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <ctype.h>
#include <pegasus/version.h>
#include <s2/third_party/absl/base/port.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion src/test/function_test/base_api/test_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

#include <limits.h>
#include <s2/third_party/absl/base/port.h>
#include <string.h>
#include <time.h>
#include <atomic>
Expand Down
41 changes: 19 additions & 22 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,22 +366,29 @@ ExternalProject_Add(nlohmann_json
DOWNLOAD_NO_PROGRESS true
)

ExternalProject_Add(abseil
URL ${OSS_URL_PREFIX}/abseil-20230802.1.zip
https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip
URL_MD5 5c6193dbc82834f8e762c6a28c9cc615
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DABSL_FIND_GOOGLETEST=OFF
-DCMAKE_CXX_STANDARD=17
DOWNLOAD_EXTRACT_TIMESTAMP true
DOWNLOAD_NO_PROGRESS true
)

ExternalProject_Add(s2geometry
URL ${OSS_URL_PREFIX}/s2geometry-e8d16637a467d9f096a92a6d81a50a9b747ca828.zip
https://github.com/neverchanje/s2geometry/archive/e8d16637a467d9f096a92a6d81a50a9b747ca828.zip
URL_MD5 75cc44c9c31382083d8a2d0e42590788
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_s2_build_with_cxx17.patch
URL ${OSS_URL_PREFIX}/s2geometry-0.10.0.tar.gz
https://github.com/google/s2geometry/archive/refs/tags/v0.10.0.tar.gz
URL_MD5 c68f3c5d326dde9255681b9201393a9f
PATCH_COMMAND patch -p1 < ${TP_DIR}/fix_s2_build_with_absl_and_gtest.patch
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT}
-DGOOGLETEST_VERSION=1.14.0
-DGTEST_ROOT=${googletest_SRC}/googletest
-DBUILD_SHARED_LIBS=OFF
-DBUILD_PYTHON=OFF
-DBUILD_TESTING=OFF
-DGTEST_ROOT=${googletest_SRC}/googletest
-DWITH_PYTHON=OFF
-DBUILD_EXAMPLES=OFF
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_STANDARD=17
DEPENDS googletest
DEPENDS googletest abseil
DOWNLOAD_EXTRACT_TIMESTAMP true
DOWNLOAD_NO_PROGRESS true
)
Expand Down Expand Up @@ -453,13 +460,3 @@ ExternalProject_Add(http-parser
DOWNLOAD_NO_PROGRESS true
)

ExternalProject_Add(abseil
URL ${OSS_URL_PREFIX}/abseil-20230802.1.zip
https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip
URL_MD5 5c6193dbc82834f8e762c6a28c9cc615
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TP_OUTPUT}
-DABSL_FIND_GOOGLETEST=OFF
-DCMAKE_CXX_STANDARD=14
DOWNLOAD_EXTRACT_TIMESTAMP true
DOWNLOAD_NO_PROGRESS true
)
42 changes: 42 additions & 0 deletions thirdparty/fix_s2_build_with_absl_and_gtest.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From 3e3d469e81b5b8934abc4b15cd9e33065b5a489f Mon Sep 17 00:00:00 2001
From: Yingchun Lai <[email protected]>
Date: Tue, 21 Nov 2023 23:43:25 +0800
Subject: [PATCH] Build as thirdparty of Apache Pegasus

---
CMakeLists.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f080b4b..8e3471a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,7 @@ endif()
# undefined symbol errors since ABSL_HAVE_STD_STRING_VIEW etc will
# end up defined differently. There is probably a better way to achieve
# this than assuming what absl used.
-set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# No compiler-specific extensions, i.e. -std=c++11, not -std=gnu++11.
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -40,6 +40,7 @@ add_feature_info(SHARED_LIBS BUILD_SHARED_LIBS
"builds shared libraries instead of static.")

option(BUILD_EXAMPLES "Build s2 documentation examples." ON)
+option(BUILD_TESTS "Build s2 tests." OFF)

option(WITH_PYTHON "Add python interface" OFF)
add_feature_info(PYTHON WITH_PYTHON "provides python interface to S2")
@@ -429,7 +430,7 @@ install(TARGETS ${S2_TARGETS}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

message("GTEST_ROOT: ${GTEST_ROOT}")
-if (GTEST_ROOT)
+if (GTEST_ROOT AND BUILD_TESTS)
add_subdirectory(${GTEST_ROOT} build_gtest)
include_directories(${GTEST_ROOT}/include)

--
2.41.0

0 comments on commit d88923d

Please sign in to comment.