Skip to content

Commit

Permalink
CXXCBC-638: switch SDK to use bundled fmtlib for spdlog (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej authored Jan 13, 2025
1 parent 2fe9d00 commit 3510b3a
Show file tree
Hide file tree
Showing 176 changed files with 272 additions and 308 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:

jobs:
clang_format:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -22,14 +22,14 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y wget gnupg2 git
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo bash -c "echo 'deb https://apt.llvm.org/focal/ llvm-toolchain-focal-18 main' >> /etc/apt/sources.list"
sudo bash -c "echo 'deb https://apt.llvm.org/noble/ llvm-toolchain-noble-19 main' >> /etc/apt/sources.list"
sudo apt-get update -y
sudo apt-get install -y clang-format-18
sudo apt-get install -y clang-format-19
- name: Run clang-format
run: ./bin/check-clang-format
env:
CB_GIT_CLANG_FORMAT: /usr/bin/git-clang-format-18
CB_CLANG_FORMAT: /usr/bin/clang-format-18
CB_GIT_CLANG_FORMAT: /usr/bin/git-clang-format-19
CB_CLANG_FORMAT: /usr/bin/clang-format-19

clang_static_analyzer:
runs-on: ubuntu-20.04
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ foreach(TARGET ${couchbase_cxx_client_LIBRARIES})
${TARGET}
PRIVATE project_options
project_warnings
fmt::fmt
spdlog::spdlog
Microsoft.GSL::GSL
asio
Expand Down
1 change: 1 addition & 0 deletions bin/check-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ IFS=$'\n\t'

cd "${PROJECT_ROOT}"

${CB_CLANG_FORMAT} --version
format_diff="$(${CB_GIT_CLANG_FORMAT} --binary ${CB_CLANG_FORMAT} --diff --commit HEAD^)"

if [ "$format_diff" == "clang-format did not modify any files" ] || \
Expand Down
2 changes: 1 addition & 1 deletion cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(CPM_DOWNLOAD_VERSION 0.38.6)
set(CPM_DOWNLOAD_VERSION 0.40.5)

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
Expand Down
4 changes: 0 additions & 4 deletions cmake/Testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ macro(integration_test name)
Microsoft.GSL::GSL
asio
taocpp::json
fmt::fmt
spdlog::spdlog
test_utils)
if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL)
Expand Down Expand Up @@ -101,7 +100,6 @@ macro(transaction_test name)
asio
taocpp::json
spdlog::spdlog
fmt::fmt
${couchbase_cxx_client_DEFAULT_LIBRARY}
test_utils)
if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL)
Expand Down Expand Up @@ -146,7 +144,6 @@ macro(unit_test name)
asio
taocpp::json
spdlog::spdlog
fmt::fmt
${couchbase_cxx_client_DEFAULT_LIBRARY}
test_utils)
if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL)
Expand Down Expand Up @@ -193,7 +190,6 @@ macro(integration_benchmark name)
asio
taocpp::json
spdlog::spdlog
fmt::fmt
${couchbase_cxx_client_DEFAULT_LIBRARY}
test_utils)
if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL)
Expand Down
31 changes: 6 additions & 25 deletions cmake/ThirdPartyDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

include(cmake/CPM.cmake)

set(CPM_USE_LOCAL_PACKAGES OFF)

# https://cmake.org/cmake/help/v3.28/policy/CMP0063.html
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)

Expand All @@ -15,29 +17,6 @@ function(declare_system_library target)
$<TARGET_PROPERTY:${target},INTERFACE_INCLUDE_DIRECTORIES>)
endfunction()

if(NOT TARGET fmt::fmt)
# https://github.com/fmtlib/fmt/releases
cpmaddpackage(
NAME
fmt
GIT_TAG
11.0.1
VERSION
11.0.1
GITHUB_REPOSITORY
"fmtlib/fmt"
EXCLUDE_FROM_ALL ON
OPTIONS
"FMT_INSTALL OFF"
# Unicode support for MSVC enabled in CompilerWarnings.cmake
"FMT_UNICODE OFF"
"FMT_DOC OFF"
"BUILD_SHARED_LIBS OFF"
"CMAKE_C_VISIBILITY_PRESET hidden"
"CMAKE_CXX_VISIBILITY_PRESET hidden"
"CMAKE_POSITION_INDEPENDENT_CODE ON")
endif()

