Commit Graph

1467 Commits

Author SHA1 Message Date
Qt Submodule Update Bot eebbc89765 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I7f3b4b0f6de79ac1e508819b0d39dc2a9368a462
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-23 22:20:34 +00:00
Qt Submodule Update Bot a9b2f02b41 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ifb64e1c9a2bc09a4f6186a65012dde9c74e21b35
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-21 09:42:36 +00:00
Alexey Edelev a445cf4344 Make the well-known type scheme lookup explicit in installed Qt
Instead of storing the build-time path to the well-known types
protobuf includes, calculate them when configuring user projects.

New approach expects that all well-known type schemas that the
ProtobufWellKnownTypes module used at build time are present when
configuring user projects. The include paths then calculated and
stored in the QT_PROTOBUF_INCLUDES property of the
ProtobufWellKnownTypes module.

The property usage remains unchanged.

Pick-to: 6.9 6.8
Fixes: QTBUG-130113
Change-Id: I31a607404f85f2a325c63e0f28d2ab2a0f4ea25f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-19 10:13:14 +01:00
Alexey Edelev 5494d64908 Make the types list of qt_internal_add_protobuf_wellknown_types named
Add the TYPES argument to the qt_internal_add_protobuf_wellknown_types
command instead of using ARGN. It's safer and more scalable approach.

Pick-to: 6.8 6.9
Change-Id: I75ac5df740b614433b74e8b70729211f49e0a308
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-05-19 10:13:11 +01:00
Alexey Edelev 18bb2ba5e1 Allow specifying extra protobuf include directories for protobuf modules
Iterate the _<Module>_proto_external_include_dir variable in
<Module>ProtobufProperties.cmake and add the existing paths to
the QT_PROTO_INCLUDES property. This allow specifying extra paths
in <Module>Config.cmake.

If the respecive paths are not found or are not absolute, the
respective warning is raised.
Setting QT_NO_WARN_PROTOBUF_BROKEN_INCLUDES to ON suppresses the
warning.

Pick-to: 6.8 6.9
Change-Id: I4b6971e84f35b2986d187fb5d1766ed0cf3390f5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-19 10:13:09 +01:00
Qt Submodule Update Bot cf750df488 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ibf5f7750f2a7286c43da3123ad1ed000ffa334d4
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-18 11:06:17 +00:00
Dennis Oberst bfb44df850 Fix and improve benchmarks
The existing benchmarks were not optimal: bidirectional streaming wasn’t
fully asynchronous, limiting channel performance. Introduce a
`BenchmarkData` type to collect detailed metrics and print richer
results at the end. Also add latency measurements for unary READ and
WRITE operations.

As a drive-by add cxx20 checks in cmake.

Pick-to: 6.9 6.8
Change-Id: I56d61e4712b7fe9e5b8b52a14f84b0583094e373
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-16 14:42:19 +02:00
Dennis Oberst 66984e6a3c QGrpc{Channel,Call}Options: Support incremental updates via addMetadata
Currently we only provide `setMetadata(~)` as a way for users to
supply their metadata. However, certain code paths would benefit from
having an `add` functionality as well, without requiring the user to
create a temporary object.

[ChangeLog][GRPC][QGrpc*Options] Added support for incrementally adding
metadata via `addMetadata()`.

Change-Id: Ibc5d721850745df5f171b9126b595ca9c6b0c319
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-16 14:42:14 +02:00
Dennis Oberst 778371b8ea Deprecate QHash<QBA,QBA> metadata in favor of QMultiHash
Even though gRPC provides some leeway, as "Access to metadata is
language dependent", we have yet to see an implementation which doesn't
support multiple values per key.

Common implementations like grpc-c++, grpc-go or grpc-java provide this
and we should do it aswell.

Ref: https://grpc.io/docs/what-is-grpc/core-concepts/#metadata
Ref: https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md#constructing-metadata

Use a base class to implement common functionality for the options
classes. Also use a new common class in the tests.

The QMultiHash overload is selected when the 'QtGrpc::MultiValue'
argument is used in 'metadata' calls. We update the documentation
accordingly.

Deprecation is scheduled for Qt 6.13

Users with a custom Qt build - those who care - should be rewarded with
minimal traces of this "accident" and should not suffer from potential
performance/storage overhead. Therefore we deprecate QtGrpc::MultiValue
for those builds, effectively providing Qt 7 behavior.

[ChangeLog][Deprecation Notice]
Deprecate the metadata()/setMetadata() methods on QGrpcCallOptions and
QGrpcChannelOptions that use QHash in favor of the new overloads that
use QMultiHash. This is more in line with the gRPC specification.

