diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2023-10-10 10:29:03 +0300 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2023-10-11 09:30:21 +0000 |
commit | 1772df50a3bacd91ba8125ececf774aa0e6311f9 (patch) | |
tree | 4fb38af9bca69baa9a8493c170c842378e9be5e6 | |
parent | a2463d3921e530f39afbf00c1d5df46e88ce7e06 (diff) |
protobuf: remove probe-based library lookup
It is not reliable these days and it is hard to maintain it.
Only leave provider-based lookup or built-in runtime (via
private _linkLibraries property).
Task-number: QBS-1663
Change-Id: I1cc3e3a7b18f721fe252d9b5489ed7495a9a6366
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | doc/reference/modules/protobufcpp-module.qdoc | 44 | ||||
-rw-r--r-- | share/qbs/modules/protobuf/cpp/protobufcpp.qbs | 100 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 3 |
3 files changed, 12 insertions, 135 deletions
diff --git a/doc/reference/modules/protobufcpp-module.qdoc b/doc/reference/modules/protobufcpp-module.qdoc index 85851c4ae..eef189d0b 100644 --- a/doc/reference/modules/protobufcpp-module.qdoc +++ b/doc/reference/modules/protobufcpp-module.qdoc @@ -78,6 +78,14 @@ \li 1.18.0 \li This tag is attached to the header files generated by \c protoc compiler. \endtable + + \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++). */ /*! @@ -101,24 +109,6 @@ */ /*! - \qmlproperty string protobuf.cpp::grpcIncludePath - - The path where grpc++ headers are located. Set this property to override the - default location. - - \defaultvalue \c auto-detected -*/ - -/*! - \qmlproperty string protobuf.cpp::grpcLibraryPath - - The path where the grpc++ library is located. Set this property to override the - default location. - - \defaultvalue \c auto-detected -*/ - -/*! \qmlproperty pathList protobuf.cpp::importPaths The list of imports that are passed to the \c protoc tool via the \c --proto_path option. @@ -131,24 +121,6 @@ */ /*! - \qmlproperty string protobuf.cpp::includePath - - The path where protobuf C++ headers are located. Set this property to override the - default location. - - \defaultvalue \c auto-detected -*/ - -/*! - \qmlproperty string protobuf.cpp::libraryPath - - The path where the protobuf C++ library is located. Set this property to override the - default location. - - \defaultvalue \c auto-detected -*/ - -/*! \qmlproperty string protobuf.cpp::outputDir \readonly diff --git a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs index e9505dfc4..9a8c55524 100644 --- a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs +++ b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs @@ -6,29 +6,14 @@ import "../protobufbase.qbs" as ProtobufBase import "../protobuf.js" as HelperFunctions ProtobufBase { - property string includePath: includeProbe.found ? includeProbe.path : undefined - property string libraryPath: libraryProbe.found ? libraryProbe.path : undefined - property bool useGrpc: false property bool _linkLibraries: true - property stringList _extraGrpcLibs: [] readonly property bool _hasModules: protobuflib.present && (!useGrpc || grpcpp.present) - property string grpcIncludePath: grpcIncludeProbe.found ? grpcIncludeProbe.path : undefined - property string grpcLibraryPath: grpcLibraryProbe.found ? grpcLibraryProbe.path : undefined - property string _cxxLanguageVersion: "c++17" - readonly property string _libraryName: { - var libraryName; - if (libraryProbe.found) { - libraryName = FileInfo.baseName(libraryProbe.fileName); - if (libraryName.startsWith("lib")) - libraryName = libraryName.substring(3); - } - return libraryName; - } + cpp.includePaths: outputDir Depends { name: "cpp" } Depends { @@ -52,43 +37,6 @@ ProtobufBase { names: "grpc_cpp_plugin" } - cpp.libraryPaths: { - if (!_linkLibraries || _hasModules) - return []; - - var result = []; - if (libraryProbe.found) - result.push(libraryProbe.path); - if (useGrpc && grpcLibraryProbe.found) - result.push(grpcLibraryPath); - return result; - } - cpp.dynamicLibraries: { - if (!_linkLibraries || _hasModules) - return []; - - var result = []; - if (_libraryName) - result.push(_libraryName) - if (qbs.targetOS.includes("unix")) - result.push("pthread"); - if (useGrpc) { - result = result.concat(_extraGrpcLibs); - result.push("grpc++"); - } - return result; - } - cpp.includePaths: { - if (!_linkLibraries || _hasModules) - return [outputDir]; - - var result = [outputDir]; - if (includeProbe.found) - result.push(includePath); - if (useGrpc && grpcIncludeProbe.found) - result.push(grpcIncludePath); - return result; - } cpp.cxxLanguageVersion: _cxxLanguageVersion Rule { @@ -123,56 +71,16 @@ ProtobufBase { } } - Probes.IncludeProbe { - id: includeProbe - names: "google/protobuf/message.h" - platformSearchPaths: includePath ? [] : base - searchPaths: includePath ? [includePath] : [] - } - - Probes.LibraryProbe { - id: libraryProbe - names: [ - "protobuf", - "protobufd", - ] - platformSearchPaths: libraryPath ? [] : base - searchPaths: libraryPath ? [libraryPath] : [] - } - - Probes.IncludeProbe { - id: grpcIncludeProbe - pathSuffixes: "grpc++" - names: "grpc++.h" - platformSearchPaths: grpcIncludePath ? [] : base - searchPaths: grpcIncludePath ? [grpcIncludePath] : [] - } - - Probes.LibraryProbe { - id: grpcLibraryProbe - names: "grpc++" - platformSearchPaths: grpcLibraryPath ? [] : base - searchPaths: grpcLibraryPath ? [grpcLibraryPath] : [] - } - validate: { HelperFunctions.validateCompiler(compilerName, compilerPath); - if (_hasModules) - return; - - if (_linkLibraries && !includeProbe.found) - throw "Can't find cpp protobuf include files. Please set the includePath property."; - if (_linkLibraries && !libraryProbe.found) - throw "Can't find cpp protobuf library. Please set the libraryPath property."; + if (_linkLibraries && ! _hasModules) { + throw "Can't find cpp protobuf runtime. Make sure .pc files are present"; + } if (useGrpc) { if (!File.exists(grpcPluginPath)) throw "Can't find grpc_cpp_plugin plugin. Please set the grpcPluginPath property."; - if (_linkLibraries && !grpcIncludeProbe.found) - throw "Can't find grpc++ include files. Please set the grpcIncludePath property."; - if (_linkLibraries && !grpcLibraryProbe.found) - throw "Can't find grpc++ library. Please set the grpcLibraryPath property."; } } } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index f8a037766..c39cc33f1 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -5956,7 +5956,6 @@ void TestBlackbox::protobuf_data() QTest::addColumn<QStringList>("properties"); QTest::addColumn<bool>("hasModules"); QTest::addColumn<bool>("successExpected"); - QTest::newRow("cpp") << QString("addressbook_cpp.qbs") << QStringList() << false << true; QTest::newRow("cpp-pkgconfig") << QString("addressbook_cpp.qbs") << QStringList("project.qbsModuleProviders:qbspkgconfig") @@ -8367,8 +8366,6 @@ void TestBlackbox::grpc_data() QTest::addColumn<QStringList>("arguments"); QTest::addColumn<bool>("hasModules"); - QTest::newRow("cpp") << QString("grpc_cpp.qbs") << QStringList() << false; - QStringList pkgConfigArgs("project.qbsModuleProviders:qbspkgconfig"); // on macOS, openSSL is hidden from pkg-config by default if (qbs::Internal::HostOsInfo::isMacosHost()) { |