Skip to content

Commit d19bf2a

Browse files
yash-niYash ChauhanCopilot
authored
Upgrade grpc library to v1.78.1 (#499)
* Initial changes * Removed all internal private api * Removed forward decleration * Using internal zigzag encode and decode * Upgraded grpc submodule to v1.78.0 * Updated template constructor * Removed extra whitespace Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Removed hard coded utf8 validity check * Added conditional_variable include * Removed periods from debug log * Removed circular dependency * Rename semaphore to lv_semaphore * Added unit tests * Added cached datasize * Fixed parsing for various types * Fixed byte message parsing * Added _cachedByteSize * Fixed enum parsing * Fix nested message parsing * Through rumtime error if string is invalid * Correctly parse oneof in codedstream * Minor cleanup * Fix parsing for singular types * Invalidate bytesize cache * Added AreUtf8StringsEnabled feature toggle for byte parsing * Return error from seralizetostring Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove commented headers Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Correct cache reset * Remove empty buffer check Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Include break in wiretype group * Upgrade grpc to v1.78.1 * Update src/lv_serialization_traits.h comments Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Return false if parsing fails * Removed buffer clear * Override recorderror and recordwarning * Added support for unpacked repeated field * Added tests for unpacked repeated fields * Use wireformat from wireformatlite internal library * Remove inline zigzag helpers * Minor changes * Minor changes * Changed parameter names to camelcase * Resolved build errors * Refactor protobuf numeric field parsing using traits-based template * Fix: merge multiple packed chunks for the same repeated field * Added commentes for bytesizelongcache * Added tests for repeated string/bytes merging across multiple occurrences * Correctly handle empty buffers * Removed unnecessary copies and allocations in ParseFromByteBuffer * Minor changes and refactoring * Minor changes and code cleanup * minor changes --------- Co-authored-by: Yash Chauhan <yash.chauhan@emerson.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 51c1ef2 commit d19bf2a

25 files changed

+4399
-1268
lines changed

CMakeLists.txt

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(labview-grpc C CXX)
88
set(ABSL_ENABLE_INSTALL ON)
99

1010
if(NOT MSVC)
11-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
11+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
1212
# Set default visibility to hidden, only export LIBRARY_EXPORT symbols from the shared library
1313
add_compile_options(-fvisibility=hidden)
1414
else()
@@ -19,7 +19,7 @@ else()
1919
set(protobuf_MSVC_STATIC_RUNTIME ON CACHE BOOL "Use static runtime for protobuf" FORCE)
2020
set(ABSL_MSVC_STATIC_RUNTIME ON CACHE BOOL "Use static runtime for Abseil")
2121
set(CARES_MSVC_STATIC_RUNTIME ON CACHE BOOL "Use static runtime for c-ares")
22-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
22+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
2323
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244")
2424
add_compile_options("$<$<NOT:$<CONFIG:Debug>>:/Zi>")
2525
add_link_options("$<$<NOT:$<CONFIG:Debug>>:/DEBUG>")
@@ -46,6 +46,15 @@ add_definitions(-D_PS_${CMAKE_SIZEOF_VOID_P})
4646
#----------------------------------------------------------------------
4747
add_subdirectory(third_party/grpc ${CMAKE_CURRENT_BINARY_DIR}/grpc EXCLUDE_FROM_ALL)
4848

49+
#----------------------------------------------------------------------
50+
# Workaround for MSVC C1001 ICE in descriptor_visitor.h on 32-bit builds
51+
# Force protobuf to use C++20 to avoid compiler internal error
52+
# See: https://github.com/google/bloaty/pull/410
53+
#----------------------------------------------------------------------
54+
if(MSVC)
55+
set_target_properties(libprotobuf libprotobuf-lite libprotoc PROPERTIES CXX_STANDARD 20)
56+
endif()
57+
4958
#----------------------------------------------------------------------
5059
# Use the grpc targets directly from this build.
5160
#----------------------------------------------------------------------
@@ -95,6 +104,7 @@ add_library(labview_grpc_server SHARED
95104
src/lv_message_value.cc
96105
src/lv_proto_server_reflection_plugin.cc
97106
src/lv_proto_server_reflection_service.cc
107+
src/lv_serialization_traits.cc
98108
src/message_element_metadata_owner.cc
99109
src/message_metadata.cc
100110
src/path_support.cc
@@ -217,6 +227,42 @@ target_link_libraries(test_server
217227
${_GRPC_GRPCPP}
218228
${_PROTOBUF_LIBPROTOBUF})
219229

230+
#######################################################################
231+
# Unit Tests (Google Test)
232+
#######################################################################
233+
234+
# Google Test is bundled with gRPC
235+
set(GTEST_DIR "${CMAKE_SOURCE_DIR}/third_party/grpc/third_party/googletest")
236+
add_subdirectory(${GTEST_DIR} ${CMAKE_CURRENT_BINARY_DIR}/googletest EXCLUDE_FROM_ALL)
237+
238+
add_executable(unit_tests
239+
tests/unit/lv_message_tests.cc
240+
src/lv_message.cc
241+
src/lv_message_value.cc
242+
src/lv_serialization_traits.cc
243+
src/string_utils.cc
244+
src/feature_toggles.cc
245+
src/message_metadata.cc
246+
src/message_element_metadata_owner.cc
247+
src/lv_interop.cc
248+
src/path_support.cc
249+
src/exceptions.cc
250+
src/well_known_messages.cc
251+
)
252+
target_link_libraries(unit_tests
253+
gtest
254+
${_GRPC_GRPCPP}
255+
${_PROTOBUF_LIBPROTOBUF}
256+
)
257+
target_include_directories(unit_tests PRIVATE
258+
"${CMAKE_SOURCE_DIR}/src"
259+
"${CMAKE_CURRENT_BINARY_DIR}"
260+
"${GTEST_DIR}/googletest/include"
261+
)
262+
263+
enable_testing()
264+
add_test(NAME unit_tests COMMAND unit_tests)
265+
220266
add_dependencies(labview_grpc_server Detect_Compatibility_Breaks)
221267
add_dependencies(labview_grpc_generator Detect_Compatibility_Breaks)
222268
add_dependencies(test_client Detect_Compatibility_Breaks)

src/event_data.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
#include <grpc_server.h>
44
#include <lv_message.h>
55

6-
//---------------------------------------------------------------------
7-
//---------------------------------------------------------------------
8-
using namespace google::protobuf::internal;
9-
106
namespace grpc_labview
117
{
128
//---------------------------------------------------------------------

src/grpc_client.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
#pragma once
55

66
//---------------------------------------------------------------------
7+
// IMPORTANT: lv_serialization_traits.h MUST be included BEFORE grpc headers
8+
// This registers our custom SerializationTraits<LVMessage> specialization
79
//---------------------------------------------------------------------
8-
#include <metadata_owner.h>
10+
#include <lv_serialization_traits.h>
911
#include <grpcpp/grpcpp.h>
10-
#include <lv_message.h>
1112
#include <grpcpp/impl/codegen/sync_stream.h>
13+
#include <metadata_owner.h>
1214
#include <future>
1315
#include <unordered_map>
1416

src/grpc_server.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
//---------------------------------------------------------------------
88
#ifdef __WIN32__
99
#define WIN32_LEAN_AND_MEAN
10+
#define NOMINMAX
1011
#include <windows.h>
1112
#endif
1213

1314
//---------------------------------------------------------------------
15+
// IMPORTANT: lv_serialization_traits.h MUST be included BEFORE grpc headers
16+
// This registers our custom SerializationTraits<LVMessage> specialization
1417
//---------------------------------------------------------------------
18+
#include <lv_serialization_traits.h>
1519
#include <grpcpp/grpcpp.h>
1620
#include <grpcpp/impl/codegen/async_generic_service.h>
1721
#include <grpcpp/impl/codegen/completion_queue.h>
@@ -27,7 +31,7 @@
2731
#include <map>
2832
#include <event_data.h>
2933
#include <metadata_owner.h>
30-
#include <semaphore.h>
34+
#include <lv_semaphore.h>
3135

3236
//---------------------------------------------------------------------
3337
//---------------------------------------------------------------------

src/lv_interop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//---------------------------------------------------------------------
77
#ifdef _WIN32
88
#define WIN32_LEAN_AND_MEAN
9+
#define NOMINMAX
910
#include <windows.h>
1011
#endif
1112

0 commit comments

Comments
 (0)