Skip to content

Commit

Permalink
Update to the latest commit of CLP core; Fix the scope of what's cons…
Browse files Browse the repository at this point in the history
…idered a system header. (#7)
  • Loading branch information
LinZhihao-723 authored Jul 5, 2024
1 parent 898c8c2 commit c565ab8
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 131 deletions.
12 changes: 6 additions & 6 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 35 additions & 23 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (NOT EXISTS ${CLP_SRC_DIR})
FetchContent_Declare(
clp-core
GIT_REPOSITORY https://github.com/y-scope/clp.git
GIT_TAG 084efa35b7e9a63aecc5e327b97aea2a1cef83bc
GIT_TAG 3c1f0ad1c44b53d6c17fd7c1d578ec61616b5661
SOURCE_DIR ${CLP_SRC_DIR}
)
message(STATUS "Fetching CLP from github.")
Expand Down Expand Up @@ -70,15 +70,21 @@ target_compile_options(${LIB_NAME}
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)

# Mark below headers as system headers so that the compiler (including clang-tidy) doesn't generate
# warnings from them.
target_include_directories(${LIB_NAME}
SYSTEM PRIVATE
${CLP_SRC_DIR}/components/core/submodules
${CMAKE_CURRENT_SOURCE_DIR}
${CLP_SRC_DIR}/components/core/src
)

target_include_directories(${LIB_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CLP_SRC_DIR}/components/core/src
# CLP source expects string_utils to be included as a library <string_utils/...>, but we
# directly bundle string_utils source files so we must add it to the include path.
${CLP_SRC_DIR}/components/core/src/clp
)

target_sources(${LIB_NAME} PUBLIC
Expand All @@ -94,27 +100,33 @@ target_sources(${LIB_NAME} PUBLIC
src/ffi_go/ir/serializer.h
src/ffi_go/search/wildcard_query.h
PRIVATE
${CLP_SRC_DIR}/components/core/src/BufferReader.cpp
${CLP_SRC_DIR}/components/core/src/BufferReader.hpp
${CLP_SRC_DIR}/components/core/src/Defs.h
${CLP_SRC_DIR}/components/core/src/ErrorCode.hpp
${CLP_SRC_DIR}/components/core/src/ReaderInterface.cpp
${CLP_SRC_DIR}/components/core/src/ReaderInterface.hpp
${CLP_SRC_DIR}/components/core/src/string_utils.cpp
${CLP_SRC_DIR}/components/core/src/string_utils.hpp
${CLP_SRC_DIR}/components/core/src/string_utils.inc
${CLP_SRC_DIR}/components/core/src/TraceableException.hpp
${CLP_SRC_DIR}/components/core/src/type_utils.hpp
${CLP_SRC_DIR}/components/core/src/ffi/encoding_methods.cpp
${CLP_SRC_DIR}/components/core/src/ffi/encoding_methods.hpp
${CLP_SRC_DIR}/components/core/src/ffi/encoding_methods.inc
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/byteswap.hpp
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/encoding_methods.cpp
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/encoding_methods.hpp
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/decoding_methods.cpp
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/decoding_methods.hpp
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/decoding_methods.inc
${CLP_SRC_DIR}/components/core/src/ffi/ir_stream/protocol_constants.hpp
${CLP_SRC_DIR}/components/core/src/clp/BufferReader.cpp
${CLP_SRC_DIR}/components/core/src/clp/BufferReader.hpp
${CLP_SRC_DIR}/components/core/src/clp/Defs.h
${CLP_SRC_DIR}/components/core/src/clp/ErrorCode.hpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/encoding_methods.cpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/encoding_methods.hpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/encoding_methods.inc
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/byteswap.hpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/encoding_methods.cpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/encoding_methods.hpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/decoding_methods.cpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/decoding_methods.hpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/decoding_methods.inc
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/protocol_constants.hpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/utils.cpp
${CLP_SRC_DIR}/components/core/src/clp/ffi/ir_stream/utils.hpp
${CLP_SRC_DIR}/components/core/src/clp/ir/parsing.cpp
${CLP_SRC_DIR}/components/core/src/clp/ir/parsing.hpp
${CLP_SRC_DIR}/components/core/src/clp/ir/parsing.inc
${CLP_SRC_DIR}/components/core/src/clp/ir/types.hpp
${CLP_SRC_DIR}/components/core/src/clp/ReaderInterface.cpp
${CLP_SRC_DIR}/components/core/src/clp/ReaderInterface.hpp
${CLP_SRC_DIR}/components/core/src/clp/string_utils/string_utils.cpp
${CLP_SRC_DIR}/components/core/src/clp/string_utils/string_utils.hpp
${CLP_SRC_DIR}/components/core/src/clp/TraceableException.hpp
${CLP_SRC_DIR}/components/core/src/clp/time_types.hpp
${CLP_SRC_DIR}/components/core/src/clp/type_utils.hpp
src/ffi_go/types.hpp
src/ffi_go/ir/decoder.cpp
src/ffi_go/ir/deserializer.cpp
Expand Down
57 changes: 33 additions & 24 deletions cpp/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,40 @@ _build_com_github_y_scope_clp = """
cc_library(
name = "libclp_ffi_core",
srcs = [
"clp/components/core/src/BufferReader.cpp",
"clp/components/core/src/ReaderInterface.cpp",
"clp/components/core/src/string_utils.cpp",
"clp/components/core/src/ffi/encoding_methods.cpp",
"clp/components/core/src/ffi/ir_stream/encoding_methods.cpp",
"clp/components/core/src/ffi/ir_stream/decoding_methods.cpp",
"clp/components/core/src/clp/BufferReader.cpp",
"clp/components/core/src/clp/ffi/encoding_methods.cpp",
"clp/components/core/src/clp/ffi/ir_stream/encoding_methods.cpp",
"clp/components/core/src/clp/ffi/ir_stream/decoding_methods.cpp",
"clp/components/core/src/clp/ffi/ir_stream/utils.cpp",
"clp/components/core/src/clp/ir/parsing.cpp",
"clp/components/core/src/clp/ReaderInterface.cpp",
"clp/components/core/src/clp/string_utils/string_utils.cpp",
],
hdrs = [
"clp/components/core/src/BufferReader.hpp",
"clp/components/core/src/Defs.h",
"clp/components/core/src/ErrorCode.hpp",
"clp/components/core/src/ReaderInterface.hpp",
"clp/components/core/src/string_utils.hpp",
"clp/components/core/src/string_utils.inc",
"clp/components/core/src/TraceableException.hpp",
"clp/components/core/src/type_utils.hpp",
"clp/components/core/src/ffi/encoding_methods.hpp",
"clp/components/core/src/ffi/encoding_methods.inc",
"clp/components/core/src/ffi/ir_stream/byteswap.hpp",
"clp/components/core/src/ffi/ir_stream/encoding_methods.hpp",
"clp/components/core/src/ffi/ir_stream/decoding_methods.hpp",
"clp/components/core/src/ffi/ir_stream/decoding_methods.inc",
"clp/components/core/src/ffi/ir_stream/protocol_constants.hpp",
"clp/components/core/src/clp/BufferReader.hpp",
"clp/components/core/src/clp/Defs.h",
"clp/components/core/src/clp/ErrorCode.hpp",
"clp/components/core/src/clp/ReaderInterface.hpp",
"clp/components/core/src/clp/ffi/encoding_methods.hpp",
"clp/components/core/src/clp/ffi/encoding_methods.inc",
"clp/components/core/src/clp/ffi/ir_stream/byteswap.hpp",
"clp/components/core/src/clp/ffi/ir_stream/encoding_methods.hpp",
"clp/components/core/src/clp/ffi/ir_stream/decoding_methods.hpp",
"clp/components/core/src/clp/ffi/ir_stream/decoding_methods.inc",
"clp/components/core/src/clp/ffi/ir_stream/protocol_constants.hpp",
"clp/components/core/src/clp/ffi/ir_stream/utils.hpp",
"clp/components/core/src/clp/ir/parsing.inc",
"clp/components/core/src/clp/ir/parsing.hpp",
"clp/components/core/src/clp/ir/types.hpp",
"clp/components/core/src/clp/string_utils/string_utils.hpp",
"clp/components/core/src/clp/TraceableException.hpp",
"clp/components/core/src/clp/time_types.hpp",
"clp/components/core/src/clp/type_utils.hpp",
],
includes = [
"./clp/components/core/src",
"./clp/components/core/src/clp",
],
includes = ["."],
copts = [
"-std=c++20",
] + select({
Expand Down Expand Up @@ -69,8 +78,8 @@ def _clp_ext_com_github_nlohmann_json():
def com_github_y_scope_clp():
_clp_ext_com_github_nlohmann_json()

commit = "084efa35b7e9a63aecc5e327b97aea2a1cef83bc"
commit_sha256 = "3aea613f00b8ca2e07803c5774a2faf8d7a315d983093eb4ce23a14a73414f72"
commit = "3c1f0ad1c44b53d6c17fd7c1d578ec61616b5661"
commit_sha256 = "1daaa432357ed470eb8a2b5e7c8b4064418fa0f5d89fd075c6f1b4aef1ac6319"
http_archive(
name = "com_github_y_scope_clp",
sha256 = commit_sha256,
Expand Down
21 changes: 11 additions & 10 deletions cpp/src/ffi_go/ir/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#include <string_view>
#include <type_traits>

#include <clp/components/core/src/ffi/encoding_methods.hpp>
#include <clp/components/core/src/ffi/ir_stream/decoding_methods.hpp>
#include <clp/ffi/encoding_methods.hpp>
#include <clp/ffi/ir_stream/decoding_methods.hpp>
#include <clp/ir/types.hpp>

#include "ffi_go/api_decoration.h"
#include "ffi_go/defs.h"
#include "ffi_go/ir/types.hpp"

namespace ffi_go::ir {
using namespace ffi::ir_stream;
using clp::ffi::ir_stream::IRErrorCode;

namespace {
/**
Expand All @@ -29,27 +30,27 @@ template <class encoded_var_view_t>
) -> int {
using encoded_var_t = std::conditional_t<
std::is_same_v<Int64tSpan, encoded_var_view_t>,
ffi::eight_byte_encoded_variable_t,
ffi::four_byte_encoded_variable_t>;
clp::ir::eight_byte_encoded_variable_t,
clp::ir::four_byte_encoded_variable_t>;
if (nullptr == ir_decoder || nullptr == log_msg_view) {
return static_cast<int>(IRErrorCode_Corrupted_IR);
return static_cast<int>(IRErrorCode::IRErrorCode_Corrupted_IR);
}
Decoder* decoder{static_cast<Decoder*>(ir_decoder)};
auto& log_msg{decoder->m_log_message};
log_msg.reserve(logtype.m_size + dict_vars.m_size);

IRErrorCode err{IRErrorCode_Success};
IRErrorCode err{IRErrorCode::IRErrorCode_Success};
try {
log_msg = ffi::decode_message<encoded_var_t>(
log_msg = clp::ffi::decode_message<encoded_var_t>(
std::string_view(logtype.m_data, logtype.m_size),
vars.m_data,
vars.m_size,
std::string_view(dict_vars.m_data, dict_vars.m_size),
dict_var_end_offsets.m_data,
dict_var_end_offsets.m_size
);
} catch (ffi::EncodingException const& e) {
err = IRErrorCode_Decode_Error;
} catch (clp::ffi::EncodingException const& e) {
err = IRErrorCode::IRErrorCode_Decode_Error;
}

log_msg_view->m_data = log_msg.data();
Expand Down
Loading

0 comments on commit c565ab8

Please sign in to comment.