diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 857a43441a..ffad00349d 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -25,7 +25,7 @@ jobs: target: 'desktop' - name: Install Dependencies - run: brew install ninja doxygen graphviz protobuf@21 hdf5@1.10 pkg-config + run: brew install ninja doxygen graphviz protobuf hdf5@1.10 pkg-config - name: Install Cap’n Proto run: | @@ -85,7 +85,7 @@ jobs: -DECAL_THIRDPARTY_BUILD_QWT=ON \ -DECAL_THIRDPARTY_BUILD_YAML-CPP=ON \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH="/usr/local/opt/hdf5@1.10:/usr/local/opt/protobuf@21" \ + -DCMAKE_PREFIX_PATH=/usr/local/opt/hdf5@1.10 \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON \ -DPython_FIND_STRATEGY=LOCATION \ diff --git a/contrib/ecalproto/src/ecal_proto_dyn.cpp b/contrib/ecalproto/src/ecal_proto_dyn.cpp index 0e53dec6fe..3394e6d65c 100644 --- a/contrib/ecalproto/src/ecal_proto_dyn.cpp +++ b/contrib/ecalproto/src/ecal_proto_dyn.cpp @@ -28,23 +28,105 @@ #include #include +#include "google/protobuf/port_def.inc" + namespace eCAL { namespace protobuf { +#if PROTOBUF_VERSION >= 5026000 + class ParserErrorCollector : public google::protobuf::io::ErrorCollector + { + public: + ParserErrorCollector() = default; + ~ParserErrorCollector() override = default; + + std::string Get() { return(m_ss.str()); } + + // Indicates that there was an error in the input at the given line and + // column numbers. The numbers are zero-based, so you may want to add + // 1 to each before printing them. + void RecordError(int line_, + google::protobuf::io::ColumnNumber column_, + absl::string_view message_) override + { + Add(line_, column_, "ERROR", message_); + } + + // Indicates that there was a warning in the input at the given line and + // column numbers. The numbers are zero-based, so you may want to add + // 1 to each before printing them. + void RecordWarning(int line_, + google::protobuf::io::ColumnNumber column_, + absl::string_view message_) override + { + Add(line_, column_, "WARNING: ", message_); + } + + private: + void Add(int line_, google::protobuf::io::ColumnNumber column_, const std::string& type_, absl::string_view message_) + { + m_ss << line_ << ":" << column_ << " " << type_ << ": " << message_ << std::endl; + } + + std::stringstream m_ss; +}; + + class DescriptorErrorCollector : public google::protobuf::DescriptorPool::ErrorCollector + { + public: + DescriptorErrorCollector() = default; + ~DescriptorErrorCollector() override {} + + std::string Get() { return(m_ss.str()); } + + void RecordError(absl::string_view filename, + absl::string_view element_name, + const google::protobuf::Message* descriptor, + ErrorLocation location, + absl::string_view message) override + { + Add(filename, element_name, descriptor, location, "ERROR", message); + } + + void RecordWarning(absl::string_view filename, + absl::string_view element_name, + const google::protobuf::Message* descriptor, + ErrorLocation location, + absl::string_view message) override + { + Add(filename, element_name, descriptor, location, "WARNING", message); + } + + private: + void Add( + absl::string_view filename, + absl::string_view element_name, + const google::protobuf::Message* /*descriptor*/, + ErrorLocation location, + const std::string& type, + absl::string_view message + ) + { + m_ss << filename << " " << element_name << " " << location << " " << type << ": " << message << std::endl; + } + std::stringstream m_ss; + }; + +#else class ParserErrorCollector : public google::protobuf::io::ErrorCollector { public: - ParserErrorCollector() {} - ~ParserErrorCollector() {} + ParserErrorCollector() = default; + ~ParserErrorCollector() override = default; std::string Get() { return(m_ss.str()); } // Indicates that there was an error in the input at the given line and // column numbers. The numbers are zero-based, so you may want to add // 1 to each before printing them. - void AddError(int line_, int column_, const std::string& msg_) + void AddError(int line_, int column_, const std::string& msg_) override { Add(line_, column_, "ERROR: " + msg_); } @@ -52,7 +134,7 @@ namespace protobuf // Indicates that there was a warning in the input at the given line and // column numbers. The numbers are zero-based, so you may want to add // 1 to each before printing them. - void AddWarning(int line_, int column_, const std::string& msg_) + void AddWarning(int line_, int column_, const std::string& msg_) override { Add(line_, column_, "WARNING: " + msg_); } @@ -69,8 +151,8 @@ namespace protobuf class DescriptorErrorCollector : public google::protobuf::DescriptorPool::ErrorCollector { public: - DescriptorErrorCollector() {} - ~DescriptorErrorCollector() {} + DescriptorErrorCollector() = default; + ~DescriptorErrorCollector() override {} std::string Get() { return(m_ss.str()); } @@ -80,7 +162,7 @@ namespace protobuf const google::protobuf::Message* descriptor, // Descriptor of the erroneous element. ErrorLocation location, // One of the location constants, above. const std::string& message // Human-readable error message. - ) + ) override { Add(filename, element_name, descriptor, location, "ERROR: " + message); } @@ -91,7 +173,7 @@ namespace protobuf const google::protobuf::Message* descriptor, // Descriptor of the erroneous element. ErrorLocation location, // One of the location constants, above. const std::string& message // Human-readable error message. - ) + ) override { Add(filename, element_name, descriptor, location, "WARNING: " + message); } @@ -110,6 +192,8 @@ namespace protobuf std::stringstream m_ss; }; +#endif + google::protobuf::Message* CProtoDynDecoder::GetProtoMessageFromFile(const std::string& proto_filename_, const std::string& msg_type_, std::string& error_s_) {