find_package with NAMES argument forces the CONFIG mode look up.
We accidentally looked for Protobuf uppercase in MODULE mode in
configure.cmake which allowed Protobuf targets be found for tests
and tools. Make this double lookup procedure explicit. All efforts
to support ubuntu/debian platforms, that decline to deliver protobuf
Config files.
Drive-by, use the correct variable to check that Protobuf is found
in golang grpc test server.
Pick-to: 6.9
Change-Id: I50d17aec72540a472bff30782d83e4555c51604a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
- add rvalue tests for message types, repeated and map types, oneof,
other non-trivially copyable types(QString QByteArray and QDatetime)
Note, skipping optional, since it is already implemented in
void QtProtobufOptionalTest::move().
Task-number: QTBUG-128388
Change-Id: If36d05de659181c547a836aeb84d5f9da38709bd
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
As it's defined as [[nodiscard]].
Pick-to: 6.8 6.9
Change-Id: I849922ed7bd64a4f67e6da0e11b1d6b4ad38deb7
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
We should aim to have the attributions as close as possible to the
actual sources. The old 'combined' attribution also did mix up the
in-source copy of some protobuf files, compared to the dependency
that is provided by provisioning.
This also fixes an issue in our documentation infrastructure, where
we remove tests/ directory before building the Qt Framework
attributions. This generated a warning so far:
File ./qtgrpc/qt_attribution.json: Directory '/home/vagrant/qt-everywhere-src-6.8.1/qtgrpc/tests/auto/protobuf/conformance/data' does not exist.
Pick-to: 6.8 6.9
Change-Id: I26c8483737ab6a6e863b3ee4a683c77cb9af5c0a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Use shorter protobuf registration file name.
Rename '_protobuftyperegistrations' suffix to '_qtprotoreg'. It helps
to bypass windows long path issues.
Pick-to: 6.8 6.9
Change-Id: Ide40ad2942135c08a06097269ef2f2a4718b1e09
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Consider that some well-known repeated types should be encoded as
atomic JSON types in array too.
Task-number: QTBUG-120214
Pick-to: 6.8 6.9
Change-Id: I57d98bb8584183f98882db64ab5612315887397d
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Consider that well-known repeated Value types may be encoded as
atomic JSON types in array too.
Task-number: QTBUG-120214
Pick-to: 6.8 6.9
Change-Id: I9fa332571728089788ed5acc5f0b62fc9ec6f306
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add the support for the optional deserializers of the well-known
Value types.
Generalize the approach so Timestamp, Duration, and BoolValue have
the common implementation.
Task-number: QTBUG-120214
Pick-to: 6.8 6.9
Change-Id: I0e835e6f0be3e45b525b310e2fb38dfec60911f3
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Validate the integer values that are packed to string when
deserializing numbers from JSON.
Task-number: QTBUG-120214
Pick-to: 6.8 6.9
Change-Id: I6324caa0e3c75cb96c89a523db478229d59958fe
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add custom JSON serializer for google.protobuf.Duration.
The serializer should serializer the number to the following
format: '<seconds>.<nanos>s' by default. Deserializer meanwhile
supports both object and short string JSON representations.
Add the respective tests.
As driven-by change replace qWarning with the proper QtProtobuf
module specific qProtoWarning in the
(de)serializeProtobufWellKnownTimestamp functions.
Task-number: QTBUG-120214
Pick-to: 6.8 6.9
Change-Id: I328c647a2e1de53d6ee9d94e655f953b53aef03f
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The qt_autogen_tools_initial_setup was called with the wrong target.
Pick-to: 6.8 6.9
Change-Id: Ied10a04745a75d5894fc8f04243e75f04c0c8390
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Added support for encoding google::protobuf::Timestamp in the [RFC 3339]
format in JSON. The Timestamp message has seconds and nanos fields
which were serialized as is previously. After the fix, the Timestamp is
serialized in a "field-name":"2024-11-14T06:20:11.530Z" format in JSON.
Pick-to: 6.8 6.9
Fixes: QTBUG-130555
Change-Id: I7372e541faccdb7dec9083e36b673013a9a4ce5e
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
When using the nested Qt types from either QtCore or QtGui packages
protobuf generator doesn't consider these types when generating the
includes.
Fixes: QTBUG-132182
Pick-to: 6.8 6.9
Change-Id: I6f0de0119ff9f8fd8109dd621a0d20f5dca31003
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Protoc disallows using the <field name>Entry if the respective
<field name> map field is defined. But meanwhile it allows using
<field name>_Entry as the field name, which ends up as
<field name>Entry in the generated code. The difference is in the
letter case is used for the alias we add for map entries and the
actual field name.
As the conclusion - test passes, but we should keep it in our test
suite to ensure we compliant with the protoc rules.
Pick-to: 6.8 6.9
Change-Id: I8a8d6796b6c5564b211bd11fdd23102b0031031e
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add the benchmark of the JSON deserialzer. Re use the common
functionality in both JSON and protobuf deserializer benchmarks.
Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I34befe253d076793228f660b24a9983af0fbc780
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Move the generic logic of serializer to a separate class and
use this class to implement the protobuf and JSON deserialization.
This also fixed one of the conformance usecases since related
to invalid enum handling.
Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Fixes: QTBUG-112423
Fixes: QTBUG-112425
Fixes: QTBUG-112424
Change-Id: I400303a8666df90050a54bd7036daa0107adcce5
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Move the generic logic of serializer to a separate class and
use this class to implement the protobuf and JSON serialization.
This also fixed one of the conformance usecases since related
to invalid enum handling.
Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Ie78da9103e68e7701b36f7d4e4c8e83f38d3c5c2
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Use more complicated data structure when benchmarking the protobuf
deserialzer. This allows also to identify changes that have
performance impact onto the deserialization.
Pick-to: 6.8 6.9
Change-Id: Ibf3a312c18edb86d383d5e236f3dad47e8581532
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Generating the aliases for protobuf QList types leads to the name
clashing when users want ot introduce messages that have name
consisting of previously defined message name and Repeated suffix,
e.g.:
message MyMessage {
}
message MyMessageRepeated {
}
We shouldn't prohibit the above scheme in our generators and generate
the respective messages correctly. The only possible solution -
complete removal of the protobuf messages QList aliases.
Generator still generates the aliases guarded by the
QT_USE_PROTOBUF_LIST_ALIASES macro. The macro is enabled by
Qt::Protobuf when building using CMake, but can be disabled at any
time by setting QT_USE_PROTOBUF_LIST_ALIASES property on protobuf
target to avoid name clashing.
[ChangeLog][Protobuf] qtprotobufgen doesn't generate protobuf message
QList aliases. All usages of aliases should be replace by respective
QList types. Aliases are still generated and are guarded by the
QT_USE_PROTOBUF_LIST_ALIASES macro in the generated code. The macro
is enabled by default and can be disabled using
QT_USE_PROTOBUF_LIST_ALIASES target property.
Fixes: QTBUG-129652
Pick-to: 6.8 6.9
Change-Id: I026755b36985eef01a6851156d9c9cfff141d247
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Value type classes in Qt usually contain an implicit QVariant opeartor.
Add it to comply with idiomatic Qt patterns.
Task-number: QTBUG-129161
Change-Id: Ib9ccd0cdfa7d6d6c2440323d1cc9b6088ea554c6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The generation was broken for proto filenames, which where
invalid identifier, since the filename is used at several places in the
generation process.
This became evident for the protobuftyperegistrations and traditional
filename header guards.
Solve this by transforming the basename into a valid identifier.
Also add a testcase on the highest point of abstraction for the
generators (qtgrpcgen).
Fixes: QTBUG-131417
Pick-to: 6.8
Change-Id: I492907881913f8b43ebf365a9e1fe38062113c3c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This will work around the issue in debian-like platforms, where
relatively new protobuf doesn't deliver the proper config files.
The lookup still prefers looking for the config files, but not
the deprecated CMake module.
Change-Id: Ie1d5217e9023022976dd058be9dd7fd1ce37e39f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This reverts commit 3d6c2827a0.
Disabling the tests was a temporary measure taken to buy us time to fix
the underlying issues. Since commit
80c6d3c08b593471f3279f45c54fdd85222072eb in qtdeclarative the particular
code exercised by these tests is fixed. Therefore, we can re-enable
them.
Pick-to: 6.8
Task-number: QTBUG-127174
Change-Id: I304dc0318be50cdf2fded34bd33d9e3ba568089c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Use the empty initialization for the google::protobuf:Any when it's
used as the oneof field.
Fixes: QTBUG-131415
Pick-to: 6.8
Change-Id: Ib2e9d9234b9cf90dce3c72b85001fa1b62a501e8
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Fix the invalid assignment of the string to an object. Assing
string values to the inner message field instead.
Pick-to: 6.8
Fixes: QTBUG-131577
Change-Id: I52dd735c0ffd3a00ac5f95f090c03b7ca3172081
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
The channel options test should not check the SSL configuration when
SSL has not been configured
Fixes: QTBUG-131134
Pick-to: 6.8
Change-Id: I6356d0e7b9330a6b5d6830da93d4bb0958f6dcf7
Reviewed-by: Jaime Resano <Jaime.RESANO-AISA@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
These modules are not relevant anymore. After porting Qt::Grpc
relied on native gRPC implementation. But since we migrated to the
fully functional Qt HTTP/2 the need of reference gRPC and protobuf
gone.
Remove the WrapgRPC and WrapProtobuf modules, use the protobuf
gRPC modules directly in tests examples and tools. Since non of
those never add the build-time depdendcy on reference libraries,
we don't need to add the respective dependencies in Qt packages.
The only thing we still wrap is protoc. We either look for executable
but we never propagate it as the reference target, but utilize the
path from there.
Fixes: QTBUG-128809
Change-Id: Id5008f8dd935288cbaa8a9abb88d485824099d46
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Move the common logic of two tests to the base class. Adjust the
implementation of the qtgrpcgen test to the recent changes in
the qtprotobufgen test.
Pick-to: 6.8
Task-number: QTBUG-128753
Change-Id: I946cd132c6850ce56d8c3217169bb5c4e335e969
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
MacOS provisioning is fixed long time ago. Remove leftovers from
tests.
Pick-to: 6.8
Taks-number: QTBUG-109130
Change-Id: I4565ffecfd49ac7f6c56045027a6f564d0547e3e
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add the protocplugintestcommon static library that contains a common
code for both tests.
Reuse the library in tests instead of code duplication.
Pick-to: 6.8
Task-number: QTBUG-128753
Change-Id: Ib56861462635d6a0fff0f1add9b2cd7765316e09
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Add the missing tests for the HEADER_GUARD. The test was not
provided by functional change, since it required the refactoring
in qtprotobufgen test kit.
Change-Id: I1e14ba29c61adb80d5af3775c7c729f1ab508448
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Use the common .proto scheme for all testcases, that defined lot of
message variants, so we can see how changes in generator affect
various types but not only restricted subset.
Rearrange the test cases according to the generator options.
Change the verification process for command line tests. Consider not
only some files but all generated files, so we can see if some new
file is added or some files are remove/renamed.
Simplify tests.
Add the COPY_TEST_RESULTS environment variable support. This variable
now allows copying test results to the source directory. The introduced
functionality is very handy when need update expected results after the
major changes in generator.
Add the respective feature guards for the QProcess usage. In case if
the feature is disabled in QtCore.
Pick-to: 6.8
Task-number: QTBUG-128753
Change-Id: I5ac33684c8cf4fd5dd133b404061db4435a87344
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Protobuf required the special strings for (-)Infinity and NaN floating
point numbers. Use the valid letter case when serializing those.
Pick-to: 6.8
Change-Id: I45a9190aee8d407eca63fd1b352d041d5063e7ec
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
In certain usecases users might need to know the RPC result message
type. Currently we do not store it anywhere, so API users decide
how to deserialize message when calling QGrpcOperation::read method.
Add RCP methods overloads to QGrpcClientBase that accept the meta
types of the RPC result messages. Generate the code that uses these
overloads by default, sot QGrpcClientBase can store the information
about the result type inside the QGrpcOperationContext.
Introduce QGrpcOperation::responseMetaType,
QGrpcOperationContext::responseMetaType and
QGrpcOperationContext::setResponseMetaType methods.
These methods are user-facing API to access or change the result meta
type.
Task-number: QTBUG-128743
Change-Id: Ide0ebc1c935dfbdf0d3b62e05acdf058f95bf367
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Guard the QLocalSocket implementation in QGrpcHttp2Channel
with the respective feature condition.
Fixes: QTBUG-129204
Pick-to: 6.8 6.8.0
Change-Id: Ie4de6576318305194735d76b46db1475faff3fdb
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Currently we're doing something manually, which, since Qt6 is a
dedicated feature. Use that instead for less error-prone disconnections
for our single-shot signals.
Lets not re-invent the wheel for something that has been (potentially
faster rather then slower) invented for this exact usecase.
We will promote the usage of Qt::SingleShotConnection, so as good
teachers we should be using it as well.
Pick-to: 6.8
Change-Id: I3b2b9f176f06d91b4d0946a38c53a4c2614c8a01
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
All new enums should be scoped.
Drive-by change: Remove the redundant suffixes of the enum elements.
It's obvious from the scope that those are errors.
Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: Ided4ab4a1ddb2d14713f876ffe4fe339af39ae6b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The option is noop, since the QML URI is not used by generators.
Plain QML option should be sufficient.
Pick-to: 6.8
Change-Id: I3b3c90103799316300ca86f11e5ddcc60e53443d
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
The use of shared pointers has potential risk of storing the
QGrpcOperation children forever and leaking in user code. The problem
is clearly in the lambda connections that we encourage to use in the
docs and examples:
auto stream = testStream(...);
QObject::connect(stream.get(), &QGrpcOperation::finished,
ctx, [ctx, stream]{...});
The above code will hold the 'stream' forever, unless user will make
the explicit disconnect in the lambda.
By using std::unique_ptr we partially solve this, or at least convince
user to solve this. When user creates lambda he knows the 'stream'
lifetime and most probably should consider that after the move, lambda
is owning the QGrpcOperation, so the need of disconnect is more clear
in this case:
auto stream = testStream(...);
auto *streamPtr = stream.get();
QObject::connect(streamPtr, &QGrpcOperation::finished,
ctx, [ctx, stream = std::move(stream)]{...});
The code becomes a bit more complicated, but it points explicitly to
the potential risk. Also it disallows to make this trick to multiple
lambdas at the same time.
Of course using the lambda context to control the QGrpcOperation
lifetime in this case is not necessary. But even if users will decide
to manage the QGrpcOperation lifetime differently, the use of
std::unique_ptr will clearly point to the ownership.
[ChangeLog][Grpc] All generated RPC methods now return std::unique_ptr
instead of std::shared_ptr. This change explicitly defines that caller
takes the ownership of the returned pointers.
Pick-to: 6.8
Change-Id: I271b91454f0c1b12b77127a7e025fa493367e279
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add missing BuildInternals lookiup for the standalone build of the
gGRPC benchmark project.
Pick-to: 6.8
Change-Id: I4fb423f95743bc67ebca1604bec3756edd521795
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add the explicit lvalue ref-quialifiers for the non-trivially copyable
type getters in the generated code.
Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: I06f0dd0dfb8f35e937f21c5e58271fa8d5f76a44
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Add rvalue setter to the generated messages for the non-trivially
copyable fields. This also implies the change of trivially copyable
type setters. These setters now pass arguments by value, but not
as cref.
Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: Ic504366b1c7218a9825fff4c74cf694c19d442a7
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Remove the generating of the mutable getters for protobuf messages.
Since the moc prefers using them as property getters we cannot
continue generating them, because each access to the property detaches,
which has bad consequences for the performance.
Pick-to: 6.8
Fixes: QTBUG-119913
Change-Id: I8cf405f01932174318a5d8c5a251a24272b90629
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
It's necessary not only to set the inner metadata when the setMetadata
is called, but also when QQmlGrpcMetadata::data is changed. Otherwise
the internal metadata value will not be in sync.
As drive-by change, fix the usage of channel options in
QGrpcHttp2Channel. Instead of storing the options duplicate in
QGrpcHttp2Channel, use the QAbstractGrpcHttp2Channel copy.
Make QAbstractGrpcHttp2Channel::channelOptions public.
TODO: QGrpcHttp2Channel doesn't consider the changes of ssl
configuration and serialization format when updating the
channelOptions, but it should react respectively or disallow setting
those at runtime.
Pick-to: 6.8
Change-Id: I40cf8476679f83a2925d77bcd1d89f043a0b6e67
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>