From dd04edf72fd30c48ecec8b069788057c48364851 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 1 Aug 2023 16:11:04 +0200 Subject: [PATCH] Fix building protobufgen with old protobuf versions Guard the 'override' keyword of GetSupportedFeatures with protobuf version check that is only applicable for versions higher than 3.12. TODO: This workaround should gone once we restrict the minimal supported protobuf version. See QTBUG-115702. Amends bbb19e18e2bf2f7365769a0223511a91ada697f3 Fixes: QTBUG-115693 Pick-to: 6.6 Change-Id: I9cba91215b8914d5994bfa27114a7deb411f8756 Reviewed-by: Konrad Kujawa Reviewed-by: Qt CI Bot --- src/tools/qtprotoccommon/generatorbase.cpp | 5 ----- src/tools/qtprotoccommon/generatorbase.h | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/tools/qtprotoccommon/generatorbase.cpp b/src/tools/qtprotoccommon/generatorbase.cpp index 00b453bb..5a49a0a1 100644 --- a/src/tools/qtprotoccommon/generatorbase.cpp +++ b/src/tools/qtprotoccommon/generatorbase.cpp @@ -29,11 +29,6 @@ bool GeneratorBase::GenerateAll(const std::vector &files return CodeGenerator::GenerateAll(files, parameter, generatorContext, error); } -uint64_t GeneratorBase::GetSupportedFeatures() const -{ - return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL; -} - std::string GeneratorBase::generateBaseName(const FileDescriptor *file, const std::string &name) { std::string outFileBasename; diff --git a/src/tools/qtprotoccommon/generatorbase.h b/src/tools/qtprotoccommon/generatorbase.h index e1b52cf0..084789e8 100644 --- a/src/tools/qtprotoccommon/generatorbase.h +++ b/src/tools/qtprotoccommon/generatorbase.h @@ -6,6 +6,7 @@ #define GENERATORBASE_H #include +#include #include #include @@ -37,7 +38,17 @@ public: std::string *error) const override; bool HasGenerateAll() const override { return true; } - uint64_t GetSupportedFeatures() const override; +// TODO: This suppresses the build issue with old protobuf versions. Since we don't have the +// strict protobuf versions that we support this work around will be here for a while, since +// yocto builds quite old protobuf by now. See QTBUG-115702. +#if PROTOBUF_VERSION < 3012000 + uint64_t GetSupportedFeatures() const { return 0; }; +#else + uint64_t GetSupportedFeatures() const override + { + return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL; + } +#endif static void printDisclaimer(::google::protobuf::io::Printer *printer); void OpenFileNamespaces(const ::google::protobuf::FileDescriptor *file, @@ -51,4 +62,6 @@ protected: }; } // namespace qtprotoccommon +#include + #endif // GENERATORBASE_H