You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by la...@apache.org on 2022/01/27 02:36:18 UTC

[incubator-pegasus] branch master updated: feat(build): support to build on MacOS (#891)

This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new a42ae44  feat(build): support to build on MacOS (#891)
a42ae44 is described below

commit a42ae4444f4606e29dd6737fcc32b89f7c6b12b2
Author: Yingchun Lai <ac...@gmail.com>
AuthorDate: Thu Jan 27 10:34:23 2022 +0800

    feat(build): support to build on MacOS (#891)
---
 rdsn                                       |  2 +-
 src/base/pegasus_key_schema.h              | 13 +++++++------
 src/base/pegasus_value_schema.h            |  2 +-
 src/base/test/CMakeLists.txt               |  2 +-
 src/client_lib/CMakeLists.txt              | 27 +++++++++++++++++----------
 src/geo/bench/CMakeLists.txt               |  2 +-
 src/geo/test/CMakeLists.txt                |  2 +-
 src/redis_protocol/proxy/CMakeLists.txt    |  2 +-
 src/redis_protocol/proxy_ut/CMakeLists.txt |  2 +-
 src/server/available_detector.cpp          |  6 +++---
 src/server/hashkey_transform.h             |  3 ++-
 src/server/pegasus_server_impl.cpp         |  2 +-
 src/shell/commands/data_operations.cpp     | 15 ++++++++-------
 src/shell/commands/debugger.cpp            |  3 ++-
 src/test/bench_test/CMakeLists.txt         |  2 +-
 src/test/bench_test/rand.cpp               |  3 ++-
 src/test/kill_test/CMakeLists.txt          |  2 +-
 src/test/pressure_test/CMakeLists.txt      |  2 +-
 src/test/upgrade_test/CMakeLists.txt       |  2 +-
 19 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/rdsn b/rdsn
index 058f947..daa7585 160000
--- a/rdsn
+++ b/rdsn
@@ -1 +1 @@
-Subproject commit 058f9474d3b16b4d9123d03df6332a8218377d29
+Subproject commit daa7585185529377ca49dc7ed47f31361a830f12
diff --git a/src/base/pegasus_key_schema.h b/src/base/pegasus_key_schema.h
index b894c6d..042da1c 100644
--- a/src/base/pegasus_key_schema.h
+++ b/src/base/pegasus_key_schema.h
@@ -20,10 +20,11 @@
 #pragma once
 
 #include <stdint.h>
-#include <string.h>
+#include <string>
 #include <dsn/utility/ports.h>
 #include <dsn/utility/utils.h>
 #include <dsn/utility/blob.h>
+#include <dsn/utility/endians.h>
 #include <dsn/utility/utils.h>
 #include <dsn/utility/crc.h>
 #include <dsn/c/api_utilities.h>
@@ -46,7 +47,7 @@ void pegasus_generate_key(::dsn::blob &key, const T &hash_key, const T &sort_key
 
     // hash_key_len is in big endian
     uint16_t hash_key_len = hash_key.length();
-    *((int16_t *)buf.get()) = htobe16((int16_t)hash_key_len);
+    *((int16_t *)buf.get()) = ::dsn::endian::hton((uint16_t)hash_key_len);
 
     ::memcpy(buf.get() + 2, hash_key.data(), hash_key_len);
 
@@ -68,7 +69,7 @@ void pegasus_generate_next_blob(::dsn::blob &next, const T &hash_key)
     int hash_key_len = hash_key.length();
     std::shared_ptr<char> buf(::dsn::utils::make_shared_array<char>(hash_key_len + 2));
 
-    *((int16_t *)buf.get()) = htobe16((int16_t)hash_key_len);
+    *((int16_t *)buf.get()) = ::dsn::endian::hton((uint16_t)hash_key_len);
     ::memcpy(buf.get() + 2, hash_key.data(), hash_key_len);
 
     unsigned char *p = (unsigned char *)(buf.get() + hash_key_len + 1);
@@ -104,7 +105,7 @@ pegasus_restore_key(const ::dsn::blob &key, ::dsn::blob &hash_key, ::dsn::blob &
     dassert(key.length() >= 2, "key length must be no less than 2");
 
     // hash_key_len is in big endian
-    uint16_t hash_key_len = be16toh(*(int16_t *)(key.data()));
+    uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data()));
 
     if (hash_key_len > 0) {
         dassert(key.length() >= 2 + hash_key_len,
@@ -129,7 +130,7 @@ pegasus_restore_key(const ::dsn::blob &key, std::string &hash_key, std::string &
     dassert(key.length() >= 2, "key length must be no less than 2");
 
     // hash_key_len is in big endian
-    uint16_t hash_key_len = be16toh(*(int16_t *)(key.data()));
+    uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data()));
 
     if (hash_key_len > 0) {
         dassert(key.length() >= 2 + hash_key_len,
@@ -153,7 +154,7 @@ inline uint64_t pegasus_key_hash(const T &key)
     dassert(key.size() >= 2, "key length must be no less than 2");
 
     // hash_key_len is in big endian
-    uint16_t hash_key_len = be16toh(*(int16_t *)(key.data()));
+    uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data()));
 
     if (hash_key_len > 0) {
         // hash_key_len > 0, compute hash from hash_key
diff --git a/src/base/pegasus_value_schema.h b/src/base/pegasus_value_schema.h
index 0202e6a..cc1d8f6 100644
--- a/src/base/pegasus_value_schema.h
+++ b/src/base/pegasus_value_schema.h
@@ -20,7 +20,7 @@
 #pragma once
 
 #include <stdint.h>
-#include <string.h>
+#include <array>
 #include <string>
 #include <vector>
 
diff --git a/src/base/test/CMakeLists.txt b/src/base/test/CMakeLists.txt
index 651e0c0..8af554b 100644
--- a/src/base/test/CMakeLists.txt
+++ b/src/base/test/CMakeLists.txt
@@ -33,7 +33,7 @@ set(MY_PROJ_LIBS
         pegasus_base
         gtest)
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 set(MY_BINPLACES config.ini run.sh)
 
diff --git a/src/client_lib/CMakeLists.txt b/src/client_lib/CMakeLists.txt
index f2a9986..cbc6e48 100644
--- a/src/client_lib/CMakeLists.txt
+++ b/src/client_lib/CMakeLists.txt
@@ -28,6 +28,10 @@ target_include_directories(pegasus_client_impl_objects PUBLIC $<TARGET_PROPERTY:
 #
 # link the static lib of pegasus_client: combine pegasus_client_impl, pegasus_base, etc into a single static lib
 set(pegasus_client_static_lib ${CMAKE_CURRENT_BINARY_DIR}/libpegasus_client_static.a)
+if (APPLE)
+    add_custom_target(pre_combine_lib
+        COMMAND ar -x ${DSN_ROOT}/lib/libdsn_utils.a)
+endif()
 add_custom_target(combine_lib
     COMMAND ar -x ${DSN_ROOT}/lib/libdsn_runtime.a
     COMMAND ar -x ${DSN_ROOT}/lib/libdsn_client.a
@@ -48,13 +52,16 @@ set_target_properties(pegasus_client_static
     IMPORTED_LOCATION ${pegasus_client_static_lib})
 install(FILES ${pegasus_client_static_lib} DESTINATION "lib")
 
-# link the shared lib of pegasus client
-add_library(pegasus_client_shared SHARED $<TARGET_OBJECTS:pegasus_client_impl_objects>)
-target_link_libraries(pegasus_client_shared PRIVATE
-    pegasus_base
-    dsn_runtime
-    dsn_utils
-    dsn_client
-    dsn_replication_common
-    thrift)
-install(TARGETS pegasus_client_shared DESTINATION "lib")
+if (NOT APPLE)
+    # link the shared lib of pegasus client
+    add_library(pegasus_client_shared SHARED $<TARGET_OBJECTS:pegasus_client_impl_objects>)
+    target_link_libraries(pegasus_client_shared PRIVATE
+        pegasus_base
+        dsn_runtime
+        dsn_utils
+        dsn_client
+        dsn_replication_common
+        thrift)
+    install(TARGETS pegasus_client_shared DESTINATION "lib")
+endif()
+
diff --git a/src/geo/bench/CMakeLists.txt b/src/geo/bench/CMakeLists.txt
index 3b84846..1c4ea97 100644
--- a/src/geo/bench/CMakeLists.txt
+++ b/src/geo/bench/CMakeLists.txt
@@ -36,7 +36,7 @@ set(MY_PROJ_LIBS
         dsn_utils
         )
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 set(MY_BINPLACES "config.ini")
 
diff --git a/src/geo/test/CMakeLists.txt b/src/geo/test/CMakeLists.txt
index 807d730..fbb17cd 100644
--- a/src/geo/test/CMakeLists.txt
+++ b/src/geo/test/CMakeLists.txt
@@ -35,7 +35,7 @@ set(MY_PROJ_LIBS
         dsn_utils
         gtest)
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 add_definitions(-Wno-attributes)
 
diff --git a/src/redis_protocol/proxy/CMakeLists.txt b/src/redis_protocol/proxy/CMakeLists.txt
index 88aaae1..229e140 100644
--- a/src/redis_protocol/proxy/CMakeLists.txt
+++ b/src/redis_protocol/proxy/CMakeLists.txt
@@ -36,7 +36,7 @@ set(MY_PROJ_LIBS pegasus.rproxylib
 
 set(MY_BINPLACES "config.ini")
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 # Avoid megabytes of warnings like:
 # rdsn/thirdparty/output/include/s2/s1angle.h:288:28: error:
diff --git a/src/redis_protocol/proxy_ut/CMakeLists.txt b/src/redis_protocol/proxy_ut/CMakeLists.txt
index 18f9d82..73cf0a7 100644
--- a/src/redis_protocol/proxy_ut/CMakeLists.txt
+++ b/src/redis_protocol/proxy_ut/CMakeLists.txt
@@ -27,7 +27,7 @@ set(MY_PROJ_SRC "")
 # "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 set(MY_PROJ_LIBS pegasus.rproxylib
                 pegasus_base
diff --git a/src/server/available_detector.cpp b/src/server/available_detector.cpp
index c39fadd..75df127 100644
--- a/src/server/available_detector.cpp
+++ b/src/server/available_detector.cpp
@@ -386,7 +386,7 @@ void available_detector::on_day_report()
     ddebug("start to report on new day, last_day = %s", _old_day.c_str());
     int64_t detect_times = _recent_day_detect_times.fetch_and(0);
     int64_t fail_times = _recent_day_fail_times.fetch_and(0);
-    int64_t succ_times = std::max(0L, detect_times - fail_times);
+    int64_t succ_times = std::max<int64_t>(0L, detect_times - fail_times);
     int64_t available = 0;
     std::string hash_key("detect_available_day");
     std::string sort_key(_old_day);
@@ -437,7 +437,7 @@ void available_detector::on_hour_report()
     ddebug("start to report on new hour, last_hour = %s", _old_hour.c_str());
     int64_t detect_times = _recent_hour_detect_times.fetch_and(0);
     int64_t fail_times = _recent_hour_fail_times.fetch_and(0);
-    int64_t succ_times = std::max(0L, detect_times - fail_times);
+    int64_t succ_times = std::max<int64_t>(0L, detect_times - fail_times);
     int64_t available = 0;
     std::string hash_key("detect_available_hour");
     std::string sort_key(_old_hour);
@@ -461,7 +461,7 @@ void available_detector::on_minute_report()
     ddebug("start to report on new minute, last_minute = %s", _old_minute.c_str());
     int64_t detect_times = _recent_minute_detect_times.fetch_and(0);
     int64_t fail_times = _recent_minute_fail_times.fetch_and(0);
-    int64_t succ_times = std::max(0L, detect_times - fail_times);
+    int64_t succ_times = std::max<int64_t>(0L, detect_times - fail_times);
     int64_t available = 0;
     std::string hash_key("detect_available_minute");
     std::string sort_key(_old_minute);
diff --git a/src/server/hashkey_transform.h b/src/server/hashkey_transform.h
index 6b9b74b..e0f64ff 100644
--- a/src/server/hashkey_transform.h
+++ b/src/server/hashkey_transform.h
@@ -24,6 +24,7 @@
 
 #include <dsn/c/api_utilities.h>
 #include <dsn/utility/blob.h>
+#include <dsn/utility/endians.h>
 
 namespace pegasus {
 namespace server {
@@ -46,7 +47,7 @@ public:
         }
 
         // hash_key_len is in big endian
-        uint16_t hash_key_len = be16toh(*(int16_t *)(src.data()));
+        uint16_t hash_key_len = dsn::endian::ntoh(*(uint16_t *)(src.data()));
         dassert(src.size() >= 2 + hash_key_len,
                 "key length must be no less than (2 + hash_key_len)");
         return rocksdb::Slice(src.data(), 2 + hash_key_len);
diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp
index 72a2448..d3d6b58 100644
--- a/src/server/pegasus_server_impl.cpp
+++ b/src/server/pegasus_server_impl.cpp
@@ -2830,7 +2830,7 @@ bool pegasus_server_impl::set_usage_scenario(const std::string &usage_scenario)
             new_options["write_buffer_size"] = std::to_string(buffer_size);
             uint64_t max_size = get_random_nearby(_data_cf_opts.max_bytes_for_level_base);
             new_options["level0_file_num_compaction_trigger"] =
-                std::to_string(std::max(4UL, max_size / buffer_size));
+                std::to_string(std::max<uint64_t>(4UL, max_size / buffer_size));
         }
     } else if (usage_scenario == ROCKSDB_ENV_USAGE_SCENARIO_BULK_LOAD) {
         // refer to Options::PrepareForBulkLoad()
diff --git a/src/shell/commands/data_operations.cpp b/src/shell/commands/data_operations.cpp
index 44eabbb..90d9703 100644
--- a/src/shell/commands/data_operations.cpp
+++ b/src/shell/commands/data_operations.cpp
@@ -18,6 +18,7 @@
  */
 
 #include "shell/commands.h"
+#include <fmt/printf.h>
 #include "idl_utils.h"
 
 static void
@@ -115,7 +116,7 @@ bool set_value(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
     return true;
 }
@@ -149,7 +150,7 @@ bool multi_set_value(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
     return true;
 }
@@ -403,7 +404,7 @@ bool delete_value(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
     return true;
 }
@@ -433,7 +434,7 @@ bool multi_del_value(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
     return true;
 }
@@ -664,7 +665,7 @@ bool incr(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
     return true;
 }
@@ -819,7 +820,7 @@ bool check_and_set(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
     return true;
 }
@@ -983,7 +984,7 @@ bool check_and_mutate(command_executor *e, shell_context *sc, arguments args)
     fprintf(stderr, "\n");
     fprintf(stderr, "app_id          : %d\n", info.app_id);
     fprintf(stderr, "partition_index : %d\n", info.partition_index);
-    fprintf(stderr, "decree          : %ld\n", info.decree);
+    fmt::fprintf(stderr, "decree          : %lld\n", info.decree);
     fprintf(stderr, "server          : %s\n", info.server.c_str());
 
     return true;
diff --git a/src/shell/commands/debugger.cpp b/src/shell/commands/debugger.cpp
index e3d8407..080b957 100644
--- a/src/shell/commands/debugger.cpp
+++ b/src/shell/commands/debugger.cpp
@@ -271,7 +271,8 @@ bool rdb_value_hex2str(command_executor *e, shell_context *sc, arguments args)
     std::string pegasus_value = rocksdb::LDBCommand::HexToString(hex_rdb_value);
     auto expire_ts = static_cast<int64_t>(pegasus::pegasus_extract_expire_ts(0, pegasus_value)) +
                      pegasus::utils::epoch_begin; // TODO(wutao): pass user specified version
-    fmt::print(stderr, "\nWhen to expire:\n  {:%Y-%m-%d %H:%M:%S}\n", *std::localtime(&expire_ts));
+    std::time_t tm(expire_ts);
+    fmt::print(stderr, "\nWhen to expire:\n  {:%Y-%m-%d %H:%M:%S}\n", *std::localtime(&tm));
 
     dsn::blob user_data;
     pegasus::pegasus_extract_user_data(0, std::move(pegasus_value), user_data);
diff --git a/src/test/bench_test/CMakeLists.txt b/src/test/bench_test/CMakeLists.txt
index 307d543..eaf02da 100644
--- a/src/test/bench_test/CMakeLists.txt
+++ b/src/test/bench_test/CMakeLists.txt
@@ -36,7 +36,7 @@ set(MY_PROJ_LIBS
         krb5
         )
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 set(MY_BINPLACES "config.ini")
 
diff --git a/src/test/bench_test/rand.cpp b/src/test/bench_test/rand.cpp
index 9829705..09f82b5 100644
--- a/src/test/bench_test/rand.cpp
+++ b/src/test/bench_test/rand.cpp
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+#include <algorithm>
 #include <random>
 
 namespace pegasus {
@@ -37,7 +38,7 @@ std::string generate_string(uint64_t len)
 
     // fill with random int
     uint64_t random_int = next_u64();
-    key.append(reinterpret_cast<char *>(&random_int), std::min(len, 8UL));
+    key.append(reinterpret_cast<char *>(&random_int), std::min<uint64_t>(len, 8UL));
 
     // append with '0'
     key.resize(len, '0');
diff --git a/src/test/kill_test/CMakeLists.txt b/src/test/kill_test/CMakeLists.txt
index df97448..6e2ab5d 100644
--- a/src/test/kill_test/CMakeLists.txt
+++ b/src/test/kill_test/CMakeLists.txt
@@ -41,7 +41,7 @@ set(MY_PROJ_LIBS
     )
 set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 if (UNIX)
     SET(CMAKE_INSTALL_RPATH ".")
diff --git a/src/test/pressure_test/CMakeLists.txt b/src/test/pressure_test/CMakeLists.txt
index 42e29b7..b26cc10 100644
--- a/src/test/pressure_test/CMakeLists.txt
+++ b/src/test/pressure_test/CMakeLists.txt
@@ -37,7 +37,7 @@ set(MY_PROJ_LIBS
 
 set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-pressure.ini")
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 if (UNIX)
     SET(CMAKE_INSTALL_RPATH ".")
diff --git a/src/test/upgrade_test/CMakeLists.txt b/src/test/upgrade_test/CMakeLists.txt
index c4aed17..ee3a6ef 100644
--- a/src/test/upgrade_test/CMakeLists.txt
+++ b/src/test/upgrade_test/CMakeLists.txt
@@ -40,7 +40,7 @@ set(MY_PROJ_LIBS
     )
 set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")
 
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)
 
 if (UNIX)
     SET(CMAKE_INSTALL_RPATH ".")

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org