Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added optional mavsdk server built with grpc proto reflection. This a… #1850

Merged
merged 3 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.13)
option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
option(SUPERBUILD "Build dependencies" ON)
option(BUILD_MAVSDK_SERVER "Build mavsdk_server" OFF)
option(BUILD_WITH_PROTO_REFLECTION "Build mavsdk_server with proto reflection" OFF)
option(BUILD_SHARED_LIBS "Build core as shared libraries instead of static ones" ON)

if(SUPERBUILD AND HUNTER_ENABLED)
Expand Down
4 changes: 4 additions & 0 deletions src/mavsdk_server/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ target_link_libraries(mavsdk_server
${COMPONENTS_PROTOGENS}
)

if(BUILD_WITH_PROTO_REFLECTION)
add_definitions(-DENABLE_PROTO_REFLECTION)
target_link_libraries(mavsdk_server PRIVATE gRPC::grpc++_reflection)
endif()

foreach(plugin ${COMPONENTS_LIST})
string(TOUPPER ${plugin} plugin_uppercase)
Expand Down
4 changes: 4 additions & 0 deletions src/mavsdk_server/src/grpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ int GrpcServer::run()
builder.RegisterService(&_tune_service);
#endif

#ifdef ENABLE_PROTO_REFLECTION
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
#endif

grpc::EnableDefaultHealthCheckService(true);
_server = builder.BuildAndStart();

Expand Down
5 changes: 5 additions & 0 deletions src/mavsdk_server/src/grpc_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>

#ifdef ENABLE_PROTO_REFLECTION
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#endif

#include <memory>

#include "mavsdk.h"
Expand Down
4 changes: 4 additions & 0 deletions templates/grpc_server.cpp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ int GrpcServer::run()
#endif
{% endfor %}

#ifdef ENABLE_PROTO_REFLECTION
grpc::reflection::InitProtoReflectionServerBuilderPlugin();
#endif

grpc::EnableDefaultHealthCheckService(true);
_server = builder.BuildAndStart();

Expand Down
5 changes: 5 additions & 0 deletions templates/grpc_server.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#include <grpcpp/server.h>
#include <grpcpp/server_builder.h>

#ifdef ENABLE_PROTO_REFLECTION
#include <grpcpp/ext/proto_server_reflection_plugin.h>
#endif

#include <memory>

#include "mavsdk.h"
Expand Down