Fixes: QTBUG-136471
Change-Id: I58d14d2c304c06de269c99ba5383beee86d12f77
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-16 14:42:11 +02:00
Qt Submodule Update Bot 9a1cc11111 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I50fd31e223bb75aa8294195faa62034cf9aa4bd6
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-13 16:09:16 +00:00
Qt Submodule Update Bot 9f74f49992 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Idb29fc5e62a4b51b2003c6bbd4317eda8d9de07f
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-08 15:24:38 +00:00
Qt Submodule Update Bot abbe99c0d0 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I4c32faf64cce6cbd50afec2c9bfd818e2b4b8e46
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-03 02:19:22 +00:00
Qt Submodule Update Bot 391e98f4ac Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ib62c1fb3607068b61d1bc8abe6dfe7b7c84938aa
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-05-01 08:58:10 +00:00
Qt Submodule Update Bot a9d4a09bef Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I43aab9cff23ff466af8f3959380c7dba6e87fb40
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-29 11:44:05 +00:00
Dennis Oberst 6ffaa636c7 Grpc benchmarks: add qelapsedtimer include to shared header
It was missing for the grpc reference client. It's used in both clients
so simply add it to the shared header

Pick-to: 6.8 6.9
Change-Id: I568aa92f50c7b4c7a94d0226a7d4e4672863fac8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-24 17:33:45 +02:00
Qt Submodule Update Bot 55fb00bbe1 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ibcb7d5beaf48416ad7d7dc76904759df0b8fe49c
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-24 09:35:11 +00:00
Qt Submodule Update Bot 55a7035b66 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ic89be0824af25e69b5ea3710c032989ad0473e33
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-22 14:05:18 +00:00
Qt Submodule Update Bot e2e856ed1c Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ibece72a39a2dc28ee4480d462c79890416d04d5b
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-15 11:31:18 +00:00
Dennis Oberst 3645862635 qtgrpc: mark security critical source files
Reviewed and marked all security critical files in the qtgrpc/src
directory.

More information: https://contribute.qt-project.org/quips/23

Fixes: QTBUG-135455
Change-Id: Iad313dfe4b5b168d56954e58ab30e0e411ab6de5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-11 10:49:10 +02:00
Qt Submodule Update Bot 0951e2dd00 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: Ie541feb0567ea6f1774397cf8955107029a7ce84
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-09 23:56:19 +00:00
Andreas Eliasson 094f5f54d5 Doc: Add missing \title to GRPC client guide example
Pick-to: 6.8 6.9
Change-Id: I8bf7f2e5b578b58f67816c02fd4c2b2f00aba798
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-04-08 07:51:39 +00:00
Alexey Edelev 08e170bec9 Require the 'scope' descriptor in produceProperyMap functions
The scope is mandatory there, since we read the containing class
name from it. Assert if the scope is nullptr.

Coverity-Id: 479426
Pick-to: 6.8 6.9
Change-Id: Iad3acba25083fde89b70b9c6dcacd4e2cafc3cae
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2025-04-04 17:45:31 +02:00
Alexey Edelev cc5f89d5a4 Move assign the serialized buffer in QProtobufSerializerImpl::serializeMessageFieldEnd
Small optimization bits.

Coverity-Id: 479440
Pickt-to: 6.8 6.9
Change-Id: I302a98564e77eaf3810e7e85457fc768a26f4c18
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2025-04-04 17:45:26 +02:00
Alexey Edelev d6586d97a1 Long live mutable getters
The functionality is desirable by some users, we re-enable it.
New API addresses the core issue that is partially related to
QTBUG-119912, but has wider concequences in blind use in user
projects. We add the 'mut' prefix to all mutable getters to make
the mutable access explicit. Overload approach leads to unwanted
detaches not only whe is used be moc-generated code, but also
in user projects if developers do not pay enough attention to
const modifiers of their variables/references. We declined to
restore it, dispite it was the better looking API, in favor to
the code safety.

This also reveals the code clashing scenario, when the overload
might happen if the message has both 'a' and 'mutA' fields in
its definition. This scenario is kindly forbidden by our generator,
and sanitized at very early stages. We expect that it won't happen
in user projects, but even if it will, the solution is to rename
the field when generating Qt code. The serialization/deserialization
do not depend on field naming directly. json_name attribute also
will help to workaround this.

The undocumented ALLOW_MUTABLE_GETTER_CONFLICTS option allows clashing
the mutable getter names, but its usage currently limited by our
internal code only. The reason unfixed QTBUG-119912 issue in moc.
Once the issue is fixed, the moc version check should get the proper
version, but not '99' as for now and the ALLOW_MUTABLE_GETTER_CONFLICTS
will become public.