if(NOT TARGET spdlog::spdlog)
# https://github.com/gabime/spdlog/releases
cpmaddpackage(
Expand All @@ -54,8 +33,11 @@ if(NOT TARGET spdlog::spdlog)
"CMAKE_C_VISIBILITY_PRESET hidden"
"CMAKE_CXX_VISIBILITY_PRESET hidden"
"CMAKE_POSITION_INDEPENDENT_CODE ON"
"NO_CMAKE_SYSTEM_PATH ON"
"NO_CMAKE_INSTALL_PREFIX ON"
"NO_CMAKE_SYSTEM_PACKAGE_REGISTRY ON"
"SPDLOG_BUILD_SHARED OFF"
"SPDLOG_FMT_EXTERNAL ON")
"SPDLOG_FMT_EXTERNAL OFF")
endif()

if(NOT TARGET Microsoft.GSL::GSL)
Expand Down Expand Up @@ -246,6 +228,5 @@ declare_system_library(llhttp::llhttp)
declare_system_library(hdr_histogram_static)
declare_system_library(Microsoft.GSL::GSL)
declare_system_library(spdlog::spdlog)
declare_system_library(fmt::fmt)
declare_system_library(asio)
declare_system_library(taocpp::json)
2 changes: 1 addition & 1 deletion core/agent_config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "agent_config.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>

#include <string>

Expand Down
2 changes: 1 addition & 1 deletion core/agent_group_config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "agent_group_config.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>

#include <string>

Expand Down
18 changes: 9 additions & 9 deletions core/bucket.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
#include <asio/io_context.hpp>
#include <asio/post.hpp>
#include <asio/ssl/context.hpp>
#include <fmt/format.h>
#include <gsl/span>
#include <spdlog/fmt/bundled/core.h>

#include <algorithm>
#include <chrono>
Expand Down Expand Up @@ -225,8 +225,8 @@ class bucket_impl
return {};
}

