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 bbb19e18e2

Fixes: QTBUG-115693
Pick-to: 6.6
Change-Id: I9cba91215b8914d5994bfa27114a7deb411f8756
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2023-08-01 16:11:04 +02:00
parent cb071d590f
commit dd04edf72f
2 changed files with 14 additions and 6 deletions

View File

@ -29,11 +29,6 @@ bool GeneratorBase::GenerateAll(const std::vector<const FileDescriptor *> &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;

View File

@ -6,6 +6,7 @@
#define GENERATORBASE_H
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/port_def.inc>
#include <string>
#include <functional>
@ -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 <google/protobuf/port_undef.inc>
#endif // GENERATORBASE_H