Another design solution is the use of overloaded functions that
return pointers, like it's done it the reference protobuf. But this
kind of API leaves the pointer ownership undefined and decided to
not be used.

[ChangeLog][Protobuf] The generated messages now have the mutable
getters for the fiels of the message type. The getters have 'mut'
prefix and implicily allocate the respective fields if needed, so the
use of intermediate message objects is not required.

Task-number: QTBUG-119913
Change-Id: I09b9ee37e1fbbe37b9c3cb501e92442da8ad3e4b
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-04-04 17:45:22 +02:00
Dennis Oberst 4de7b5f2b5 ProtobufSerializer: fix potential overflow in encodeHeader
Ensure the fieldNumber remains within valid bounds before shifting.
Replace implicit conversions with explicit uint* casts.

Coverity-Id: 479441
Pick-to: 6.9 6.8
Change-Id: I82f9436f7fe89feab2fd60ff982c96631e390514
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:28:08 +02:00
Dennis Oberst 4b536e162d QProtobufSerializer: change fieldIndex to fieldNumber in encodeHeader
Pick-to: 6.9 6.8
Change-Id: I465aa746f0467933715091f6c5a1ba536b8313d2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:28:04 +02:00
Dennis Oberst 9508b383f2 QtProtobufQtCoreTypes: skip missing copy when iterating segments
Coverity-Id: 479431
Pick-to: 6.9 6.8
Change-Id: I633424a034e19f39a1c072f25afd39adc3e7e440
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:28:01 +02:00
Dennis Oberst e0257e5d0b QtGrpc: add missing std::move
Coverity-Id: 479450
Coverity-Id: 479444
Pick-to: 6.9 6.8
Change-Id: I6d27da6ff7a11da7e52025e46d68beddb41e0395
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:53 +02:00
Dennis Oberst 5392ab2bf0 ProtobufDeserializer: fix uninitialized iterator member
Explicitly initialize m_it to avoid undefined behavior of uninitialized
class members.

Coverity-Id: 479445
Change-Id: I6af28d118ae12a25d58d697535da185c8e1c47e1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:49 +02:00
Dennis Oberst 99d09ea8be tools [generators]: Prefer error string over throwing
This is not a library. The tool should not recover here. Print the error
and exit the program.

Coverity-Id: 479436
Pick-to: 6.9 6.8
Change-Id: I97c24b325a037e19de17af9b246ba2bb2be76d78
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:34 +02:00
Dennis Oberst f66f3daffb ProtobufScalarJsonSerializers: fix overflowed return value
Restructure the limits check to be more compact by separating the
invariant from the variant. The latter is extracted into a constexpr
lambda check.

Fix the overflow by checking the ok flag and return a default
initialized T.

Coverity-Id: 479421
Change-Id: Ia50fcba5de1335c2a26478d10f89b2d9c5696c4b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-04 14:27:30 +02:00
Dennis Oberst f5b0365d35 tools [qtgrpcgen]: construct exportMacroFilename in place
saves a copy.

Coverity-Id: 479417
Pick-to: 6.9 6.8
Change-Id: I09d3d1a8e137ba9bbf0003825766b7907dff747a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:27 +02:00
Dennis Oberst fd117e8f3a tools [utils]: misc. improvements
- sort / restructure header usage
- use utils::toAsciiLower, same as asciiToUpper()

Change-Id: Ic5e7a369cea64cdb561471fb8c1246036263698d
Pick-to: 6.9 6.8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:24 +02:00
Dennis Oberst a335b71abe tools [utils]: directly emplace substrings into vector for split()
Saves a temporary.

Change-Id: I6851e6f941dfa593fb37f79a7ec19ce446753556
Pick-to: 6.9 6.8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:19 +02:00
Dennis Oberst 0e6a9f6890 tools [utils]: implement trim as part of ltrim & rtrim
This is the only logical solution for this code...
As a drive-by make asciiSpacing constexpr and adjust capitalization.

Change-Id: I2cda5006a9eec94b80701d71e5c4000c3c852bf3
Pick-to: 6.9 6.8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:16 +02:00
Dennis Oberst cb5cc69cb3 tools [utils]: fix invalid erase on ltrim()
When the string is entirely whitespace all characters except one gets
erased. Rather use size() to denote the end of the string.

Change-Id: I80bf92319d4725b9400e0f67e968e3cb8c27dd86
Pick-to: 6.9 6.8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:12 +02:00
Dennis Oberst 839b9372f8 tools [utils]: implement file operation with std::filesystem
Coverity noticed inefficiencies of unneeded copies. Fix this by using
std::filesystem for these operations.