auto direct_re_queue(const std::shared_ptr<mcbp::queue_request>& req,
bool is_retry) -> std::error_code
auto direct_re_queue(const std::shared_ptr<mcbp::queue_request>& req, bool is_retry)
-> std::error_code
{
auto handle_error = [is_retry, req](std::error_code ec) {
// We only want to log an error on retries if the error isn't cancelled.
Expand Down Expand Up @@ -281,8 +281,8 @@ class bucket_impl
return {};
}

auto backoff_and_retry(const std::shared_ptr<mcbp::queue_request>& request,
retry_reason reason) -> bool
auto backoff_and_retry(const std::shared_ptr<mcbp::queue_request>& request, retry_reason reason)
-> bool
{
auto action = retry_orchestrator::should_retry(request, reason);
auto retried = action.need_to_retry();
Expand Down Expand Up @@ -314,8 +314,8 @@ class bucket_impl
return {};
}

[[nodiscard]] auto server_by_vbucket(std::uint16_t vbucket,
std::size_t node_index) -> std::optional<std::size_t>
[[nodiscard]] auto server_by_vbucket(std::uint16_t vbucket, std::size_t node_index)
-> std::optional<std::size_t>
{
const std::scoped_lock lock(config_mutex_);
if (config_) {
Expand Down Expand Up @@ -1141,8 +1141,8 @@ bucket::direct_dispatch(std::shared_ptr<mcbp::queue_request> req) -> std::error_
}

auto
bucket::direct_re_queue(const std::shared_ptr<mcbp::queue_request>& req,
bool is_retry) -> std::error_code
bucket::direct_re_queue(const std::shared_ptr<mcbp::queue_request>& req, bool is_retry)
-> std::error_code
{
return impl_->direct_re_queue(req, is_retry);
}
Expand Down
2 changes: 0 additions & 2 deletions core/cluster.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,10 @@
#include <asio/executor_work_guard.hpp>
#include <asio/post.hpp>
#include <asio/ssl/verify_mode.hpp>
#include <fmt/core.h>

#include <atomic>
#include <chrono>
#include <cstring>
#include <fmt/format.h>
#include <map>
#include <memory>
#include <mutex>
Expand Down
2 changes: 1 addition & 1 deletion core/cluster_agent_config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "cluster_agent_config.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>

#include <string>

Expand Down
2 changes: 1 addition & 1 deletion core/collections_component.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <asio/error.hpp>
#include <asio/io_context.hpp>
#include <asio/steady_timer.hpp>
#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>
#include <tao/json/value.hpp>
#include <tao/pegtl/parse_error.hpp>
#include <tl/expected.hpp>
Expand Down
4 changes: 2 additions & 2 deletions core/columnar/agent_config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include "agent_config.hxx"

#include <fmt/chrono.h>
#include <fmt/core.h>
#include <spdlog/fmt/bundled/chrono.h>
#include <spdlog/fmt/bundled/core.h>

#include <string>

Expand Down
1 change: 0 additions & 1 deletion core/columnar/error.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#pragma once

#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <system_error>
Expand Down
4 changes: 2 additions & 2 deletions core/columnar/query_component.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@

#include <asio/io_context.hpp>
#include <asio/steady_timer.hpp>
#include <fmt/chrono.h>
#include <fmt/format.h>
#include <gsl/util>
#include <spdlog/fmt/bundled/chrono.h>
#include <spdlog/fmt/bundled/core.h>
#include <tao/json/value.hpp>
#include <tl/expected.hpp>

Expand Down
2 changes: 1 addition & 1 deletion core/config_profiles.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "cluster_options.hxx"
#include "core/config_profile.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>

#include <chrono>
#include <mutex>
Expand Down
2 changes: 1 addition & 1 deletion core/core_sdk_shim.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "core_sdk_shim.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>

#include <string>

Expand Down
2 changes: 1 addition & 1 deletion core/crud_component.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
#include <asio/error.hpp>
#include <asio/io_context.hpp>
#include <asio/steady_timer.hpp>
#include <fmt/format.h>
#include <gsl/span>
#include <gsl/span_ext>
#include <gsl/util>
#include <snappy.h>
#include <spdlog/fmt/bundled/core.h>
#include <tao/json/value.hpp>
#include <tl/expected.hpp>

Expand Down
2 changes: 1 addition & 1 deletion core/design_document_namespace_fmt.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "design_document_namespace.hxx"

#include <fmt/core.h>
#include <spdlog/fmt/bundled/core.h>

template<>
struct fmt::formatter<couchbase::core::design_document_namespace> {
Expand Down
2 changes: 1 addition & 1 deletion core/diagnostics_fmt.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "diagnostics.hxx"

#include <fmt/core.h>
#include <spdlog/fmt/bundled/core.h>

template<>
struct fmt::formatter<couchbase::core::diag::cluster_state> {
Expand Down
2 changes: 1 addition & 1 deletion core/document_id.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "core/utils/binary.hxx"
#include "core/utils/unsigned_leb128.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/core.h>

#include <algorithm>
#include <cstddef>
Expand Down
2 changes: 1 addition & 1 deletion core/document_id_fmt.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "document_id.hxx"

#include <fmt/core.h>
#include <spdlog/fmt/bundled/core.h>

template<>
struct fmt::formatter<couchbase::core::document_id> {
Expand Down
4 changes: 3 additions & 1 deletion core/error_context/analytics_json.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#include "core/impl/retry_reason.hxx"

#include <couchbase/error_codes.hxx>
#include <couchbase/fmt/retry_reason.hxx>

#include <spdlog/fmt/bundled/core.h>
#include <tao/json/forward.hpp>
#include <tao/json/value.hpp>

#include <couchbase/fmt/retry_reason.hxx>

namespace tao::json
{
template<>
Expand Down
2 changes: 1 addition & 1 deletion core/error_context/key_value_json.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "key_value_error_context.hxx"

#include <fmt/format.h>
#include <spdlog/fmt/bundled/format.h>
#include <tao/json/forward.hpp>

namespace tao::json
Expand Down
2 changes: 1 addition & 1 deletion core/error_context/query_public_json.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <couchbase/fmt/retry_reason.hxx>

#include <fmt/format.h>
#include <spdlog/fmt/bundled/format.h>
#include <tao/json/forward.hpp>

namespace tao::json
Expand Down
2 changes: 1 addition & 1 deletion core/error_context/subdocument_json.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <couchbase/fmt/retry_reason.hxx>

#include <fmt/format.h>
#include <spdlog/fmt/bundled/format.h>
#include <tao/json/forward.hpp>

#include "key_value_json.hxx"
Expand Down
2 changes: 1 addition & 1 deletion core/fmt/key_value_error_map_attribute.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "core/error_context/key_value_error_map_attribute.hxx"

#include <fmt/core.h>
#include <spdlog/fmt/bundled/core.h>

template<>
struct fmt::formatter<couchbase::core::key_value_error_map_attribute> {
Expand Down
Loading

0 comments on commit 3510b3a

Please sign in to comment.