aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Schäpers <bjoern@hazardy.de>2023-12-08 23:42:54 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2024-01-11 17:47:49 +0000
commitaa044048f0b3573ddda09d1b7a4483af9eed3de4 (patch)
treeb952317f5916f7e5954c7ae35542d9ac045b32d1
parent167799f31c8ca3cfd79394b6c3fe8389c7df4de1 (diff)
protobuf: Usable without qbspkgconfigprovider
It only fails with "Can't find cpp protobuf runtime. Make sure .pc files are present" which is not helpful, since they are present. Additionally remove the grpcpp to grpc++ mapping in both pkg-config probes. This kind of amends 1772df50a3bacd91ba8125ececf774aa0e6311f9, I readded the tests. Task-number: QBS-1663 Change-Id: I73b7b76a66cc2b8eea5dddd57e5221715b6e6014 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--doc/reference/modules/protobufcpp-module.qdoc7
-rw-r--r--share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs6
-rw-r--r--share/qbs/module-providers/qbspkgconfig.qbs3
-rw-r--r--share/qbs/modules/protobuf/cpp/protobufcpp.qbs9
-rw-r--r--tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs1
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp16
6 files changed, 25 insertions, 17 deletions
diff --git a/doc/reference/modules/protobufcpp-module.qdoc b/doc/reference/modules/protobufcpp-module.qdoc
index eef189d0b..2c96eaeef 100644
--- a/doc/reference/modules/protobufcpp-module.qdoc
+++ b/doc/reference/modules/protobufcpp-module.qdoc
@@ -82,10 +82,9 @@
\section2 Dependencies
The \l protobuf.cpp module requires runtime libraries to be operational. It depends on the
- \c "protobuflib" module which can be created by the \l qbspkgconfig module provider (the
- corresponding packages are \c protobuf or \c protobuf-lite). If \l useGrpc is set to true,
- the \l protobuf.cpp module also depends on the \c "grpcpp" module (corresponding package is
- \c gprc++).
+ \c "protobuflib" module which can be created by the \l qbspkgconfig or fallback module
+ providers (the corresponding packages are \c protobuf or \c protobuf-lite). If \l useGrpc is
+ set to true, the \l protobuf.cpp module also depends on the \c "grpc++" module.
*/
/*!
diff --git a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs
index 61a9c0b74..0fe81c3cc 100644
--- a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs
+++ b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs
@@ -85,6 +85,12 @@ Probe {
&& p.exec(executable, versionArgs.concat(packageNames)) !== 0) {
return;
}
+
+ // protobuf is reserved as qbs module name, which depends on the protobuflib module
+ packageNames = packageNames.map(function(name) {
+ return name === "protobuflib" ? "protobuf" : name;
+ });
+
var args = packageNames;
if (p.exec(executable, args.concat([ '--cflags' ])) === 0) {
stdout = p.readStdOut().trim();
diff --git a/share/qbs/module-providers/qbspkgconfig.qbs b/share/qbs/module-providers/qbspkgconfig.qbs
index aebed0ab3..0c6c99293 100644
--- a/share/qbs/module-providers/qbspkgconfig.qbs
+++ b/share/qbs/module-providers/qbspkgconfig.qbs
@@ -144,8 +144,7 @@ ModuleProvider {
// TODO: ponder how we can solve forward mapping with Packages so we can fill deps
var moduleMapping = {
- "protobuf": "protobuflib",
- "grpc++": "grpcpp"
+ "protobuf": "protobuflib"
}
var reverseMapping = {}
for (var key in moduleMapping)
diff --git a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs
index 9a8c55524..b5dab2372 100644
--- a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs
+++ b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs
@@ -19,14 +19,13 @@ ProtobufBase {
Depends {
name: "protobuflib";
condition: _linkLibraries;
- required: false;
- enableFallback: false
+ required: false
}
Depends {
- name: "grpcpp";
+ name: "grpc++";
+ id: grpcpp
condition: _linkLibraries && useGrpc;
- required: false;
- enableFallback: false
+ required: false
}
property path grpcPluginPath: grpcPluginProbe.filePath
diff --git a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs
index dd2184c7e..4b004a884 100644
--- a/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs
+++ b/tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs
@@ -16,6 +16,7 @@ CppApplication {
cpp.warningLevel: "none"
Depends { name: "protobuf.cpp"; required: false }
+ Depends { name: "grpc++"; id: grpcpp; required: false }
protobuf.cpp.useGrpc: true
property bool hasDependencies: {
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index e6a72cd77..4e97ba92c 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -5957,21 +5957,22 @@ void TestBlackbox::protobuf_data()
QTest::addColumn<QStringList>("properties");
QTest::addColumn<bool>("hasModules");
QTest::addColumn<bool>("successExpected");
+ QTest::newRow("cpp-fallback") << QString("addressbook_cpp.qbs") << QStringList() << true << true;
QTest::newRow("cpp-pkgconfig")
<< QString("addressbook_cpp.qbs")
- << QStringList("project.qbsModuleProviders:qbspkgconfig")
+ << QStringList({"project.qbsModuleProviders:qbspkgconfig", "--no-fallback-module-provider"})
<< true
<< true;
QTest::newRow("objc") << QString("addressbook_objc.qbs") << QStringList() << false << true;
QTest::newRow("nanopb") << QString("addressbook_nanopb.qbs") << QStringList() << false << true;
- QTest::newRow("import") << QString("import.qbs") << QStringList() << false << true;
+ QTest::newRow("import") << QString("import.qbs") << QStringList() << true << true;
QTest::newRow("missing import dir") << QString("needs-import-dir.qbs")
- << QStringList() << false << false;
+ << QStringList() << true << false;
QTest::newRow("provided import dir")
<< QString("needs-import-dir.qbs")
- << QStringList("products.app.theImportDir:subdir") << false << true;
+ << QStringList("products.app.theImportDir:subdir") << true << true;
QTest::newRow("create proto library")
- << QString("create-proto-library.qbs") << QStringList() << false << true;
+ << QString("create-proto-library.qbs") << QStringList() << true << true;
}
void TestBlackbox::protobuf()
@@ -8373,7 +8374,10 @@ void TestBlackbox::grpc_data()
QTest::addColumn<QStringList>("arguments");
QTest::addColumn<bool>("hasModules");
- QStringList pkgConfigArgs("project.qbsModuleProviders:qbspkgconfig");
+ QTest::newRow("cpp-fallback") << QString("grpc_cpp.qbs") << QStringList() << true;
+
+ QStringList pkgConfigArgs({
+ "project.qbsModuleProviders:qbspkgconfig", "--no-fallback-module-provider"});
// on macOS, openSSL is hidden from pkg-config by default
if (qbs::Internal::HostOsInfo::isMacosHost()) {
pkgConfigArgs