Coverity-Id: 479416
Pick-to: 6.9 6.8
Change-Id: I44666f4ca791763c13152c4861e78a122b8cfc50
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:09 +02:00
Dennis Oberst 4710cacf13 QProtobufPropertyOrdering: remove dead code for char_data alignment check
Coverity rightfully complained about dead code in the char_data
method, as ... % alignof(char) will never be non zero.

Fix this by removing the superfluous check.

As a drive-by remove unused parameters - they can be added if needed.

Coverity-Id: 479414
Pick-to: 6.9 6.8
Change-Id: Ie3f2b14cbf3e18c76deae491c099ccf7ec8b7716
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-04 14:27:05 +02:00
Qt Submodule Update Bot 74ed4c3437 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I753a63b6a7d42b83b2c9d2b51ebe7a0acac3781d
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-03 15:51:12 +00:00
Qt Submodule Update Bot 823302ea42 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I9f84b8cf226507f591bad07573e6a6e51cebc11b
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-04-01 12:48:41 +00:00
Qt Submodule Update Bot 878c67dce3 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I9ccef3f593339a2612ba959bd5fa24faf3802268
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-03-29 16:10:18 +00:00
Qt Submodule Update Bot eda9ac0443 Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I18908f560cad1cd8ca3848e098a521793463b0e2
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-03-19 17:33:54 +00:00
Alexey Edelev 514769d1bd Adapt the generator code to be compatible with protobuf >= 30
The newer protobuf version uses string_views as the return value.
Wrap the respecitive API with constructing std::string and update
some of the util functions to accept std::string_view arguments
but not plain std::string.

Fixes: QTBUG-134885
Pick-to: 6.8 6.9
Change-Id: I8bc06c46167a8b1bc0dca36242249e672ffcccd3
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-19 15:15:37 +01:00
Alexey Edelev 12cb9d24e7 Add the missing copyrights to QtProtobufProperties.cmake.in
Pick-to: 6.8 6.9
Change-Id: I4831e7f993a01aeb75af1fd96a3295e4cb42e7c7
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-19 13:12:30 +01:00
Alexey Edelev b8b8dd9fe2 Avoid storing absolute paths to protobuf module includes
Sanitize proto includes to ensure the generated
<Module>ProtobufProperties.cmake is fully relocatable.

Drive-by, ensure that includes do not contain duplicates.

Task-number: QTBUG-130113
Change-Id: I64f56d497d412705f174a027f711b90ad7614abf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-19 11:35:45 +01:00
Alexey Edelev 53f2963d56 Avoid storing proto_files-NOTFOUND in _qt_internal_proto_files
Ensure we store values correct way.

Pick-to: 6.8 6.9
Change-Id: I89ec10e41969a001d34a73a0fdd77a661b7c9506
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-19 10:47:50 +01:00
Alexey Edelev 252c5467de Add the hint to find the host grpc_cpp_plugin when crosscompiling
gRPC doesn't provide the smart tool lookup when crosscompiling.
So gRPC lookup is unable to find the grpc_cpp_plugin plugin when
crosscompiling examples. Use find_program to find the plugin in
host paths.

Pick-to: 6.8 6.9
Fixes: QTBUG-134647
Change-Id: I961b180b348dee4f1b2f2523be225d3003847e4c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-18 18:08:13 +01:00
Alexey Edelev 428e3d07b9 Fix the cmdLineInvalidExportMacro
The test was faulty positive because of invalid command line.
The input file name was missing there, so protoc was failing to
generate code, but didn't test the actual invalid EXPORT_MACRO name.

Pick-to: 6.8 6.9
Change-Id: Ib57235fb22c740dc30aec58076833c8f6de4a250
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-18 15:30:10 +01:00
Lucie Gérard 2bc78bfb7d Update licensing of files with infrastructure type
A QUIP 18[1] update sets git files, REUSE.toml and licenseRule.json
as infrastructure type files. They are licensed with:
LicenseRef-Qt-Commercial OR BSD-3-Clause

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.9 6.8
Change-Id: Ib3bbda05a9b150dc9f7da564cd3bdc2691a749cc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-03-13 15:14:53 +01:00
Dennis Oberst c0496671be qtgrpc_chat_server: Compile certificates into the application
The previous approach was error-prone, as using TARGET_FILE_DIR
hard-coded the path to the build directory and ignored install locations
entirely.

Fix this by using a more reliable approach: embedding the certificate
strings directly into the application.

Pick-to: 6.9 6.9.0 6.8 6.8.3
Change-Id: Ifb883891fd55bb023e7f9828f9c422ea3e5d1c3e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-13 13:11:23 +01:00